| 1 | require 'dokidoki.module' [[ make ]] |
| 2 | |
| 3 | local game = require 'dokidoki.game' |
| 4 | local kernel = require 'dokidoki.kernel' |
| 5 | local v2 = require 'dokidoki.v2' |
| 6 | require 'glfw' |
| 7 | |
| 8 | local blueprints = require 'blueprints' |
| 9 | |
| 10 | local music |
| 11 | |
| 12 | local args = {} |
| 13 | for _, a in ipairs(arg) do |
| 14 | args[a] = true |
| 15 | end |
| 16 | |
| 17 | function make () |
| 18 | return game.make_game( |
| 19 | {'update_setup', 'update', 'collision_registry', 'collision_check', |
| 20 | 'update_cleanup'}, |
| 21 | {'draw_setup', 'draw', 'draw_foreground', 'fade_draw'}, |
| 22 | function (game) |
| 23 | math.randomseed(os.time()) |
| 24 | glfw.SetWindowTitle("Pax Britannica") |
| 25 | |
| 26 | game.init_component('exit_handler') |
| 27 | game.init_component('keyboard') |
| 28 | game.init_component('opengl_2d') |
| 29 | game.opengl_2d.width = 1024 |
| 30 | game.opengl_2d.height = 768 |
| 31 | game.opengl_2d.background_color = {0, 0, 0} |
| 32 | |
| 33 | game.init_component('constants') |
| 34 | game.init_component('collision') |
| 35 | game.init_component('resources') |
| 36 | game.init_component('targeting') |
| 37 | game.init_component('tracing') |
| 38 | game.init_component('log') |
| 39 | game.init_component('fast_forward') |
| 40 | game.init_component('the_one_button') |
| 41 | game.init_component('debug_keys') |
| 42 | |
| 43 | game.exit_handler.trap_esc = true |
| 44 | function game.exit_handler.on_close() |
| 45 | game.log.print_stats() |
| 46 | kernel.abort_main_loop() |
| 47 | end |
| 48 | |
| 49 | local function init() |
| 50 | game.actors.new(blueprints.background) |
| 51 | game.actors.new(blueprints.background_fx) |
| 52 | game.actors.new(blueprints.game_flow) |
| 53 | game.init_component('particles') |
| 54 | end |
| 55 | |
| 56 | if args['--no-music'] or music then |
| 57 | init() |
| 58 | else |
| 59 | game.actors.new(blueprints.music_loader, |
| 60 | {'load_music', filename='audio/music.ogg', callback=function(loaded) |
| 61 | music = loaded |
| 62 | music:play(1, 1, 0) |
| 63 | init() |
| 64 | end}) |
| 65 | end |
| 66 | end) |
| 67 | end |
| 68 | |
| 69 | return get_module_exports() |