townengine/apps/twnlua/data/scripts/game.lua

66 lines
1.5 KiB
Lua
Raw Normal View History

2024-10-07 12:23:04 +00:00
ORIGIN = { x = 320, y = 180 }
RADIUS = 48
offset = { x = 0, y = 0 }
angle = 0
function game_tick()
if ctx.udata == nil then
ctx.udata = {
frame_count = 0,
nest = {
frame_count = 0,
},
arr = { [0] = 0 },
}
end
draw_text {
string = tostring(ctx.udata.frame_count),
position = { x = 0, y = 0 },
font = "/fonts/kenney-pixel.ttf",
}
draw_text {
string = tostring(ctx.udata.nest.frame_count),
position = { x = 0, y = 14 },
font = "/fonts/kenney-pixel.ttf",
}
draw_text {
string = tostring(ctx.udata.arr[0]),
position = { x = 0, y = 28 },
font = "/fonts/kenney-pixel.ttf",
}
2025-01-13 05:57:21 +00:00
input_action {
name = "press",
control = "A"
}
2025-01-13 05:57:21 +00:00
draw_sprite {
texture = "/assets/title.png",
2024-10-07 12:23:04 +00:00
rect = {
x = 320 - (320 / 2),
y = 180 - (128 / 2),
w = 320,
h = 128,
},
}
2025-01-13 05:57:21 +00:00
if input_action_pressed { name = "press" } then
draw_text {
string = "it never happened",
position = offset,
font = "/fonts/kenney-pixel.ttf",
}
end
2024-10-07 12:23:04 +00:00
ctx.udata.frame_count = ctx.udata.frame_count + 1
ctx.udata.nest.frame_count = ctx.udata.nest.frame_count + 1
ctx.udata.arr[0] = ctx.udata.arr[0] + 1
2024-10-07 12:23:04 +00:00
offset.x = ORIGIN.x + (math.cos(angle) * RADIUS)
offset.y = ORIGIN.y + (math.sin(angle) * RADIUS)
angle = angle + 0.1
end