Skip to content

Commit

Permalink
deploy: b02235a
Browse files Browse the repository at this point in the history
  • Loading branch information
dwursteisen committed Mar 18, 2024
1 parent 007827a commit 0c9ee00
Show file tree
Hide file tree
Showing 15 changed files with 324 additions and 85 deletions.
5 changes: 4 additions & 1 deletion _engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ function popup(logo, text, color, keep)
end

function printDebug(index, text, color)
local prev = gfx.camera()
shape.rectf(0, index * 6, #text * 6 + 6, 6, color)
print(text, 6, index * 6 + 1, "#FFFFFF")
gfx.camera(prev.x, prev.y)
end

function clear()
Expand All @@ -40,8 +42,9 @@ end

function _draw()
if forever or dt > 0 then
local prev = gfx.camera()
shape.rectf(0, 0, width, 6 * msg.lines, msg.color)
-- TODO: display the logo
print(msg.text, 6, 1, "#FFFFFF")
gfx.camera(prev.x, prev.y)
end
end
173 changes: 142 additions & 31 deletions dependencies/tiny-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,17 @@ <h4 id="_ctrl_pressing">ctrl.pressing()</h4>
</tiny-editor>
</div>
<div class="sect3">
<h4 id="_ctrl_touched">ctrl.touched()</h4>
<h4 id="_ctrl_2">ctrl.</h4>
<div class="paragraph">
<p>function _draw()
local pos = ctrl.touched(0)
if pos ~= nil then
shape.circlef(pos.x, pos.y, 4, 9)
print("("..pos.x .. ", "..pos.y..")", pos.x + 3, pos.y + 3)
end
end
()</p>
</div>
<div class="paragraph">
<p>Return the position of the touch (as <code>{x, y}</code>)if the screen was touched or the mouse button was pressed during the last frame. <code>nil</code> otherwise.
The touch can be :</p>
Expand All @@ -556,7 +566,15 @@ <h4 id="_ctrl_touched">ctrl.touched()</h4>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-lua" data-lang="lua">ctrl.touched(touch) -- Is the screen was touched or mouse button was pressed?</code></pre>
<pre class="highlight"><code class="language-lua" data-lang="lua">ctrl.
function _draw()
local pos = ctrl.touched(0)
if pos ~= nil then
shape.circlef(pos.x, pos.y, 4, 9)
print("("..pos.x .. ", "..pos.y..")", pos.x + 3, pos.y + 3)
end
end
(touch) -- Is the screen was touched or mouse button was pressed?</code></pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -586,35 +604,15 @@ <h4 id="_ctrl_touching">ctrl.touching()</h4>
</div>
<tiny-editor style="display: none;" >

function _init()
t = {}
end

function _update()
local touch = ctrl.touching(0)
if(touch) then
table.insert(t, {str = " touching "..touch.x.."-"..touch.y, ttl = 3})
end

for i,s in rpairs(t) do
s.ttl = s.ttl - 1/60
if s.ttl < 0 then
table.remove(t, i)
end
end
end

function _draw()
gfx.cls()

local p = 0
for i, s in rpairs(t) do
print(i..s.str, 10, 6 * p, 2)
p = p + 1
local start = ctrl.touching(0)
if start ~= nil then
local pos = ctrl.touch()
shape.line(start.x, start.y, pos.x, pos.y, 9)
print("("..start.x .. ", "..start.y..")", start.x, start.y)
print("("..pos.x .. ", "..pos.y..")", pos.x, pos.y)
end

local touch = ctrl.touch()
shape.circlef(touch.x, touch.y, 2, 8)
end

</tiny-editor>
Expand Down Expand Up @@ -3461,14 +3459,44 @@ <h4 id="_spr_pset">spr.pset()</h4>
<div class="sect3">
<h4 id="_spr_sheet">spr.sheet()</h4>
<div class="paragraph">
<p>Switch to another spritesheet. The index of the spritesheet is given by it&#8217;s position in the spritesheets field from the <code>_tiny.json</code> file.The first spritesheet is at the index 0. It retuns the previous spritesheet.</p>
<p>Switch to another spritesheet. The index of the spritesheet is given by it&#8217;s position in the spritesheets field from the <code>_tiny.json</code> file.The first spritesheet is at the index 0. It retuns the previous spritesheet. The spritesheet can also be referenced by its filename.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-lua" data-lang="lua">spr.sheet() -- Switch to the first spritesheet
spr.sheet(spritesheetN) -- Switch to the N spritesheet</code></pre>
</div>
</div>
<tiny-editor style="display: none;" >

local current = 0
function _update()
local x = math.perlin((tiny.frame % 100) / 100, (tiny.frame % 100) / 100, (tiny.frame % 100) / 100)
local y = math.perlin((tiny.frame * 0.5 % 100) / 100, (tiny.frame % 100) / 100, (tiny.frame * 0.5 % 100) / 100)

gfx.cls()
shape.circlef(x * 256, y * 256, 10, 8)
gfx.to_sheet("circle.png")

gfx.cls()
shape.rectf(x * 256, y * 256, 20, 20, 8)
gfx.to_sheet("rect.png")

if ctrl.pressed(keys.space) then
current = (current + 1) % 2
end
end

function _draw()
if current == 0 then
spr.sheet("circle.png")
else
spr.sheet("rect.png")
end
spr.sdraw()
end

</tiny-editor>
</div>
<div class="sect3">
<h4 id="_spr_sdraw">spr.sdraw()</h4>
Expand Down Expand Up @@ -3750,6 +3778,89 @@ <h4 id="_print">print()</h4>
</div>
</div>
<div class="sect2">
<h3 id="_test">test</h3>
<div class="paragraph">
<p>Test method utilities used when tests are run. See <a href="#_the_tiny_cli_run_command">Run command</a></p>
</div>
<div class="sect3">
<h4 id="_test_eq">test.eq()</h4>
<div class="paragraph">
<p>Assert that <code>expected</code> and <code>actual</code> are equals</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-lua" data-lang="lua">test.eq(expected, actual) -- Assert that `expected` and `actual` are equals</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_test_neq">test.neq()</h4>
<div class="paragraph">
<p>Assert that <code>expected</code> and <code>actual</code> are <em>not</em> equals</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-lua" data-lang="lua">test.neq(expected, actual) -- Assert that `expected` and `actual` are not equals</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_test_t">test.t()</h4>
<div class="paragraph">
<p>Assert that <code>actual</code> is true</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-lua" data-lang="lua">test.t(actual) -- Assert that `actual` is true</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_test_t_2">test.t()</h4>
<div class="paragraph">
<p>Assert that <code>actual</code> is false</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-lua" data-lang="lua">test.t(actual) -- Assert that `actual` is false</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_test_create">test.create()</h4>
<div class="paragraph">
<p>Create a new <code>test</code> named <code>name</code></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-lua" data-lang="lua">test.create(name, test) -- Create a new `test` named `name`</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Argument name</th>
<th class="tableblock halign-left valign-top">Argument description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The name of the test</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">test</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The test: it has to be a function</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect2">
<h3 id="_tiny">tiny</h3>
<div class="paragraph">
<p>Tiny Lib which offer offer the current frame (<code>tiny.frame</code>), the current time (<code>tiny.time</code>), delta time (<code>tiny.dt</code>) and to switch to another script using <code>exit</code>.</p>
Expand Down Expand Up @@ -4215,8 +4326,8 @@ <h4 id="_ws_list">ws.list()</h4>
</div>
<div id="footer">
<div id="footer-text">
Version 1.2.2<br>
Last updated 2024-02-18 11:10:33 UTC
Version 1.3.0<br>
Last updated 2024-03-18 22:45:30 UTC
</div>
</div>
</body>
Expand Down
Loading

0 comments on commit 0c9ee00

Please sign in to comment.