diff --git a/sdcard/ctruLua/main.lua b/sdcard/ctruLua/main.lua index 4918e1e..fe7fe98 100644 --- a/sdcard/ctruLua/main.lua +++ b/sdcard/ctruLua/main.lua @@ -1,12 +1,15 @@ local gfx = require("ctr.gfx") local hid = require("ctr.hid") +local ctr = require("ctr") local x = 0 local y = 0 +local d = 4 local angle = 0 gfx.color.setBackground(gfx.color.RGBA8(200, 200, 200)) +gfx.set3D(true) while os.run() do local keys = hid.keys() @@ -17,8 +20,11 @@ while os.run() do if keys.held.left then x = x - 1 end if keys.held.up 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.cstickDown then d = d - 1 end - gfx.startFrame(gfx.GFX_TOP) + gfx.startFrame(gfx.GFX_TOP, gfx.GFX_LEFT) gfx.color.setDefault(0xFF0000FF) gfx.rectangle(x, y, 10, 10, angle) @@ -33,12 +39,19 @@ while os.run() do gfx.circle(125, 125, 16) gfx.endFrame() - + + gfx.startFrame(gfx.GFX_TOP, gfx.GFX_RIGHT) + + gfx.circle(125+d, 125, 16) + + gfx.endFrame() + gfx.startFrame(gfx.GFX_BOTTOM) gfx.color.setDefault(0, 0, 0) gfx.text(5, 7, "FPS: "..math.ceil(gfx.getFPS())) gfx.text(5, 20, "Hello world, from Lua !", 20) + gfx.text(5, 30, "Time: "..os.date()) gfx.endFrame() diff --git a/source/gfx.c b/source/gfx.c index 363bda9..f47e205 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -39,6 +39,16 @@ static int gfx_getFPS(lua_State *L) { return 1; } +static int gfx_set3D(lua_State *L) { + bool enable = false; + if (lua_isboolean(L, 1)) + enable = lua_toboolean(L, 1); + + gfxSet3D(enable); + + return 1; +} + static int gfx_line(lua_State *L) { int x1 = luaL_checkinteger(L, 1); int y1 = luaL_checkinteger(L, 2); @@ -112,6 +122,7 @@ static const struct luaL_Reg gfx_lib[] = { { "endFrame", gfx_endFrame }, { "render", gfx_render }, { "getFPS", gfx_getFPS }, + { "set3D", gfx_set3D }, { "line", gfx_line }, { "point", gfx_point }, { "rectangle", gfx_rectangle },