2010-08-12 13:08:09 +00:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2010-08-12 15:43:47 +00:00
|
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2010-08-12 13:08:09 +00:00
|
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
|
|
<head>
|
2010-08-13 10:02:47 +00:00
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
|
|
<title>hump - LÖVE Helper Utilities for More Productivity</title>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
body {
|
|
|
|
margin-top: 1.0em;
|
|
|
|
background-color: #f7fcfc;
|
|
|
|
font-family: "Helvetica,Arial,FreeSans";
|
|
|
|
color: #000000;
|
|
|
|
}
|
|
|
|
#container {
|
|
|
|
margin: 0 auto;
|
|
|
|
width: 800px;
|
|
|
|
}
|
|
|
|
h1 { font-size: 3.8em; color: #080303; margin-bottom: 10px; border-bottom: 2px solid #080303; }
|
|
|
|
h1 .small { font-size: 0.4em; }
|
|
|
|
h1 a { text-decoration: none }
|
|
|
|
h2 { font-size: 1.5em; color: #080303; border-top: 1px solid #a0a0a0; }
|
|
|
|
h3 { color: #080303; margin-bottom: 1em; background: #eee; margin-top: 3em; }
|
|
|
|
h4 { color: #080303; margin-top: 2em; }
|
|
|
|
a { color: #080303; }
|
|
|
|
.description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;}
|
|
|
|
.download { float: right; }
|
|
|
|
pre { background: #000; color: #fff; padding: 15px;}
|
|
|
|
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
|
|
|
.footer { text-align:center; padding-top:30px; font-style: italic; }
|
|
|
|
|
|
|
|
ul.nav { display:inline; margin-left: 0; padding-left: 0; }
|
|
|
|
ul.nav li { display:inline; margin-right: 1em; }
|
|
|
|
|
|
|
|
a.top { font-size: 8pt; margin-left: 1em; float: right; }
|
2010-09-04 10:29:19 +00:00
|
|
|
a.source { border-radius: 5px; -moz-border-radius: 5px; font-weight:bold; float:right; border:1px solid #777; padding: 2px 4px 2px 4px; background: #e4e4e4; text-decoration:none; font-size: 9pt;}
|
|
|
|
a.source:hover { background: #eee; border-color: #aaa; color: #555;}
|
2010-08-13 10:02:47 +00:00
|
|
|
|
|
|
|
.doc { padding-left: 1em; margin-bottom: 1em; border-left: 1px dotted #aaa; }
|
2010-11-13 15:48:05 +00:00
|
|
|
.functiondoc { display:block; font-weight:bold; font-family: fixed; background: #f9f9f9; border:1px solid #ddd; margin-left: -1em; }
|
2010-08-13 10:02:47 +00:00
|
|
|
|
|
|
|
.functionlist { border-left: 1px dotted #aaa; margin: -.6em 0 0 2em; }
|
|
|
|
.functionlist a { text-decoration: none; font-weight:bold; color: #506060; }
|
|
|
|
.functionlist a:hover { color: black; }
|
2010-10-16 15:28:13 +00:00
|
|
|
.functionlist td em { font-size: .8em; font-weight:bold;width:7em; display:inline-block; }
|
2010-08-13 10:02:47 +00:00
|
|
|
|
2010-08-17 19:49:30 +00:00
|
|
|
td, th { vertical-align: top; }
|
2010-08-13 10:02:47 +00:00
|
|
|
.doc table { margin-top: 5px; }
|
2010-08-17 19:49:30 +00:00
|
|
|
td, th { border-top: 1px dashed #ddd; }
|
2010-08-13 10:02:47 +00:00
|
|
|
th { text-align: left; font-weight: normal; font-style: italic; text-decoration: underline; }
|
2010-08-17 19:49:30 +00:00
|
|
|
td { padding-left: 1em; margin: 0; }
|
2010-10-18 11:02:45 +00:00
|
|
|
td.p { text-align: right; vertical-align: top; }
|
2010-08-13 10:02:47 +00:00
|
|
|
.doc td em { font-size: .8em; font-weight:bold; font-style:normal; padding-right: .6em;}
|
|
|
|
|
|
|
|
.doc pre, code { color: black; padding: 0; font-family: fixed; border: 1px solid #ddd; background: #e7ecec; }
|
2010-11-13 15:48:05 +00:00
|
|
|
pre code.lua { border: 0; }
|
2010-08-13 10:02:47 +00:00
|
|
|
</style>
|
2010-11-13 15:48:05 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="highlight.css" />
|
|
|
|
<script type="text/javascript" src="highlight.pack.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
window.onload = function() {
|
|
|
|
var examples = document.getElementsByTagName("code");
|
|
|
|
for (i = 0; i < examples.length; ++i) {
|
|
|
|
if (examples[i].className == "lua")
|
|
|
|
hljs.highlightBlock(examples[i], " ");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
2010-08-12 13:08:09 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2010-08-13 10:02:47 +00:00
|
|
|
<a href="http://github.com/vrld/hump"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
|
|
|
|
|
|
|
|
<a name="top"></a>
|
|
|
|
<div id="container">
|
|
|
|
|
|
|
|
<h1><a href="http://github.com/vrld/hump">hump</a>
|
|
|
|
<span class="small"> Helper Utilities for More Productivity</span></h1>
|
|
|
|
|
|
|
|
<ul class="nav">
|
|
|
|
<li><a href="#intro">Introduction</a></li>
|
|
|
|
<li><a href="#doc">Documenation</a></li>
|
|
|
|
<li><a href="#license">License</a></li>
|
|
|
|
<li><a href="#download">Download</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<a name="intro"></a>
|
|
|
|
<h2>Introduction<a class="top" href="#top">^ top</a></h2>
|
|
|
|
<p><em>Helper Utilities for a Multitude of Problems</em> is a set of lightweight helpers
|
|
|
|
for the excellent <a href="http://love2d.org/">LÖVE</a> Engine.</p>
|
|
|
|
|
|
|
|
<p>It currently features
|
|
|
|
<ul>
|
2010-10-17 14:03:13 +00:00
|
|
|
<li><em>gamestate.lua</em>: a gamestate system.</li>
|
|
|
|
<li><em>timer.lua</em>: timed function calling and interpolating functions,</li>
|
2010-08-13 10:02:47 +00:00
|
|
|
<li><em>vector.lua</em>: a mature vector type,</li>
|
|
|
|
<li><em>class.lua</em>: a simple and easy class system with function inheritance,</li>
|
2010-10-18 11:02:45 +00:00
|
|
|
<li><em>camera.lua</em>: a move-, zoom- and rotatable camera and</li>
|
2010-08-17 17:11:21 +00:00
|
|
|
<li><em>ringbuffer.lua</em>: a circular container.</li>
|
2010-08-17 19:49:30 +00:00
|
|
|
<li><em>sequence.lua</em>: utility to handle ingame cutscenes and such.</li>
|
2010-08-13 10:02:47 +00:00
|
|
|
</ul></p>
|
|
|
|
|
|
|
|
<p><em>hump</em> differs from other libraries in that every component is independent of the
|
2010-08-17 19:49:30 +00:00
|
|
|
remaining ones (apart from camera.lua, which depends on the vector type, and sequence.lua which requires ringbuffer.lua).
|
2010-08-13 10:02:47 +00:00
|
|
|
<em>hump</em>'s footprint is very small and thus should fit nicely into your projects.</p>
|
|
|
|
|
|
|
|
<a name="doc"></a>
|
|
|
|
<h2>Documentation<a class="top" href="#top">^ top</a></h2>
|
|
|
|
|
|
|
|
Below is the documentation of the various modules. You can directly jump to a
|
|
|
|
module by clicking these:
|
|
|
|
<ul>
|
2010-10-17 14:03:13 +00:00
|
|
|
<li><a href="#gamestate.lua">gamestate.lua</a></li>
|
|
|
|
<li><a href="#timer.lua">timer.lua</a></li>
|
2010-08-13 10:02:47 +00:00
|
|
|
<li><a href="#vector.lua">vector.lua</a></li>
|
|
|
|
<li><a href="#class.lua">class.lua</a></li>
|
|
|
|
<li><a href="#camera.lua">camera.lua</a></li>
|
2010-08-17 17:11:21 +00:00
|
|
|
<li><a href="#ringbuffer.lua">ringbuffer.lua</a></li>
|
2010-08-17 19:49:30 +00:00
|
|
|
<li><a href="#sequence.lua">sequence.lua</a></li>
|
2010-08-13 10:02:47 +00:00
|
|
|
</ul>
|
|
|
|
|
2010-10-17 14:03:13 +00:00
|
|
|
<div class="module"><a name="gamestate.lua"></a>
|
|
|
|
<h3>gamestate.lua<a class="top" href="#doc">^ top</a></h3>
|
|
|
|
<a href="http://github.com/vrld/hump/blob/master/gamestate.lua" class="source">view source</a>
|
|
|
|
|
|
|
|
<p>Useful to separate different states of your game (hence "gamestate") like title screens,
|
|
|
|
level loading, main game, etc. Each gamestate can have it's own <code>update()</code>, <code>draw()</code>,
|
|
|
|
<code>keyreleased()</code>, <code>keypressed()</code> and <code>mousereleased()</code> which correspond
|
|
|
|
to the ones defined in love. See the <a href="#gamestate.lua-callbackList">callback list</a> for more details.</p>
|
|
|
|
|
|
|
|
<p>Additionally, each gamestate can define a <code>enter(pre, ...)</code> and <code>leave()</code> function,
|
|
|
|
which are called when using <code>Gamestate.switch(to, ...)</code>. <em>Do not attempt to use these functions
|
|
|
|
yourself to initialize the first gamestate,</em> use the <code>switch</code> function instead.</p>
|
|
|
|
|
|
|
|
<p>The module defines the following functions:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><a href="#gamestate.lua-new">Gamestate.new()</a></td><td>New gamestate</td></tr>
|
|
|
|
<tr><td><a href="#gamestate.lua-switch">Gamestate.switch(to, ...)</a></td><td>Switch gamestate</td></tr>
|
2010-10-31 12:17:43 +00:00
|
|
|
<tr><td><a href="#gamestate.lua-update">Gamestate.update(...)</a></td><td>Call update callback</td></tr>
|
|
|
|
<tr><td><a href="#gamestate.lua-draw">Gamestate.draw(...)</a></td><td>Call draw callback</td></tr>
|
|
|
|
<tr><td><a href="#gamestate.lua-keypressed">Gamestate.keypressed(...)</a></td><td>Call keypressed callback</td></tr>
|
|
|
|
<tr><td><a href="#gamestate.lua-keyreleased">Gamestate.keyreleased(...)</a></td><td>Call keyreleased callback</td></tr>
|
|
|
|
<tr><td><a href="#gamestate.lua-mousepressed">Gamestate.mousepressed(...)</a></td><td>Call mousepressed callback</td></tr>
|
|
|
|
<tr><td><a href="#gamestate.lua-mousereleased">Gamestate.mousereleased(...)</a></td><td>Call mousereleased callback</td></tr>
|
|
|
|
<tr><td><a href="#gamestate.lua-joystickpressed">Gamestate.joystickpressed(...)</a></td><td>Call joystickpressed callback</td></tr>
|
|
|
|
<tr><td><a href="#gamestate.lua-joystickreleased">Gamestate.joystickreleased(...)</a></td><td>Call joystickreleased callback</td></tr>
|
2010-10-17 14:03:13 +00:00
|
|
|
<tr><td><a href="#gamestate.lua-registerEvents">Gamestate.registerEvents()</a></td><td>Register all callbacks</td></tr>
|
|
|
|
</table></p>
|
|
|
|
|
|
|
|
<a name="gamestate.lua-new"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.new()<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Create a new gamestate.
|
|
|
|
<table><tr><th>Returns:</th><td>The new (but empty) gamestate object.</td></tr></table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="gamestate.lua-switch"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.switch(to, ...)<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Switch the gamestate.
|
|
|
|
<p>Calls <code>leave()</code> on the currently active gamestate.</p>
|
|
|
|
<p>Calls <code>enter(current, ...)</code> on the target gamestate, where <code>current</code>
|
|
|
|
is the gamestate before the switch and <code>...</code> are the additionals arguments given
|
|
|
|
to <code>Gamestate.switch</code>.</p>
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[gamestate]</em><code>to</code>:</td><td>target gamestate.</td></tr>
|
|
|
|
<tr><td> </td><td class="p"><code>...</code>:</td><td>additional arguments to pass</td></tr>
|
|
|
|
<tr><th>Returns:</th><td colspan="2">the result of <code>to:enter(current, ...)</code></td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="gamestate.lua-update"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.update(dt)<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Calls <code>update(dt)</code> on current gamestate.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="gamestate.lua-draw"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.draw()<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Calls <code>draw()</code> on current gamestate.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="gamestate.lua-keypressed"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.keypressed(key, unicode)<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Calls <code>keypressed(key, unicode)</code> on current gamestate.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="gamestate.lua-keyreleased"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.keyreleased(key)<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Calls <code>keyreleased(key)</code> on current gamestate.
|
|
|
|
</div>
|
|
|
|
|
2010-10-31 12:17:43 +00:00
|
|
|
<a name="gamestate.lua-mousepressed"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.mousepressed(x,y,btn)<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-31 12:17:43 +00:00
|
|
|
Calls <code>mousepressed(x,y,btn)</code> on the current gamestate.
|
|
|
|
</div>
|
2010-10-17 14:03:13 +00:00
|
|
|
|
|
|
|
<a name="gamestate.lua-mousereleased"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.mousereleased(x,y,btn)<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Calls <code>mousereleased(x,y,btn)</code> on the current gamestate.
|
|
|
|
</div>
|
|
|
|
|
2010-10-31 12:17:43 +00:00
|
|
|
<a name="gamestate.lua-joystickpressed"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.joystickpressed(joystick, button)<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-31 12:17:43 +00:00
|
|
|
Calls <code>joystickpressed(joystick, button)</code> on the current gamestate.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="gamestate.lua-joystickpressed"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.joystickreleased(joystick, button)<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-31 12:17:43 +00:00
|
|
|
Calls <code>joystickreleased(joystick, button)</code> on the current gamestate.
|
|
|
|
</div>
|
|
|
|
|
2010-10-17 14:03:13 +00:00
|
|
|
<a name="gamestate.lua-registerEvents"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Gamestate.registerEvents()<a class="top" href="#gamestate.lua">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Registers all above events so you don't need to call then in your <code>love.*</code> routines.
|
|
|
|
<p>It is an error to call this anywhere else than <code>love.load()</code>, since it overwrites the
|
|
|
|
callbacks. Don't worry though, your callbacks will still be executed.</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="gamestate.lua-callbackList"></a>
|
|
|
|
<h4>List of callbacks<a class="top" href="#gamestate.lua">^ top</a></h4>
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><code>enter(previous, ...)</code></td>
|
|
|
|
<td>Gets called upon entering the state. <strong>Don't call this yourself, use
|
|
|
|
<code>Gamestate.switch</code> instead.</strong></td></tr>
|
|
|
|
<tr><td><code>leave()</code></td>
|
|
|
|
<td>Gets called upon leaving the state. The same warning as with <code>enter</code> applies.</td></tr>
|
|
|
|
<tr><td><code>update(dt)</code></td>
|
|
|
|
<td>Manually called by <code>Gamestate.update</code>, or automatically like <code>love.update</code>
|
|
|
|
when using <code>Gamestate.registerEvents()</code>.</td></tr>
|
|
|
|
<tr><td><code>draw()</code></td>
|
|
|
|
<td>Manually called by <code>Gamestate.draw</code>, or automatically like <code>love.draw</code></td></tr>
|
|
|
|
<tr><td><code>keypressed(key, unicode)</code></td>
|
|
|
|
<td>Manually called by <code>Gamestate.keypressed</code>, or automatically like <code>love.keypressed</code></td></tr>
|
|
|
|
<tr><td><code>keyreleased(key)</code></td>
|
|
|
|
<td>Manually called by <code>Gamestate.keyreleased</code>, or automatically like <code>love.keyreleased</code></td></tr>
|
2010-10-31 12:17:43 +00:00
|
|
|
<tr><td><code>mousepressed(x,y,btn)</code></td>
|
|
|
|
<td>Manually called by <code>Gamestate.mousepressed</code>, or automatically like <code>love.mousepressed</code></td></tr>
|
|
|
|
<tr><td><code>mousereleased(x,y,btn)</code></td>
|
2010-10-17 14:03:13 +00:00
|
|
|
<td>Manually called by <code>Gamestate.mousereleased</code>, or automatically like <code>love.mousereleased</code></td></tr>
|
2010-10-31 12:17:43 +00:00
|
|
|
<tr><td><code>joystickpressed(joystick,btn)</code></td>
|
|
|
|
<td>Manually called by <code>Gamestate.joystickpressed</code>, or automatically like <code>love.joystickpressed</code></td></tr>
|
|
|
|
<tr><td style="width:200px;"><code>joystickreleased(joystick,btn)</code></td>
|
|
|
|
<td>Manually called by <code>Gamestate.joystickreleased</code>, or automatically like <code>love.joystickreleased</code></td></tr>
|
2010-10-17 14:03:13 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="module"><a name="timer.lua"></a>
|
|
|
|
<h3>timer.lua<a class="top" href="#doc">^ top</a></h3>
|
|
|
|
<a href="http://github.com/vrld/hump/blob/master/timer.lua" class="source">view source</a>
|
|
|
|
|
|
|
|
<p>This module consists of two parts:<ul>
|
|
|
|
<li><code>Timer</code> to enable delayed function calls and</li>
|
|
|
|
<li><code>Interpolator</code> for easy abstraction of functions that interpolate something over time.</li>
|
|
|
|
</ul>All functions are <a href="http://en.wikipedia.org/wiki/Higher-order_function">higher order functions</a>,
|
|
|
|
which is a concept that may seem confusing at first. The <a href="#timer.lua-Example">example</a> shows how to
|
|
|
|
use this concept.
|
|
|
|
</p>
|
|
|
|
<p>Functions:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><a href="#timer.lua-add">Timer.add(delay, func)</a></td><td>Add a delayed function</td></tr>
|
|
|
|
<tr><td><a href="#timer.lua-addPeriodic">Timer.addPeriodic(delay, func, count)</a></td><td>Add a periodic function</td></tr>
|
|
|
|
<tr><td><a href="#timer.lua-clear">Timer.clear()</a></td><td>Clear functions</td></tr>
|
|
|
|
<tr><td><a href="#timer.lua-update">Timer.update(dt)</a></td><td>Update timer</td></tr>
|
|
|
|
<tr><td><a href="#timer.lua-Interpolator">Interpolator(length, func)</a></td><td>Create interpolating function</td></tr>
|
2010-10-18 11:02:45 +00:00
|
|
|
<tr><td><a href="#timer.lua-Oscillator">Oscillator(length, func)</a></td><td>Create interpolating function</td></tr>
|
2010-10-17 14:03:13 +00:00
|
|
|
</table></p>
|
|
|
|
<p>Note the <em>.</em> (dot) in the function names. It is an error to call <code>Timer.add</code> with a colon! If you
|
|
|
|
get weird errors, that might be the cause.</p>
|
|
|
|
<p>The <code>Timer</code> stores it's timed functions in the table <code>Timer.functions</code>.
|
|
|
|
You can manipulate it, but probably shouldn't.</p>
|
|
|
|
|
|
|
|
<a name="timer.lua-add"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Timer.add(delay, func)<a href="#timer.lua" class="top">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Add a timed function. The function will be executed when <code>delay</code> seconds have elapsed.
|
|
|
|
<p>Note that there is <em>no guarantee</em> that the delay will be exceeded. It is, however, guaranteed that
|
|
|
|
the function will not be executed before the delay has passed.</p>
|
|
|
|
<p>If the function is called, it will receive itself as only parameter. This may be useful to implement the
|
|
|
|
periodic behavior of <code>Timer.addPeriodic</code> <a href="#timer.lua-Example">(see the example)</a>.
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[number]</em><code>delay</code>:</td>
|
|
|
|
<td>Time that has to pass before the function is called</td></tr>
|
|
|
|
<tr><th></th><td class="p"><em>[function]</em><code>func</code>:</td><td>The function to be called</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="timer.lua-addPeriodic"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Timer.addPeriodic(delay, func, count)<a href="#timer.lua" class="top">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Add a periodic timed function, i.e. a function that will be called every <code>delay</code> seconds.
|
|
|
|
<p>The same things as with <code>Timer.add</code> apply.</p>
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[number]</em><code>delay</code>:</td>
|
|
|
|
<td>Time that has to pass before the function is called</td></tr>
|
|
|
|
<tr><th></th><td class="p"><em>[function]</em><code>func</code>:</td><td>The function to be called.</td></tr>
|
2010-10-18 11:02:45 +00:00
|
|
|
<tr><th></th><td class="p" style="width:12em;"><em>[optional number]</em><code>count</code>:</td>
|
2010-10-17 14:03:13 +00:00
|
|
|
<td>Number of times the function should be called. If omitted, the function loops indefinitely.</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="timer.lua-clear"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Timer.clear()<a href="#timer.lua" class="top">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Clears all timers. That is, it resets the table <code>Timer.functions</code>.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="timer.lua-update"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Timer.update(dt)<a href="#timer.lua" class="top">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Update timers and execute functions if the deadline is reached. Use this function in <code>love.update(dt)</code>.
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[number]</em><code>dt</code>:</td>
|
|
|
|
<td>Time that has passed since the last <code>Timer.update</code>.</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="timer.lua-Interpolator"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Interpolator(length, func)<a href="#timer.lua" class="top">^ top</a></span>
|
2010-10-17 14:03:13 +00:00
|
|
|
Helper to create interpolating functions, i.e. functions that changes it's behavior depending
|
|
|
|
on how much time has passed.
|
|
|
|
<p>The interpolating function <code>func</code> will receive the fraction (in respect to
|
|
|
|
the supplied <code>length</code>) of time that has passed, but 1.0 at max.</p>
|
|
|
|
<p><code>Interpolator</code> creates a function that will have to be called in <code>love.update</code>, which
|
|
|
|
will itself execute <code>func</code> with the right parameters. It returns <code>true</code> as long as
|
2010-10-17 14:24:27 +00:00
|
|
|
the interpolation is not yet finished or <code>nil</code> if the interpolation stopped as well
|
|
|
|
as any parameters that the function returns.</p>
|
2010-10-18 11:02:45 +00:00
|
|
|
<p>The prototype of the functions are:<ul>
|
|
|
|
<li>Argument function: <code>function arg(fraction, ...)</code> where <code>...</code> are additional arguments.</li>
|
|
|
|
<li>Returned function: <code>function inter(dt, ...)</code> where <code>...</code> are arguments that get passed to arg</li>
|
|
|
|
</ul>
|
|
|
|
</p>
|
2010-10-17 14:03:13 +00:00
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[number]</em><code>length</code>:</td><td>Interpolation length.</td></tr>
|
|
|
|
<tr><th></th><td class="p"><em>[function]</em><code>func</code>:</td><td>Interpolating function.</td></tr>
|
2010-10-18 11:02:45 +00:00
|
|
|
<tr><th>Returns</th><td colspan="2">A function <code>inter(dt, ...)</code> that has
|
|
|
|
to be called in <code>love.update</code>.</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="timer.lua-Oscillator"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Oscillator(length, func)<a href="#timer.lua" class="top">^ top</a></span>
|
2010-10-18 11:02:45 +00:00
|
|
|
Create oscillating function, i.e. a looped interpolating function.
|
|
|
|
<p>The function does the same as <code>Interpolator</code>, except that if the passed time reaches <code>length</code>,
|
|
|
|
the internal timer will be reset. That means that the <code>fraction</code>-argument of the oscillating
|
|
|
|
function will loop from 0 to 1.</p>
|
|
|
|
<p>See the example for clarification</p>
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[number]</em><code>length</code>:</td><td>Length of one period.</td></tr>
|
|
|
|
<tr><th></th><td class="p"><em>[function]</em><code>func</code>:</td><td>Oscillating function.</td></tr>
|
|
|
|
<tr><th>Returns</th><td colspan="2">A function <code>osc(dt, ...)</code> that has
|
2010-10-17 14:03:13 +00:00
|
|
|
to be called in <code>love.update</code>.</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="timer.lua-Example"></a>
|
|
|
|
<h4>Example usage</h4>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">Timer example <a class="top" href="#timer.lua">^ top</a></span>
|
2010-10-17 14:24:27 +00:00
|
|
|
This example will print the number of elapsed seconds in the top left corner using a periodic function and
|
|
|
|
show five circles one after another using delayed functions:
|
2010-11-13 15:48:05 +00:00
|
|
|
<pre><code class="lua">time = 0
|
2010-10-17 14:24:27 +00:00
|
|
|
circles = {}
|
|
|
|
function love.load()
|
2010-11-13 15:48:05 +00:00
|
|
|
Timer.add(1, function() circles[#circles+1] = {x = 100, y = 100, r = 10} end)
|
|
|
|
Timer.add(2, function() circles[#circles+1] = {x = 130, y = 130, r = 20} end)
|
|
|
|
Timer.add(3, function() circles[#circles+1] = {x = 180, y = 180, r = 30} end)
|
|
|
|
Timer.add(4, function() circles[#circles+1] = {x = 250, y = 250, r = 40} end)
|
|
|
|
Timer.add(5, function() circles[#circles+1] = {x = 340, y = 340, r = 50} end)
|
|
|
|
Timer.addPeriodic(1, function() time = time + 1 end)
|
|
|
|
|
|
|
|
love.graphics.setBackgroundColor(255,255,255)
|
|
|
|
love.graphics.setColor(0,0,0)
|
2010-10-17 14:24:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.update(dt)
|
2010-11-13 15:48:05 +00:00
|
|
|
Timer.update(dt)
|
2010-10-17 14:24:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.draw()
|
2010-11-13 15:48:05 +00:00
|
|
|
love.graphics.print(tostring(time), 20,20)
|
|
|
|
for _,c in ipairs(circles) do
|
|
|
|
love.graphics.circle('fill', c.x, c.y, c.r)
|
|
|
|
end
|
|
|
|
end</code></pre>
|
2010-10-17 14:03:13 +00:00
|
|
|
</div>
|
2010-10-17 14:24:27 +00:00
|
|
|
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">Implementing <code>Timer.addPeriodic()</code> <a class="top" href="#timer.lua">^ top</a></span>
|
2010-10-17 14:24:27 +00:00
|
|
|
Since the function will receive itself as parameter when called, it is easy to implement
|
|
|
|
a function that will reschedule itself:
|
2010-11-13 15:48:05 +00:00
|
|
|
<pre><code class="lua">Timer.add(1, function(func) print("foo") Timer.add(1, func) end)</code></pre>
|
2010-10-17 14:24:27 +00:00
|
|
|
</pre>
|
|
|
|
</div>
|
|
|
|
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">Using Interpolator and Oscillator<a class="top" href="#timer.lua">^ top</a></span>
|
2010-10-17 14:24:27 +00:00
|
|
|
This example uses an interpolating function to fade the background from black to white and
|
2010-10-18 11:02:45 +00:00
|
|
|
swings a circle around the screen center:
|
2010-11-13 15:48:05 +00:00
|
|
|
<pre><code class="lua">function love.load()
|
|
|
|
love.graphics.setBackgroundColor(0,0,0)
|
|
|
|
love.graphics.setColor(0,0,0)
|
2010-10-17 14:24:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
xpos = 100
|
2010-11-13 15:48:05 +00:00
|
|
|
fader = Interpolator(5, function(frac)
|
|
|
|
love.graphics.setBackgroundColor(frac*255,frac*255,frac*255)
|
|
|
|
end)
|
|
|
|
|
|
|
|
mover = Oscillator(10, function(frac)
|
|
|
|
xpos = 400 + 300 * math.sin(2*math.pi*frac)
|
|
|
|
end)
|
|
|
|
|
2010-10-17 14:24:27 +00:00
|
|
|
function love.update(dt)
|
2010-11-13 15:48:05 +00:00
|
|
|
fader(dt)
|
|
|
|
mover(dt)
|
2010-10-17 14:24:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.draw()
|
2010-11-13 15:48:05 +00:00
|
|
|
love.graphics.circle('fill', xpos, 300, 80, 36)
|
|
|
|
end</code></pre>
|
2010-10-17 14:03:13 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="module"><a name="vector.lua"></a>
|
2010-08-13 10:02:47 +00:00
|
|
|
<h3>vector.lua<a class="top" href="#doc">^ top</a></h3>
|
2010-09-04 10:29:19 +00:00
|
|
|
<a href="http://github.com/vrld/hump/blob/master/vector.lua" class="source">view source</a>
|
2010-10-16 15:28:13 +00:00
|
|
|
<p>A vector class implementing nearly everything you want to do with vectors, and some more.</p>
|
|
|
|
<p>Accessors:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><em>[number]</em> <code>vector.x</code></td><td><code>x</code>-coordinate of the vector</td></tr>
|
|
|
|
<tr><td><em>[number]</em> <code>vector.y</code></td><td><code>y</code>-coordinate of the vector</td></tr>
|
|
|
|
</table>
|
|
|
|
</p>
|
|
|
|
<p>Function overview (click item for more details):
|
2010-08-13 10:02:47 +00:00
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><a href="#vector.lua-vector">vector(x,y)</a></td><td>constructor</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-isvector">isvector(v)</a></td><td>type check</td></tr>
|
2010-08-17 12:35:29 +00:00
|
|
|
<tr><td><a href="#vector.lua-clone">vector:clone()</a></td><td>deep copy</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-unpack">vector:unpack()</a></td><td>element unfolding</td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
<tr><td><a href="#vector.lua-operators">Operators</a></td><td>Arithmetics and ordering</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-permul">vector:permul(other)</a></td><td>per-element multiplication</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-len">vector:len()</a></td><td>vector length</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-len2">vector:len2()</a></td><td>squared vector length</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-dist">vector:dist(other)</a></td><td>distance to vector</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-normalized">vector:normalized()</a></td><td>normalize vector</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-normalize_inplace">vector:normalize_inplace()</a></td><td>normalize vector in-place</td></tr>
|
2010-08-17 12:35:29 +00:00
|
|
|
<tr><td><a href="#vector.lua-rotated">vector:rotated(phi)</a></td><td>rotate vector</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-rotate_inplace">vector:rotate_inplace(phi)</a></td><td>rotate vector in-place</td></tr>
|
2010-08-17 19:49:30 +00:00
|
|
|
<tr><td><a href="#vector.lua-perpendicular">vector:perpendicular()</a></td><td>quick rotation by 90°</td></tr>
|
|
|
|
<tr><td><a href="#vector.lua-projectOn">Vecor:projectOn(v)</a></td><td>projection on other vector</td></tr>
|
2010-09-30 09:55:30 +00:00
|
|
|
<tr><td><a href="#vector.lua-cross">Vecor:cross(v)</a></td><td>cross product of two vectors</td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table></p>
|
|
|
|
|
|
|
|
<a name="vector.lua-vector"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector(x,y)<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Creates a new vector. Element access with <code>v.x</code> and <code>v.y</code>.
|
|
|
|
<table>
|
2010-08-13 12:42:01 +00:00
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[number]</em><code>x</code>:</td><td>x coordinate</td></tr>
|
|
|
|
<tr><td> </td><td class="p"><em>[number]</em><code>y</code>:</td><td>y coordinate</td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
<tr><th>Returns:</th><td colspan="2">the vector</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-isvector"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function isvector(v)<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Tests for vector type.
|
|
|
|
<table>
|
2010-08-13 12:42:01 +00:00
|
|
|
<tr><th>Parameters:</th><td class="p"><code>v</code>:</td><td>variable to test</td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
<tr><th>Returns:</th><td colspan="2"><code>true</code> if <code>v</code> is a vector</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-clone"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:clone()<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Clones a vector. Use when you do not want to create references.
|
|
|
|
<table>
|
|
|
|
<tr><th>Returns:</th><td colspan="2">New vector with the same coordinates.</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-unpack"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:unpack()<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Unpacks the vector.
|
|
|
|
<table>
|
|
|
|
<tr><th>Returns:</th><td colspan="2">the coordinate tuple <code>x, y</code></td></tr>
|
|
|
|
<tr><th colspan="3">Example:</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td colspan="3"><pre><code class="lua">v = vector(1,2)
|
|
|
|
print(v:unpack()) -- prints "1 2"</code></pre></td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-operators"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">Operators<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
<p>Arithmetic (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>) and
|
|
|
|
comparative operators (<code>==</code>, <code><=</code>, <code><</code>) are defined:</p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li><code>+</code> and <code>-</code> <em>only</em> work on vectors. <code>-</code> is also
|
|
|
|
the unary minus (e.g. <code>print(-vector(1,2)) -- prints (-1,-2)</code>)</li>
|
|
|
|
<li><code>a * b</code> works on vectors and numbers:<ul>
|
|
|
|
<li>If <code>a</code> is a number and <code>b</code> is a vector (or vice versa),
|
|
|
|
the result the scalar multiplication.</li>
|
|
|
|
<li>If <code>a</code> and <code>b</code> both are vectors, then the result is the
|
|
|
|
<em>dot product</em>.</li></ul></li>
|
|
|
|
<li><code>a / b</code> is only defined for <code>a</code> being a vector and <code>b</code>
|
|
|
|
being a number. Same as <code>a * 1/b</code>.</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p><code><=</code> and <code><</code> sort lexically, i.e. <code>a < b</code>
|
|
|
|
is true if it holds: <code>a.x < b.x</code> or <code>a.y < b.y</code> if
|
|
|
|
<code>a.x == b.x</code></p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-permul"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:permul(other)<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-17 12:35:29 +00:00
|
|
|
Perform element-wise multiplication, e.g. <code>(2,3) x (3,4) = (6,12)</code>
|
2010-08-13 10:02:47 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-len"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:len()<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Get length of vector.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-len2"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:len2()<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Get squared length.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-dist"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:dist(other)<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Get distance to other vector.
|
|
|
|
|
|
|
|
<table><tr><th>Example:</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td><pre><code class="lua">a,b = vector(0,1), vector(1,0)
|
|
|
|
print(a:dist(b)) -- prints 1.4142135623731</code></pre></td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-normalized"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:normalized()<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Get normalized vector. The original vector remains unchanged.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-normalize_inplace"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:normalize_inplace()<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Normalize vector and return it.
|
|
|
|
<p><strong>Warning:</strong> This will change the state of all references to this vector.</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-rotated"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:rotated(phi)<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Get rotated vector. The original vector remains unchanged.
|
|
|
|
<table>
|
2010-08-13 12:42:01 +00:00
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[number]</em><code>phi</code>:</td><td>Rotation angle in radians.</td></tr>
|
2010-08-17 12:35:29 +00:00
|
|
|
<tr><th>Sketch:</th><td colspan="3"><img src="vector-rotated.png" alt="Rotated vector" /></td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="vector.lua-rotate_inplace"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:rotate_inplace(phi)<a class="top" href="#vector.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Rotate the vector and return it.
|
|
|
|
<p><strong>Warning:</strong> This will change the state of all references to this vector.</p>
|
|
|
|
</div>
|
2010-08-17 12:35:29 +00:00
|
|
|
|
2010-08-17 17:11:21 +00:00
|
|
|
<a name="vector.lua-perpendicular"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:perpendicular()<a href="#vector.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Get vector rotated by 90° clockwise, e.g. the vector <code>(0,1)</code> results in <code>(1,0)</code>.
|
|
|
|
<table>
|
|
|
|
<tr><th>Sketch:</th><td><img src="vector-perpendicular.png" alt="Perpendicular vector" /></td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
2010-08-17 12:35:29 +00:00
|
|
|
|
2010-08-17 17:11:21 +00:00
|
|
|
<a name="vector.lua-projectOn"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:projectOn(v)<a href="#vector.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Project this vector onto another one, e.g. <code>(2,2)</code> projected onto <code>(1,0)</code> results in <code>(2,0)</code>.
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[vector]</em><code>v</code></td><td>Vector to project onto</td></tr>
|
|
|
|
<tr><th>Returns:</th><td colspan="2">Vector with direction of <code>v</code> and length according to projection.</td></tr>
|
|
|
|
<tr><th>Sketch:</th><td colspan="2"><img src="vector-projectOn.png" alt="Projected vector" /></td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
2010-09-30 09:55:30 +00:00
|
|
|
|
|
|
|
<a name="vector.lua-cross"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function vector:cross(v)<a href="#vector.lua" class="top">^ top</a></span>
|
2010-09-30 09:55:30 +00:00
|
|
|
Calculates cross product between two vectors, i.e.:
|
|
|
|
<p>Treats both vectors as vectors of the xy-plane <em>(z-coordinate =0)</em> and calculates a vector perpendicular
|
|
|
|
on them. Because the result is perpendicular on to the input vectors, it has the form <em>(0,0,z)</em>.
|
|
|
|
The z-coordinate is returned.</p>
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[vector]</em><code>v</code></td><td>Vector to calculate the cross product with</td></tr>
|
|
|
|
<tr><th>Returns:</th><td colspan="2">Cross product as described above</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
2010-08-13 10:02:47 +00:00
|
|
|
</div>
|
|
|
|
|
2010-10-17 14:03:13 +00:00
|
|
|
<div class="module"><a name="class.lua"></a>
|
2010-08-13 10:02:47 +00:00
|
|
|
<h3>class.lua<a class="top" href="#doc">^ top</a></h3>
|
2010-09-04 10:29:19 +00:00
|
|
|
<a href="http://github.com/vrld/hump/blob/master/class.lua" class="source">view source</a>
|
2010-08-13 10:02:47 +00:00
|
|
|
<p>class.lua provides a simple and easy to use class system. Albeit it's
|
|
|
|
limitations, class.lua offers multiple inheritance and minimal
|
|
|
|
reflection capabilities. Note that only methods will be inherited
|
|
|
|
and runtime changes of a superclass won't affect subclasses.</p>
|
|
|
|
<p>The module only consists of three functions:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><a href="#class.lua-Class">Class(constructor)</a></td><td>define class</td></tr>
|
|
|
|
<tr><td><a href="#class.lua-Class2">Class{name = name, constructor}</a></td><td>define named class</td></tr>
|
|
|
|
<tr><td><a href="#class.lua-Interface">Interface(name)</a></td><td>define interface</td></tr>
|
|
|
|
<tr><td><a href="#class.lua-Inherit">Inherit(class, super, ...)</a></td><td>subclassing</td></tr>
|
|
|
|
</table></p>
|
|
|
|
<p>For an example, <a href="#class.lua-Example">see below</a>. Also be sure to read the
|
|
|
|
<a href="#class.lua-Warning">warning</a> regarding metamethods.</p>
|
|
|
|
|
|
|
|
<a name="class.lua-Class"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Class(constructor)<a class="top" href="#class.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Creates a new unnamed class.
|
|
|
|
<table>
|
2010-08-13 12:42:01 +00:00
|
|
|
<tr><th>Parameters:</th><td class="p" style="width:225px;"><em>[optional function]</em><code>constructor</code></td>
|
2010-08-13 10:02:47 +00:00
|
|
|
<td>A function used to construct the class. The first parameter of this function
|
|
|
|
is the object, the others are parameters given upon construction.</td></tr>
|
|
|
|
<tr><th>Returns:</th><td colspan="2">the new class</td></tr>
|
|
|
|
<tr><th colspan="3">Example</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td colspan="3"><pre><code class="lua">Feline = Class(function(self, size, weight)
|
|
|
|
self.size = size
|
|
|
|
self.weight = weight
|
2010-08-12 15:43:47 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
function Feline:stats()
|
2010-11-13 15:48:05 +00:00
|
|
|
return string.format("size: %.02f, weight %.02f", self.size, self.weight)
|
2010-08-12 15:43:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
garfield = Feline(.7, 45)
|
|
|
|
felix = Feline(.8, 12)
|
|
|
|
|
2010-11-13 15:48:05 +00:00
|
|
|
print("Garfield: " .. garfield:stats(), "Felix: " .. felix:stats())</code></pre></td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
2010-08-12 15:43:47 +00:00
|
|
|
|
2010-08-13 10:02:47 +00:00
|
|
|
<a name="class.lua-Class2"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Class{name = name, constructor}<a class="top" href="#class.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Create a named class, i.e. define a <code>__tostring</code> metamethod. Parameters are the same as above.
|
|
|
|
Great for debugging. Both <code>name</code> and <code>constructor</code> can be omitted (but why would you want to?)
|
2010-08-12 15:43:47 +00:00
|
|
|
|
2010-08-13 10:02:47 +00:00
|
|
|
<table><tr><th>Example:</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td><pre><code class="lua">Feline = Class{name = "Feline", function(self, size, weight)
|
|
|
|
self.size = size
|
|
|
|
self.weight = weight
|
2010-08-12 15:43:47 +00:00
|
|
|
end}
|
|
|
|
|
2010-11-13 15:48:05 +00:00
|
|
|
print(Feline) -- prints 'Feline'</code></pre></td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="class.lua-Interface"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Interface(name)<a class="top" href="#class.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Shortcut to <code>Class{name = name}</code>, i.e. a possibly named class without constructor.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="class.lua-Inherit"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Inherit(class, super, ...)<a class="top" href="#class.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Add functions of <code>super</code> to <code>class</code>. Multiple interfaces can be defined.
|
|
|
|
<p><code>super</code>'s constructor can be accessed via super.construct(self). See example below.</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="class.lua-Example"></a>
|
|
|
|
<h4>Example usage</h4>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">Everybody loves cats!<a class="top" href="#class.lua">^ top</a></span>
|
|
|
|
<pre><code class="lua">Feline = Class{name = "Feline", function(self, size, weight)
|
|
|
|
self.size = size
|
|
|
|
self.weight = weight
|
2010-08-12 15:43:47 +00:00
|
|
|
end}
|
|
|
|
|
|
|
|
function Feline:stats()
|
2010-11-13 15:48:05 +00:00
|
|
|
return string.format("size: %.02f, weight %.02f", self.size, self.weight)
|
2010-08-12 15:43:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function Feline:speak() print("meow") end
|
|
|
|
|
|
|
|
|
|
|
|
Cat = Class{name = "Cat", function(self, name, size, weight)
|
2010-11-13 15:48:05 +00:00
|
|
|
Feline.construct(self, size, weight)
|
|
|
|
self.name = name
|
2010-08-12 15:43:47 +00:00
|
|
|
end}
|
|
|
|
Inherit(Cat, Feline)
|
|
|
|
|
|
|
|
function Cat:stats()
|
2010-11-13 15:48:05 +00:00
|
|
|
return string.format("name: %s, %s", self.name, Feline.stats(self))
|
2010-08-12 15:43:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
Tiger = Class{name = "tiger", function(self, size, weight)
|
2010-11-13 15:48:05 +00:00
|
|
|
Feline.construct(self, size, weight)
|
2010-08-12 15:43:47 +00:00
|
|
|
end}
|
|
|
|
Inherit(Tiger, Feline)
|
|
|
|
|
|
|
|
function Tiger:speak() print("ROAR!") end
|
|
|
|
|
|
|
|
felix = Cat("Felix", .8, 12)
|
|
|
|
hobbes = Tiger(2.2, 68)
|
|
|
|
|
|
|
|
print(felix:stats(), hobbes:stats())
|
|
|
|
felix:speak()
|
2010-11-13 15:48:05 +00:00
|
|
|
hobbes:speak()</code></pre>
|
2010-08-13 10:02:47 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="class.lua-Warning"></a>
|
|
|
|
<h4>Warning</h4>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">Nothing is perfect<a class="top" href="#class.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
<p>Be careful when using metamethods like <code>__add</code> or <code>__mul</code>:
|
|
|
|
When subclass inherits those methods from a superclass, but does not overwrite
|
|
|
|
them, the result of the operation may be of the type superclass. Consider the following:</p>
|
2010-11-13 15:48:05 +00:00
|
|
|
<pre><code class="lua">A = Class(function(self, x) self.x = x end)
|
2010-08-12 15:43:47 +00:00
|
|
|
function A:__add(other) return A(self.x + other.x) end
|
2010-11-13 15:48:05 +00:00
|
|
|
function A:show() print("A:", self.x) end
|
2010-08-12 15:43:47 +00:00
|
|
|
|
|
|
|
B = Class(function(self, x, y) A.construct(self, x) self.y = y end)
|
|
|
|
Inherit(B, A)
|
2010-11-13 15:48:05 +00:00
|
|
|
function B:show() print("B:", self.x, self.y) end
|
2010-08-12 15:43:47 +00:00
|
|
|
function B:foo() print("foo") end
|
|
|
|
|
|
|
|
one, two = B(1,2), B(3,4)
|
|
|
|
result = one + two
|
2010-11-13 15:48:05 +00:00
|
|
|
result:show() -- prints "A: 4"
|
|
|
|
result:foo() -- error: method does not exist</code></pre>
|
2010-08-13 10:02:47 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2010-10-17 14:03:13 +00:00
|
|
|
<div class="module"><a name="camera.lua"></a>
|
2010-08-13 10:02:47 +00:00
|
|
|
<h3>camera.lua<a class="top" href="#doc">^ top</a></h3>
|
2010-09-04 10:29:19 +00:00
|
|
|
<a href="http://github.com/vrld/hump/blob/master/camera.lua" class="source">view source</a>
|
2010-08-13 10:02:47 +00:00
|
|
|
<em>Depends on <a href="#vector.lua">vector.lua</a></em>
|
|
|
|
<p>Camera object to display only a partial region of the game world. The region
|
2010-10-18 11:02:45 +00:00
|
|
|
can be moved, zoomed and rotated. You can transform camera coordinates to world coordinated
|
2010-08-13 10:02:47 +00:00
|
|
|
(e.g. get the location of the mouse in the game world). It is possible to have
|
|
|
|
more than one camera per game.</p>
|
|
|
|
|
2010-10-16 15:28:13 +00:00
|
|
|
<p>Accessors:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><em>[vector]</em> <code>camera.pos</code></td><td>The camera's position. This is also the position it looks at.</td></tr>
|
|
|
|
<tr><td><em>[number]</em> <code>camera.zoom</code></td><td>The camera's zoom level.</td></tr>
|
|
|
|
<tr><td><em>[number]</em> <code>camera.rot</code></td><td>The camera's rotation.</td></tr>
|
|
|
|
</table>
|
|
|
|
</p>
|
2010-08-13 10:02:47 +00:00
|
|
|
<p>The module defined the following funtions:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><a href="#camera.lua-Camera">Camera(pos, zoom, rotation)</a></td><td>create new camera</td></tr>
|
|
|
|
<tr><td><a href="#camera.lua-rotate">camera:rotate(phi)</a></td><td>rotate camera</td></tr>
|
|
|
|
<tr><td><a href="#camera.lua-translate">camera:translate(t)</a></td><td>move camera</td></tr>
|
|
|
|
<tr><td><a href="#camera.lua-draw">camera:draw(func)</a></td><td>apply camera transformations on function</td></tr>
|
2010-09-15 09:34:18 +00:00
|
|
|
<tr><td><a href="#camera.lua-predraw">camera:predraw()</a></td><td>apply camera transformations</td></tr>
|
|
|
|
<tr><td><a href="#camera.lua-postdraw">camera:postdraw()</a></td><td>revert camera transformations</td></tr>
|
|
|
|
<tr><td><a href="#camera.lua-toCameraCoords">camera:toCameraCoords(p)</a></td><td>get camera coordinates of a point</td></tr>
|
|
|
|
<tr><td><a href="#camera.lua-toWorldCoords">camera:toWorldCoords(p)</a></td><td>get world coordinates of a point</td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
<tr><td><a href="#camera.lua-mousepos">camera:mousepos()</a></td><td>get world coordinates of mouse</td></tr>
|
|
|
|
</table></p>
|
|
|
|
|
|
|
|
<a name="camera.lua-Camera"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function Camera(pos, zoom, rotation)<a class="top" href="#camera.lua">^ top</a></span>
|
2010-08-13 12:42:01 +00:00
|
|
|
Create a new camera with position pos, zoom zoom and rotation rotation.
|
2010-08-13 10:02:47 +00:00
|
|
|
<table>
|
2010-08-13 12:42:01 +00:00
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[optional vector]</em><code>pos</code>:</td>
|
2010-08-13 10:02:47 +00:00
|
|
|
<td>Initial position of the camera. Defaults to <code>(0,0)</code>.</td></tr>
|
2010-08-13 12:42:01 +00:00
|
|
|
<tr><td> </td><td class="p"><em>[optional number]</em><code>zoom</code>:</td>
|
2010-08-13 10:02:47 +00:00
|
|
|
<td>Initial zoom. Defaults to <code>1</code>.</td></tr>
|
2010-08-13 12:42:01 +00:00
|
|
|
<tr><td> </td><td class="p"><em>[optional number]</em><code>rotation</code>:</td>
|
2010-08-13 10:02:47 +00:00
|
|
|
<td>Initial rotation in radians. Defaults to <code>0</code>.</td></tr>
|
2010-08-13 12:42:01 +00:00
|
|
|
<tr><th>Returns:</th><td colspan="2">a new camera object</td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="camera.lua-rotate"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function camera:rotate(phi)<a class="top" href="#camera.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Rotate camera by <code>phi</code> radians. Same as <code>camera.rot = camera.rot + phi.</code>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="camera.lua-translate"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function camera:translate(t)<a class="top" href="#camera.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Translate (move) camera by vector <code>t</code>. Same as <code>camera.pos = camera.pos + t</code>.
|
2010-09-04 10:29:19 +00:00
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[vector]</em><code>t</code>:</td>
|
|
|
|
<td>Translation vector</td></tr>
|
|
|
|
</table>
|
2010-08-13 10:02:47 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="camera.lua-draw"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function camera:draw(func)<a class="top" href="#camera.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Apply camera transformation to drawings in function <code>func</code>.
|
|
|
|
Shortcut to <code>camera:apply()</code> and <code>camera:deapply()</code> (see below).
|
|
|
|
|
|
|
|
<table><tr><th>Example</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td><pre><code class="lua">cam:draw(function() love.graphics.rectangle('fill', -100,-100, 200,200) end)</code></pre></td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
2010-09-15 09:34:18 +00:00
|
|
|
<a name="camera.lua-predraw"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function camera:predraw()<a class="top" href="#camera.lua">^ top</a></span>
|
2010-09-15 09:34:18 +00:00
|
|
|
Apply camera transformations to every drawing operation until the next <code>camera:postdraw()</code>.
|
2010-08-13 10:02:47 +00:00
|
|
|
</div>
|
|
|
|
|
2010-09-15 09:34:18 +00:00
|
|
|
<a name="camera.lua-postdraw"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function camera:postdraw()<a class="top" href="#camera.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Revert camera transformations for the rest of the drawing operations.
|
|
|
|
|
|
|
|
<table><tr><th>Example:</th><td>(equivalent to the <code>cam:draw()</code> example above)</td></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td colspan="2"><pre><code class="lua">camera:predraw()
|
2010-08-13 10:02:47 +00:00
|
|
|
love.graphics.rectangle('fill', -100,-100, 200,200)
|
2010-11-13 15:48:05 +00:00
|
|
|
camera:postdraw()</code></pre></td></tr>
|
2010-08-13 10:02:47 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
2010-09-15 09:34:18 +00:00
|
|
|
<a name="camera.lua-toCameraCoords"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function camera:toCameraCoords(p)<a class="top" href="#camera.lua">^ top</a></span>
|
2010-09-15 09:34:18 +00:00
|
|
|
Transform vector <code>p</code> from world coordinates to camera coordinates, i.e.
|
|
|
|
you have the position of an object in the world and want to know where it will be
|
|
|
|
drawn on the screen.
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[vector]</em><code>p</code>:</td>
|
|
|
|
<td>Vector to transform to camera coordinates</td></tr>
|
|
|
|
<tr><th>Returns:</th><td colspan="2"><em>[vector]</em> transformed vector.</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="camera.lua-toWorldCoords"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function camera:toWorldCoords(p)<a class="top" href="#camera.lua">^ top</a></span>
|
2010-09-15 09:34:18 +00:00
|
|
|
Transform vector <code>p</code> from camera coordinates to world coordinates, i.e.
|
|
|
|
you have the coordinates of a point on the screen (e.g. the mouse), and wan't to
|
|
|
|
know where it's location is in the world.
|
2010-09-04 10:29:19 +00:00
|
|
|
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[vector]</em><code>p</code>:</td>
|
|
|
|
<td>Vector to transform to world coordinates</td></tr>
|
|
|
|
<tr><th>Returns:</th><td colspan="2"><em>[vector]</em> transformed vector.</td></tr>
|
|
|
|
</table>
|
2010-08-13 10:02:47 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="camera.lua-mousepos"></a>
|
2010-11-13 15:48:05 +00:00
|
|
|
<div class="doc"><span class="functiondoc">function camera:mousepos()<a class="top" href="#camera.lua">^ top</a></span>
|
2010-08-13 10:02:47 +00:00
|
|
|
Get mouse position in world coordinates, i.e. the position the users mouse is
|
|
|
|
currently pointing at when camera transformations are applied. Use this for any
|
|
|
|
mouse interaction with transformed objects in your game.
|
2010-09-04 10:29:19 +00:00
|
|
|
<table>
|
|
|
|
<tr><th>Returns:</th><td><em>[vector]</em> Mouse position in world coordinates.</td></tr>
|
|
|
|
</table>
|
2010-08-13 10:02:47 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2010-10-17 14:03:13 +00:00
|
|
|
<div class="module"><a name="ringbuffer.lua"></a>
|
2010-08-17 17:11:21 +00:00
|
|
|
<h3>ringbuffer.lua<a href="#doc" class="top">^ top</a></h3>
|
2010-09-04 10:29:19 +00:00
|
|
|
<a href="http://github.com/vrld/hump/blob/master/ringbuffer.lua" class="source">view source</a>
|
2010-08-17 17:11:21 +00:00
|
|
|
<p>A circular container that can hold arbitrary items. It can be used to create <em>Tomb Raider</em> style
|
|
|
|
inventories, a looping music playlist, recurring dialog sequences and much more.</p>
|
|
|
|
|
2010-10-16 15:28:13 +00:00
|
|
|
<p>Accessors:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><em>[table]</em><code>buffer.items</code></td><td>Items table. It is not recommended to read or write this directly.</td></tr>
|
|
|
|
<tr><td><em>[number]</em><code>buffer.current</code></td><td>Index of current selection. Be careful with this.</td></tr>
|
|
|
|
</table></p>
|
2010-08-17 17:11:21 +00:00
|
|
|
<p>ringbuffer.lua defines the following functions:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><a href="#ringbuffer.lua-Ringbuffer">Ringbuffer(...)</a></td><td>Create new ringbuffer</td></tr>
|
|
|
|
<tr><td><a href="#ringbuffer.lua-insert">ringbuffer:insert(item, ...)</a></td><td>Insert items</td></tr>
|
|
|
|
<tr><td><a href="#ringbuffer.lua-append">ringbuffer:append(item, ...)</a></td><td>Append items to the "end"</td></tr>
|
|
|
|
<tr><td><a href="#ringbuffer.lua-remove">ringbuffer:remove()</a></td><td>Remove item</td></tr>
|
|
|
|
<tr><td><a href="#ringbuffer.lua-removeAt">ringbuffer:removeAt(k)</a></td><td>Remove item at position</td></tr>
|
|
|
|
<tr><td><a href="#ringbuffer.lua-get">ringbuffer:get()</a></td><td>Get item</td></tr>
|
|
|
|
<tr><td><a href="#ringbuffer.lua-size">ringbuffer:size()</a></td><td>Number of items in buffer</td></tr>
|
|
|
|
<tr><td><a href="#ringbuffer.lua-next">ringbuffer:next()</a></td><td>Get next item</td></tr>
|
|
|
|
<tr><td><a href="#ringbuffer.lua-prev">ringbuffer:prev()</a></td><td>Get previous item</td></tr>
|
|
|
|
</table></p>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-Ringbuffer"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function Ringbuffer(...)<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Create a new ringbuffer.
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters</th><td class="p"><em>[optional]</em><code>...</code>:</td><td>Initial items of the buffer.</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-insert"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function ringbuffer:insert(item, ...)<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Insert items behind current item.
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><code>item</code>:</td><td>Item to insert</td></tr>
|
|
|
|
<tr><th></th><td class="p"><em>[optional]</em><code>...</code>:</td><td>Additional items to insert</td></tr>
|
|
|
|
<tr><th colspan="3">Example</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td colspan="3"><pre><code class="lua">rb = Ringbuffer(1,2,5,6) -- rb = {<u>1</u>, 2, 5, 6}
|
|
|
|
rb:next() -- rb = {<u>2</u>, 5, 6, 1}
|
|
|
|
rb:insert(3,4) -- rb = {<u>2</u>, 3, 4, 5, 6, 1}
|
|
|
|
rb:next() -- rb = {<u>3</u>, 4, 5, 6, 1, 2}</code></pre></td></tr>
|
2010-08-17 17:11:21 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-append"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function ringbuffer:append(item, ...)<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Append items to ringbuffer.
|
|
|
|
<p>This is less intuitive than <code>ringbuffer:insert(item, ...)</code> since it appears the items are added
|
2010-11-13 15:48:05 +00:00
|
|
|
at a random location. To understand why this function works how it does, remember that a ringbuffer is basically
|
|
|
|
just a list with a current active element. The active element is <b><u>underlined</u></b> in the example below.</p>
|
|
|
|
<p>Use is only recommended before using <code>ringbuffer:next()</code> or <code>ringbuffer:prev()</code>.</p>
|
2010-08-17 17:11:21 +00:00
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><code>item</code>:</td><td>Item to append</td></tr>
|
|
|
|
<tr><th></th><td class="p"><em>[optional]</em><code>...</code>:</td><td>Additional items to append</td></tr>
|
|
|
|
<tr><th colspan="3">Example</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td colspan="3"><pre><code class="lua">rb = Ringbuffer(1,2,5,6) -- rb = {<b><u>1</u></b>, 2, 5, 6} rb:get() == 1
|
|
|
|
rb:next() -- rb = {1, <b><u>2</u></b>, 5, 6} rb:get() == 2
|
|
|
|
rb:append(3,4) -- rb = {1, <b><u>2</u></b>, 5, 6, 3, 4} rb:get() == 2
|
|
|
|
rb:next() -- rb = {1, 2, <b><u>5</u></b>, 6, 3, 4} rb:get() == 5</code></pre></td></tr>
|
2010-08-17 17:11:21 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-remove"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function ringbuffer:remove()<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Remove currently selected item. The next item will be selected.
|
|
|
|
<table>
|
|
|
|
<tr><th>Example</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td><pre><code class="lua">rb = Ringbuffer(1,2,3) -- rb = {<u>1</u>, 2, 3}
|
|
|
|
rb:next() -- rb = {<u>2</u>, 3, 1}
|
|
|
|
rb:remove() -- rb = {<u>3</u>, 1}</code></pre></td></tr>
|
2010-08-17 17:11:21 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-removeAt"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function ringbuffer:removeAt(k)<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Remove item at relative position <code>k</code>. <code>k</code> may be positive or negative and
|
|
|
|
even bigger than <code>ringbuffer:size()</code>.
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[number]</em><code>k</code></td><td>Relative position of item to remove.</td></tr>
|
|
|
|
<tr><th colspan="3">Example:</th></tr>
|
2010-11-13 15:48:05 +00:00
|
|
|
<tr><td colspan="3"><pre><code class="lua">rb = Ringbuffer(1,2,3,4,5) -- rb = {<u>1</u>, 2, 3, 4, 5}
|
|
|
|
rb:removeAt(2) -- rb = {<u>1</u>, 2, 4, 5}
|
|
|
|
rb:next() -- rb = {<u>2</u>, 4, 5, 1}
|
|
|
|
rb:removeAt(-1) -- rb = {<u>2</u>, 4, 5}</code></pre></td></tr>
|
2010-08-17 17:11:21 +00:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-get"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function ringbuffer:get()<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Get currently selected item.
|
|
|
|
<table> <tr> <th>Returns:</th> <td>The currently selected item.</td> </tr> </table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-size"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function ringbuffer:size()<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
<table> <tr> <th>Returns:</th> <td>Number of items in the buffer.</td> </tr> </table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-next"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function ringbuffer:next()<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Select next item and return it.
|
|
|
|
<table> <tr> <th>Return:</th> <td>Selected item after operation.</td> </tr> </table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="ringbuffer.lua-prev"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function ringbuffer:prev()<a href="#ringbuffer.lua" class="top">^ top</a></span>
|
2010-08-17 17:11:21 +00:00
|
|
|
Select previous item and return it.
|
|
|
|
<table> <tr> <th>Return:</th> <td>Selected item after operation.</td> </tr> </table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2010-10-17 14:03:13 +00:00
|
|
|
<div class="module"><a name="sequence.lua"></a>
|
2010-09-04 10:29:19 +00:00
|
|
|
<h3>sequence.lua<a href="#doc" class="top">^ top</a></h3>
|
|
|
|
<a href="http://github.com/vrld/hump/blob/master/sequence.lua" class="source">view source</a>
|
2010-08-17 19:49:30 +00:00
|
|
|
<em>Depends on <a href="#ringbuffer.lua">ringbuffer.lua</a></em>
|
|
|
|
<p>sequence.lua offers basic support for automated switching of <em>Scenes</em>. You can use it to
|
|
|
|
add intros and cutscenes to your games.</p>
|
|
|
|
<p>sequence.lua defines two types: <code>Scene</code> and <code>Sequence</code>. A <code>Sequence</code>
|
2010-08-17 20:07:04 +00:00
|
|
|
holds several <code>Scene</code>s, but one <code>Scene</code> can belong to different <code>Sequence</code>s
|
|
|
|
(but due to side effects it shouldn't).</p>
|
2010-08-17 19:49:30 +00:00
|
|
|
<p>The module consists of the following:
|
|
|
|
<table class="functionlist">
|
|
|
|
<tr><td><a href="#sequence.lua-Sequence">Sequence(...)</a></td><td>Create new sequence</td></tr>
|
2010-08-17 20:07:04 +00:00
|
|
|
<tr><td><a href="#sequence.lua-add">sequence:add(...)</a></td><td>Add scenes</td></tr>
|
2010-08-17 19:49:30 +00:00
|
|
|
<tr><td><a href="#sequence.lua-select">sequence:select(k)</a></td><td>Select scene manually</td></tr>
|
|
|
|
<tr><td><a href="#sequence.lua-rewind">sequence:rewind()</a></td><td>Rewind sequence</td></tr>
|
|
|
|
<tr><td><a href="#sequence.lua-prevScene">sequence:prevScene</a></td><td>Manually select previous scene</td></tr>
|
|
|
|
<tr><td><a href="#sequence.lua-nextScene">sequence:nextScene</a></td><td>Manually select next scene</td></tr>
|
|
|
|
<tr><td><a href="#sequence.lua-draw">sequence:draw()</a></td><td>Draw current scene</td></tr>
|
|
|
|
<tr><td><a href="#sequence.lua-update">sequence:update(dt)</a></td><td>Update and switch current scene</td></tr>
|
|
|
|
<tr><td><a href="#sequence.lua-Scene">Scene(length)</a></td><td>New scene object</td></tr>
|
|
|
|
<tr><td><a href="#sequence.lua-isFinished">scene:isFinished()</a></td><td>Indicate end of scene</td></tr>
|
|
|
|
</table></p>
|
2010-09-04 10:29:19 +00:00
|
|
|
<p>A <code>Scene</code> defines three callback functions. <em>Do not</em> try to
|
2010-08-17 20:07:04 +00:00
|
|
|
access them yourself. Let <code>Sequence</code> do the job:
|
2010-08-17 19:49:30 +00:00
|
|
|
<table>
|
|
|
|
<tr><td><code>scene:draw()</code>:</td><td>Draw contents on screen <em>(mandatory)</em></td></tr>
|
|
|
|
<tr><td><code>scene:update(dt)</code>:</td><td>Update scene <em>(optional)</em></td></tr>
|
|
|
|
<tr><td><code>scene:enter()</code>:</td><td>Called when entering scene <em>(optional)</em></td></tr>
|
|
|
|
<tr><td><code>scene:leave()</code>:</td><td>Called when leaving scene <em>(optional)</em></td></tr>
|
|
|
|
</table></p>
|
|
|
|
<p>Additional to that, each <code>Scene</code> has a <code>time</code> variable corresponding to the time
|
|
|
|
spent in the scene.</p>
|
|
|
|
<p>The <a href="#sequence.lua-example">example</a> shows some of the concepts involved.</p>
|
|
|
|
|
|
|
|
<a name="sequence.lua-Sequence"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function Sequence(...)<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Create a new sequence with initial scenes.
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[optional Scenes]</em><code>...</code></td>
|
|
|
|
<td>Initial scenes to add to sequence</td></tr>
|
|
|
|
<tr><th>Returns:</th><td colspan="2">Sequence object with initial scenes</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-add"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function sequence:add(...)<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Append scenes to the end of the sequence.
|
|
|
|
<table>
|
|
|
|
<tr><th>Parameters:</th><td class="p"><em>[Scenes]</em><code>...</code></td>
|
|
|
|
<td>Scenes to add to sequence</td></tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-select"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function sequence:select(k)<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Manually selection of scene <code>k</code>. Usually this is not necessary but provided anyway.
|
|
|
|
<table>
|
|
|
|
<tr> <th>Parameters:</th> <td class="p"> <em>[number]</em> <code>k</code>: </td> <td>Number of the scene to select</td> </tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-rewind"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function sequence:rewind()<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Select first scene in sequence.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-prevScene"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function sequence:prevScene()<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Manually select previous scene. Usually not necessay but provided anyway.
|
|
|
|
<p><em>Warning:</em> May select the <em>last</em> scene when the current scene is the first scene in sequence.</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-nextScene"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function sequence:nextScene()<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Manually select next scene. Usually not necessay but provided anyway.
|
|
|
|
<p><em>Warning:</em> May select the <em>first</em> scene when the current scene is the last scene in sequence.</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-draw"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function sequence:draw()<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Draws current scene.
|
|
|
|
<p>Calls <code>scene:draw()</code> on currently active scene</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-update"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function sequence:update(dt)<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Update current scene and increase <code>scene.time</code>.
|
|
|
|
<p>Switches scene if current scene is finished (see <a href="#sequence.lua-isFinished"><code>scene:isFinished()</code></a>).</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-Scene"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">function Scene(length)<a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Create a new scene of length <code>length</code>
|
|
|
|
<table>
|
2010-09-04 10:29:19 +00:00
|
|
|
<tr> <th>Parameters:</th> <td class="p"><em>[optional]</em><code>length</code></td>
|
2010-08-17 19:49:30 +00:00
|
|
|
<td>Length of scene. If <code>< 0</code> scene will never finish. Defaults to <code>-1</code></td> </tr>
|
|
|
|
<tr> <th>Returns:</th> <td colspan="2">New scene object</td> </tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-isFinished"></a>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc"><a href="#sequence.lua" class="top">^ top</a></span>
|
2010-08-17 19:49:30 +00:00
|
|
|
Indicates that the scene is finished. Used by <code>sequence:update(dt)</code>.
|
|
|
|
<p>This can be overwritten, though it is not advised to do so.</p>
|
|
|
|
<table>
|
|
|
|
<tr> <th>Returns:</th> <td><code>true</code> if the scene is finished.</td> </tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a name="sequence.lua-example"></a>
|
|
|
|
<h4>Example usage</h4>
|
|
|
|
<div class="doc">
|
2010-11-13 15:48:05 +00:00
|
|
|
<span class="functiondoc">Ending credits<a href="#sequence.lua" class="top">^ top</a></span>
|
|
|
|
<pre><code class="lua">local sc = {}
|
2010-10-17 14:03:13 +00:00
|
|
|
-- moving and fading looks cool
|
2010-08-17 19:49:30 +00:00
|
|
|
sc.idea = Scene(5)
|
|
|
|
function sc.idea:draw()
|
2010-11-13 15:48:05 +00:00
|
|
|
local frac = (self.time / self.length) ^ 3
|
|
|
|
love.graphics.setColor(255,255,255,160 - frac * 160)
|
|
|
|
love.graphics.print("Idea", 200 + frac * 30, 200)
|
|
|
|
love.graphics.setColor(255,255,255,255 - frac * 255)
|
|
|
|
love.graphics.print("Max Power", 300 - frac * 40, 250)
|
2010-08-17 19:49:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
sc.code = Scene(5)
|
|
|
|
function sc.code:draw()
|
2010-11-13 15:48:05 +00:00
|
|
|
local frac = (self.time / self.length) ^ 3
|
|
|
|
love.graphics.setColor(255,255,255,160 - frac * 160)
|
|
|
|
love.graphics.print("Code", 200 + frac * 30, 200)
|
|
|
|
love.graphics.setColor(255,255,255,255 - frac * 255)
|
|
|
|
love.graphics.print("Max Power", 300 - frac * 40, 250)
|
2010-08-17 19:49:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
sc.gfx = Scene(5)
|
|
|
|
function sc.gfx:draw()
|
2010-11-13 15:48:05 +00:00
|
|
|
local frac = (self.time / self.length) ^ 3
|
|
|
|
love.graphics.setColor(255,255,255,160 - frac * 160)
|
|
|
|
love.graphics.print("GFX", 200 + frac * 30, 200)
|
|
|
|
love.graphics.setColor(255,255,255,255 - frac * 255)
|
|
|
|
love.graphics.print("also Max Power", 300 - frac * 40, 250)
|
2010-08-17 19:49:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
sc.endscreen = Scene(-1) -- last scene. no looping
|
|
|
|
function sc.endscreen:enter()
|
2010-11-13 15:48:05 +00:00
|
|
|
self.frac = 0
|
2010-08-17 19:49:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function sc.endscreen:update(dt)
|
2010-11-13 15:48:05 +00:00
|
|
|
self.frac = math.min(1, self.time / 3) -- 3 sec fade in
|
2010-08-17 19:49:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function sc.endscreen:draw()
|
2010-11-13 15:48:05 +00:00
|
|
|
love.graphics.setColor(255,255,255, self.frac * 255)
|
|
|
|
love.graphics.print("The most awesome game in history", 280, 280)
|
2010-08-17 19:49:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- create credit sequence
|
|
|
|
credits = Sequence(sc.idea, sc.code, sc.gfx)
|
|
|
|
credits:add(sc.endscreen)
|
|
|
|
|
|
|
|
|
|
|
|
-- show and update sequence
|
|
|
|
function love.draw()
|
2010-11-13 15:48:05 +00:00
|
|
|
credits:draw()
|
2010-08-17 19:49:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.update(dt)
|
2010-11-13 15:48:05 +00:00
|
|
|
credits:update(dt)
|
|
|
|
end</code></pre>
|
2010-08-17 19:49:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2010-08-13 10:02:47 +00:00
|
|
|
|
|
|
|
<a name="license"></a>
|
|
|
|
<h2>License<a class="top" href="#top">^ top</a></h2>
|
|
|
|
|
|
|
|
<p>Yay, <em>free software</em>:</p>
|
|
|
|
|
|
|
|
<blockquote><p>Copyright (c) 2010 Matthias Richter</p>
|
|
|
|
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:</p>
|
|
|
|
|
|
|
|
<p>The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.</p>
|
|
|
|
|
|
|
|
<p>Except as contained in this notice, the name(s) of the above copyright holders
|
|
|
|
shall not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
other dealings in this Software without prior written authorization.</p>
|
|
|
|
|
|
|
|
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.</p></blockquote>
|
|
|
|
|
|
|
|
<a name="download"></a>
|
|
|
|
<h2>Download<a class="top" href="#top">^ top</a></h2>
|
|
|
|
|
2010-09-04 10:29:19 +00:00
|
|
|
<p>You can view and download the individual modules on github: <a href="http://github.com/vrld/hump">vrld/hump</a>.
|
|
|
|
You may also download the whole packed sourcecode either in
|
2010-08-13 10:02:47 +00:00
|
|
|
<a href="http://github.com/vrld/hump/zipball/master">zip</a> or
|
|
|
|
<a href="http://github.com/vrld/hump/tarball/master">tar</a> formats.</p>
|
2010-09-04 10:29:19 +00:00
|
|
|
<p>You can clone the project with <a href="http://git-scm.com">Git</a> by running:
|
|
|
|
<pre>git clone git://github.com/vrld/hump</pre>
|
|
|
|
Once done, tou can check for updates by running
|
|
|
|
<pre>git pull</pre></p>
|
2010-08-13 10:02:47 +00:00
|
|
|
|
|
|
|
</div>
|
2010-08-12 13:08:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|