aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test.lua24
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 @@
1math.randomseed(os.time()) 1math.randomseed(os.time())
2 2
3open_window(800, 800, "Sample Window")
4set_fps(60)
5
3test_button_square = { x = 400, y = 400 } 6test_button_square = { x = 400, y = 400 }
4test_button_color = color.RED 7test_button_color = color.RED
5test_button_speed = 200 8test_button_speed = 200
6
7test_camera_position = { x = 0, y = 0 } 9test_camera_position = { x = 0, y = 0 }
8test_camera_speed = 200 10test_camera_speed = 200
9
10test_images_asset1 = load_image("tests/icons/icon_1.png") 11test_images_asset1 = load_image("tests/icons/icon_1.png")
11 12test_images_asset2 = load_image("tests/icons/icon_2.png")
12open_window(800, 800, "Sample Window")
13set_fps(60)
14 13
15function test_api() 14function 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
26function get_random_color() 25function 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]
33end 32end
34 33
35function test_json() 34function 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)
141end 140end
142 141
142function 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)
148end
149
143while window_running() do 150while 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()