2023-05-14 20:48:25 +00:00
|
|
|
engine_window_init(96,64,"Game")
|
2023-05-15 08:41:14 +00:00
|
|
|
texture = engine_texture_create(8,8)
|
2023-05-14 16:29:55 +00:00
|
|
|
engine_texture_from_file(texture,"assets/textures/fier0.rgba")
|
2023-05-14 10:21:03 +00:00
|
|
|
|
2023-05-14 20:48:25 +00:00
|
|
|
--[[
|
|
|
|
void handleEvent(struct ENGINE_EVENT * event) {
|
|
|
|
if (event->type == ENGINE_EVENT_TYPE_EXIT) {
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]--
|
|
|
|
|
|
|
|
frame = 0
|
|
|
|
frameSec = 0
|
|
|
|
lastSec = 0
|
|
|
|
function tick()
|
|
|
|
frame = frame + 1
|
|
|
|
frameSec = frameSec + 1
|
|
|
|
t = engine_time_get()
|
|
|
|
if t - lastSec >= 1000 then
|
|
|
|
print("FPS: " ..tostring(frameSec))
|
|
|
|
lastSec = t
|
|
|
|
frameSec = 0
|
|
|
|
end
|
|
|
|
engine_window_present()
|
|
|
|
end
|
|
|
|
|
2023-05-15 13:28:58 +00:00
|
|
|
function handleEvent(event,eventData)
|
|
|
|
if eventData[1] == ENGINE_EVENT_TYPE_EXIT then
|
|
|
|
os.exit()
|
|
|
|
end
|
|
|
|
|
|
|
|
if eventData[1] == ENGINE_EVENT_TYPE_INPUT_KB then
|
|
|
|
for _,val in pairs(eventData) do
|
|
|
|
print(tostring(val))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-05-14 20:48:25 +00:00
|
|
|
while true do
|
|
|
|
event = engine_event_get()
|
2023-05-15 13:28:58 +00:00
|
|
|
eventData = {engine_lua_event_get_data(event)}
|
|
|
|
if eventData[1] ~= ENGINE_EVENT_TYPE_NONE then
|
|
|
|
handleEvent(event,eventData)
|
|
|
|
else
|
|
|
|
tick()
|
|
|
|
end
|
|
|
|
|
|
|
|
engine_event_free(event)
|
2023-05-14 16:29:55 +00:00
|
|
|
engine_texture_render_2d(texture,math.random(-8,102),math.random(-8,72))
|
2023-05-14 10:21:03 +00:00
|
|
|
end
|