diff --git a/exercise1/exercise1.lua b/exercise1/exercise1.lua index 400aa7a..1b316ac 100644 --- a/exercise1/exercise1.lua +++ b/exercise1/exercise1.lua @@ -13,18 +13,25 @@ end TICK_DELAY = 1 / 25 -local cursor = color_surface(8, 8, 0, 0, 0) +shapes = { } +function init_shapes() + if shapes.img ~= nil then hide_image(shapes.img) end + if shapes.cursor ~= nil then hide_image(shapes.cursor) end + + shapes.cursor = color_surface(8, 8, 0, 0, 0) + shapes.img = fill_surface(VRESW, VRESH, 0xff, 0x77, 0x00) + + show_image(shapes.img) + show_image(shapes.cursor) +end function exercise1() print("Hello World!") warning("Hello Warning!") - - img = fill_surface(VRESW, VRESH, 0xff, 0x77, 0x00) - cursor_setstorage(WORLDID) + init_shapes() - show_image(img) - show_image(cursor) + cursor_setstorage(WORLDID) end @@ -45,6 +52,11 @@ end function exercise1_input_end() x, y = cursor_position() - move_image(cursor, x, y, TICK_DELAY) - warning("" .. x .. ", " .. y) + move_image(shapes.cursor, x, y, TICK_DELAY) + warning("Mouse: " .. x .. ", " .. y) +end + +function exercise1_display_state(action, id, state) + warning("Res: " .. VRESW .. ", " .. VRESH) + init_shapes() end \ No newline at end of file