diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test.lua | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/test.lua b/tests/test.lua index f85b644..372b221 100644 --- a/tests/test.lua +++ b/tests/test.lua | |||
| @@ -1,16 +1,15 @@ | |||
| 1 | math.randomseed(os.time()) | 1 | math.randomseed(os.time()) |
| 2 | 2 | ||
| 3 | open_window(800, 800, "Sample Window") | ||
| 4 | set_fps(60) | ||
| 5 | |||
| 3 | test_button_square = { x = 400, y = 400 } | 6 | test_button_square = { x = 400, y = 400 } |
| 4 | test_button_color = color.RED | 7 | test_button_color = color.RED |
| 5 | test_button_speed = 200 | 8 | test_button_speed = 200 |
| 6 | |||
| 7 | test_camera_position = { x = 0, y = 0 } | 9 | test_camera_position = { x = 0, y = 0 } |
| 8 | test_camera_speed = 200 | 10 | test_camera_speed = 200 |
| 9 | |||
| 10 | test_images_asset1 = load_image("tests/icons/icon_1.png") | 11 | test_images_asset1 = load_image("tests/icons/icon_1.png") |
| 11 | 12 | test_images_asset2 = load_image("tests/icons/icon_2.png") | |
| 12 | open_window(800, 800, "Sample Window") | ||
| 13 | set_fps(60) | ||
| 14 | 13 | ||
| 15 | function test_api() | 14 | function test_api() |
| 16 | draw_rect(100, 100, 300, 200, color.YELLOW) | 15 | draw_rect(100, 100, 300, 200, color.YELLOW) |
| @@ -26,10 +25,10 @@ end | |||
| 26 | function get_random_color() | 25 | function get_random_color() |
| 27 | local keys = {} | 26 | local keys = {} |
| 28 | for k in pairs(color) do | 27 | for k in pairs(color) do |
| 29 | table.insert(keys, k) -- Collect all keys | 28 | table.insert(keys, k) |
| 30 | end | 29 | end |
| 31 | local randomKey = keys[math.random(1, #keys)] -- Select a random key | 30 | local randomKey = keys[math.random(1, #keys)] |
| 32 | return color[randomKey] -- Return the corresponding color | 31 | return color[randomKey] |
| 33 | end | 32 | end |
| 34 | 33 | ||
| 35 | function test_json() | 34 | function test_json() |
| @@ -140,6 +139,14 @@ function test_camera() | |||
| 140 | draw_text("This text doesn't move!", 10, 10, 20, color.VIOLET) | 139 | draw_text("This text doesn't move!", 10, 10, 20, color.VIOLET) |
| 141 | end | 140 | end |
| 142 | 141 | ||
| 142 | function test_images() | ||
| 143 | draw_text(string.format("uid: %s", test_images_asset1), 50, 50, 20, color.VIOLET) | ||
| 144 | draw_text(string.format("uid: %s", test_images_asset2), 50, 80, 20, color.VIOLET) | ||
| 145 | |||
| 146 | draw_image(test_images_asset1, 150, 150) | ||
| 147 | draw_image(test_images_asset2, 200, 200) | ||
| 148 | end | ||
| 149 | |||
| 143 | while window_running() do | 150 | while window_running() do |
| 144 | start_drawing() | 151 | start_drawing() |
| 145 | clear_window(color.BLACK) | 152 | clear_window(color.BLACK) |
| @@ -148,6 +155,7 @@ while window_running() do | |||
| 148 | -- test_api() | 155 | -- test_api() |
| 149 | -- test_buttons() | 156 | -- test_buttons() |
| 150 | -- test_camera() | 157 | -- test_camera() |
| 158 | -- test_images() | ||
| 151 | 159 | ||
| 152 | draw_info() | 160 | draw_info() |
| 153 | stop_drawing() | 161 | stop_drawing() |
