aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/graphics.lua37
1 files changed, 34 insertions, 3 deletions
diff --git a/tests/graphics.lua b/tests/graphics.lua
index fc531a9..1322101 100644
--- a/tests/graphics.lua
+++ b/tests/graphics.lua
@@ -4,6 +4,9 @@ test_button_square = { x = 400, y = 400 }
4test_button_color = color.RED 4test_button_color = color.RED
5test_button_speed = 200 5test_button_speed = 200
6 6
7test_camera_position = { x = 0, y = 0 }
8test_camera_speed = 200
9
7test_images_asset1 = load_image("tests/icons/icon_1.png") 10test_images_asset1 = load_image("tests/icons/icon_1.png")
8 11
9open_window(800, 800, "Sample Window") 12open_window(800, 800, "Sample Window")
@@ -87,15 +90,43 @@ function test_buttons()
87 draw_rect(test_button_square.x, test_button_square.y, 50, 50, test_button_color) 90 draw_rect(test_button_square.x, test_button_square.y, 50, 50, test_button_color)
88end 91end
89 92
93function test_camera()
94 if button_down(button.PAD_UP) then
95 test_camera_position.y = test_camera_position.y - (test_camera_speed * get_dt())
96 end
97
98 if button_down(button.PAD_DOWN) then
99 test_camera_position.y = test_camera_position.y + (test_camera_speed * get_dt())
100 end
101
102 if button_down(button.PAD_LEFT) then
103 test_camera_position.x = test_camera_position.x - (test_camera_speed * get_dt())
104 end
105
106 if button_down(button.PAD_RIGHT) then
107 test_camera_position.x = test_camera_position.x + (test_camera_speed * get_dt())
108 end
109
110 -- Using camera
111 move_camera(test_camera_position.x, test_camera_position.y)
112
113 start_camera()
114 draw_rect(0, 0, 300, 200, color.YELLOW)
115 stop_camera()
116
117 draw_text("This text doesn't move!", 10, 10, 20, color.VIOLET)
118end
119
90while window_running() do 120while window_running() do
91 begin_drawing() 121 start_drawing()
92 clear_window(color.BLACK) 122 clear_window(color.BLACK)
93 123
94 -- test_api() 124 -- test_api()
95 test_buttons() 125 -- test_buttons()
126 -- test_camera()
96 127
97 draw_info() 128 draw_info()
98 end_drawing() 129 stop_drawing()
99end 130end
100 131
101close_window() 132close_window()