aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/graphics.lua58
-rw-r--r--examples/icons/icon_1.pngbin0 -> 352069 bytes
-rw-r--r--examples/icons/icon_2.pngbin0 -> 455412 bytes
3 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 @@
1asset1 = load_image("examples/icons/armor_3.png")
2
1open_window(800, 800, "Sample Window") 3open_window(800, 800, "Sample Window")
2set_fps(60) 4set_fps(60)
3 5
4while window_running() do 6function test_api()
5 begin_drawing()
6 clear_window(color.BLACK)
7
8 draw_rect(100, 100, 300, 200, color.YELLOW) 7 draw_rect(100, 100, 300, 200, color.YELLOW)
9 draw_text("YOOOOO", 10, 10, 20, color.VIOLET) 8 draw_text("Label text", 10, 10, 20, color.VIOLET)
10
11 draw_text(string.format("fps: %d", get_fps()), 10, 30, 20, color.VIOLET)
12 draw_text(string.format("dt: %.3f", get_dt()), 10, 50, 20, color.VIOLET)
13
14 draw_line(400, 10, 500, 100, color.RED) 9 draw_line(400, 10, 500, 100, color.RED)
15 draw_circle(500, 500, 100, color.BLUE) 10 draw_circle(500, 500, 100, color.BLUE)
16 draw_ellipse(200, 500, 100, 50, color.BLUE) 11 draw_ellipse(200, 500, 100, 50, color.BLUE)
17
18 draw_triangle(20, 20, 100, 20, 50, 100, color.BLUE) 12 draw_triangle(20, 20, 100, 20, 50, 100, color.BLUE)
13 draw_text(string.format("fps: %d", get_fps()), 10, 30, 20, color.VIOLET)
14 draw_text(string.format("dt: %.3f", get_dt()), 10, 50, 20, color.VIOLET)
15end
16
17function test_buttons()
18 if button_pressed(button.PAD_UP) then
19 draw_text("Pad Up", 10, 10, 20, color.VIOLET)
20 end
21
22 if button_pressed(button.PAD_DOWN) then
23 draw_text("Pad Down", 10, 40, 20, color.VIOLET)
24 end
25
26 if button_pressed(button.PAD_LEFT) then
27 draw_text("Pad Left", 10, 70, 20, color.VIOLET)
28 end
29
30 if button_pressed(button.PAD_RIGHT) then
31 draw_text("Pad Right", 10, 100, 20, color.VIOLET)
32 end
33
34 if button_pressed(button.A) then
35 draw_text("A", 150, 10, 20, color.VIOLET)
36 end
37
38 if button_pressed(button.B) then
39 draw_text("B", 150, 40, 20, color.VIOLET)
40 end
41
42 if button_pressed(button.X) then
43 draw_text("X", 150, 70, 20, color.VIOLET)
44 end
45
46 if button_pressed(button.Y) then
47 draw_text("Y", 150, 100, 20, color.VIOLET)
48 end
49end
50
51while window_running() do
52 begin_drawing()
53 clear_window(color.BLACK)
54
55 -- test_api()
56 test_buttons()
19 57
20 draw_info() 58 draw_info()
21 end_drawing() 59 end_drawing()
diff --git a/examples/icons/icon_1.png b/examples/icons/icon_1.png
new file mode 100644
index 0000000..4785224
--- /dev/null
+++ b/examples/icons/icon_1.png
Binary files differ
diff --git a/examples/icons/icon_2.png b/examples/icons/icon_2.png
new file mode 100644
index 0000000..c19d642
--- /dev/null
+++ b/examples/icons/icon_2.png
Binary files differ