1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Updated example

Now with 85% less eye bleeding. Also moved some dirs so it's more logical.
This commit is contained in:
Reuh 2015-08-20 12:28:33 +02:00
parent 547512c951
commit 036c0a03ce

View file

@ -2,15 +2,34 @@ local gfx = require("ctr.gfx")
local hid = require("ctr.hid") local hid = require("ctr.hid")
local ctr = require("ctr") local ctr = require("ctr")
local x = 0 local x = 50
local y = 0 local y = 50
local d = 4 local dMul = 1
local angle = 0 local angle = 0
gfx.color.setBackground(gfx.color.RGBA8(200, 200, 200)) gfx.color.setBackground(gfx.color.RGBA8(200, 200, 200))
gfx.set3D(true) gfx.set3D(true)
local function drawStuffIn3D(depth)
gfx.text(2, 5, "Depth multiplicator: "..dMul)
-- 3D stuff
local depth = math.floor(depth * dMul)
gfx.color.setDefault(0x00FFFFFF)
gfx.rectangle(240 + depth*5, 150, 120, 10)
gfx.point(10 + depth*3, 20, 0xFF0000FF)
gfx.color.setDefault(0xFF0000FF)
gfx.rectangle(x + depth*math.ceil(5*math.sin(ctr.time()/500)), y, 20, 20, angle)
gfx.line(50 - depth*3, 50, 75 + depth*2, 96, gfx.color.RGBA8(52, 10, 65))
gfx.circle(125 - depth*4, 125, 16)
end
while os.run() do while os.run() do
local keys = hid.keys() local keys = hid.keys()
@ -21,28 +40,18 @@ while os.run() do
if keys.held.up then y = y - 1 end if keys.held.up then y = y - 1 end
if keys.held.down then y = y + 1 end if keys.held.down then y = y + 1 end
if keys.held.cstickUp then d = d + 1 end if keys.held.r then dMul = dMul + 0.05 end
if keys.held.cstickDown then d = d - 1 end if keys.held.l then dMul = dMul - 0.05 end
gfx.startFrame(gfx.GFX_TOP, gfx.GFX_LEFT) gfx.startFrame(gfx.GFX_TOP, gfx.GFX_LEFT)
gfx.color.setDefault(0xFF0000FF)
gfx.rectangle(x, y, 10, 10, angle)
gfx.color.setDefault(0x00FFFFFF) drawStuffIn3D(-1)
gfx.rectangle(240, 150, 120, 10)
gfx.line(50, 50, 75, 96, gfx.color.RGBA8(52, 255, 65))
gfx.point(10, 10, 0xFF0000FF)
gfx.circle(125, 125, 16)
gfx.endFrame() gfx.endFrame()
gfx.startFrame(gfx.GFX_TOP, gfx.GFX_RIGHT) gfx.startFrame(gfx.GFX_TOP, gfx.GFX_RIGHT)
gfx.circle(125+d, 125, 16) drawStuffIn3D(1)
gfx.endFrame() gfx.endFrame()
@ -53,6 +62,10 @@ while os.run() do
gfx.text(5, 20, "Hello world, from Lua !", 20) gfx.text(5, 20, "Hello world, from Lua !", 20)
gfx.text(5, 30, "Time: "..os.date()) gfx.text(5, 30, "Time: "..os.date())
local cx, cy = hid.circle()
gfx.rectangle(40, 90, 60, 60, 0, 0xDDDDDDFF)
gfx.circle(70 + math.ceil(cx/156 * 30), 120 - math.ceil(cy/156 * 30), 10, 0x000000FF)
gfx.endFrame() gfx.endFrame()
angle = angle + 0.05 angle = angle + 0.05