diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/graphics.lua | 37 |
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 } | |||
| 4 | test_button_color = color.RED | 4 | test_button_color = color.RED |
| 5 | test_button_speed = 200 | 5 | test_button_speed = 200 |
| 6 | 6 | ||
| 7 | test_camera_position = { x = 0, y = 0 } | ||
| 8 | test_camera_speed = 200 | ||
| 9 | |||
| 7 | test_images_asset1 = load_image("tests/icons/icon_1.png") | 10 | test_images_asset1 = load_image("tests/icons/icon_1.png") |
| 8 | 11 | ||
| 9 | open_window(800, 800, "Sample Window") | 12 | open_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) |
| 88 | end | 91 | end |
| 89 | 92 | ||
| 93 | function 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) | ||
| 118 | end | ||
| 119 | |||
| 90 | while window_running() do | 120 | while 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() |
| 99 | end | 130 | end |
| 100 | 131 | ||
| 101 | close_window() | 132 | close_window() |
