Engine 0.0.6
Game engine in lua
Loading...
Searching...
No Matches
main.lua
Go to the documentation of this file.
1local zeebo_module = require('src/lib/engine/module')
2local engine_game = require('src/lib/engine/game')
3local engine_math = require('src/lib/engine/math')
4local engine_color = require('src/lib/object/color')
5local engine_http = require('src/lib/engine/http')
6local engine_encoder = require('src/lib/engine/encoder')
7local engine_draw_fps = require('src/lib/draw/fps')
8local engine_draw_poly = require('src/lib/draw/poly')
9local library_csv = require('src/third_party/csv/rodrigodornelles')
10local game = require('src/lib/object/game')
11local std = require('src/lib/object/std')
12local application = nil
13local extraevents = {
14 loop = function(dt) end,
15 draw = function() end,
16 keydown = function(key, value) end
17}
18
19function native_callback_loop(milis)
20 game.milis = milis
21 application.callbacks.loop(std, game)
22 extraevents.loop(milis)
23 return game.dt
24end
25
26function native_callback_draw()
27 native_draw_start()
28 application.callbacks.draw(std, game)
29 extraevents.draw()
30 native_draw_flush()
31end
32
33function native_callback_resize(width, height)
34 game.width = width
35 game.height = height
36end
37
38function native_callback_keyboard(key, value)
39 std.key.press[key] = value
40 extraevents.keydown(key, value)
41end
42
43function native_callback_init(width, height, game_lua)
45
50 :package('@draw_fps', engine_draw_fps)
51 :package('@draw_poly', engine_draw_poly, native_dict_poly)
53 :package('math', engine_math.clib)
54 :package('random', engine_math.clib_random)
55 :package('http', engine_http, native_dict_http)
56 :package('json', engine_encoder, native_dict_json)
57 :package('xml', engine_encoder, native_dict_xml)
59 :register(function(listener)
60 extraevents.loop = listener('loop')
61 extraevents.draw = listener('draw')
62 extraevents.keydown = listener('keydown')
63 end)
64 :run()
65
66 std.draw.clear=native_draw_clear
67 std.draw.color=native_draw_color
68 std.draw.font=native_draw_font
69 std.draw.text=native_draw_text
70 std.draw.rect=native_draw_rect
71 std.draw.line=native_draw_line
72
73 game.width = width
74 game.height = height
75 game.fps = 60
76 game.dt = 16
77 application.callbacks.init(std, game)
78end
local function require(std, game, application)
local function loadgame(game_file)
safe load game
local function package(self, module_name, module, custom)
local function register(self, register_func)
local json
Definition rxi.lua:2
local function draw(std, game)
local function http(std, game)
local function run(args)
local function init(args)
local library_csv
Definition main.lua:13
local engine_draw_fps
Definition main.lua:11
local application
Definition main.lua:16
local engine_game
Definition main.lua:5
local game
Definition main.lua:17
local std
Definition main.lua:18
local engine_color
Definition main.lua:7
local engine_math
Definition main.lua:4
local engine_draw_poly
Definition main.lua:12
local engine_http
Definition main.lua:6
local zeebo_module
Definition main.lua:1
local engine_encoder
Definition main.lua:2
function love load(args)
local function line(x1, y1, x2, y2)
local function clear(c)
local function color(c)
local function font(name, size)
local function rect(mode, x, y, width, height)
local math
Definition draw.lua:1
local function text(x, y, text)
local function loop(std, game, application, dt)
local function fps(self, show, x, y)