diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-08-09 02:12:57 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-08-09 02:12:57 +0200 |
| commit | 3ba9a8833623da130102ca6b56e25c2cad3fc739 (patch) | |
| tree | 2bbb11c54f4b0004c141558092f59c53cf54025e /examples/graphics.lua | |
| parent | 4d74dd1cfc45068199639dd04cc4090e86dac8bd (diff) | |
| download | bidi-3ba9a8833623da130102ca6b56e25c2cad3fc739.tar.gz | |
Added button pressed
Diffstat (limited to 'examples/graphics.lua')
| -rw-r--r-- | examples/graphics.lua | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/examples/graphics.lua b/examples/graphics.lua index c6b30a5..6c1f8e4 100644 --- a/examples/graphics.lua +++ b/examples/graphics.lua @@ -1,21 +1,59 @@ +asset1 = load_image("examples/icons/armor_3.png") + open_window(800, 800, "Sample Window") set_fps(60) -while window_running() do - begin_drawing() - clear_window(color.BLACK) - +function test_api() draw_rect(100, 100, 300, 200, color.YELLOW) - draw_text("YOOOOO", 10, 10, 20, color.VIOLET) - - draw_text(string.format("fps: %d", get_fps()), 10, 30, 20, color.VIOLET) - draw_text(string.format("dt: %.3f", get_dt()), 10, 50, 20, color.VIOLET) - + draw_text("Label text", 10, 10, 20, color.VIOLET) draw_line(400, 10, 500, 100, color.RED) draw_circle(500, 500, 100, color.BLUE) draw_ellipse(200, 500, 100, 50, color.BLUE) - draw_triangle(20, 20, 100, 20, 50, 100, color.BLUE) + draw_text(string.format("fps: %d", get_fps()), 10, 30, 20, color.VIOLET) + draw_text(string.format("dt: %.3f", get_dt()), 10, 50, 20, color.VIOLET) +end + +function test_buttons() + if button_pressed(button.PAD_UP) then + draw_text("Pad Up", 10, 10, 20, color.VIOLET) + end + + if button_pressed(button.PAD_DOWN) then + draw_text("Pad Down", 10, 40, 20, color.VIOLET) + end + + if button_pressed(button.PAD_LEFT) then + draw_text("Pad Left", 10, 70, 20, color.VIOLET) + end + + if button_pressed(button.PAD_RIGHT) then + draw_text("Pad Right", 10, 100, 20, color.VIOLET) + end + + if button_pressed(button.A) then + draw_text("A", 150, 10, 20, color.VIOLET) + end + + if button_pressed(button.B) then + draw_text("B", 150, 40, 20, color.VIOLET) + end + + if button_pressed(button.X) then + draw_text("X", 150, 70, 20, color.VIOLET) + end + + if button_pressed(button.Y) then + draw_text("Y", 150, 100, 20, color.VIOLET) + end +end + +while window_running() do + begin_drawing() + clear_window(color.BLACK) + + -- test_api() + test_buttons() draw_info() end_drawing() |
