1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-- global configurations
config = {
debug = false,
lang = "zh",
lootSize = 5,
heartSize = 15,
frameRate = 10,
graphics = {
doorSize = 50,
doorThickness = 5,
roomW = 0.85,
roomH = 0.8,
},
defaultRoomW = 0.85,
defaultRoomH = 0.8,
summonMargin = 30,
bullet = {
speed = 300,
size = 15,
},
player = {
size = 20,
speed = 100,
shieldTime = 3,
shoot = {
cooldown = 0.2,
},
punch = {
radius = 25,
angle = 120,
force = 200,
damage = 10,
damageCoefficient = 10,
cooldown = 0.5
},
knockback = {
force = 200,
duration = 0.2
},
},
wave = {
mobSummonDelay = 1,
},
map = {
initialRoomCount = 7,
extendedRoomCount = 5,
initialHeartCount = {
min = 2, max = 4
},
},
defaultMusic = "briskFight"
}
-- game default states
function initGame()
-- initialize random seed
math.randomseed(os.time())
-- lazy load dependencies
local Player = require "objects.player"
local mapGen = require "logic.MapGenerator"
local bodyLifeCycleManager = require "utils.bodyLifecycleManager"
local audio = require "utils.audio"
local physics = require "logic.physics"
-- initialize game state
G = {
time = 0,
lastSummonTime = 0,
roomCleared = 0,
}
-- initialize other components
audio.stopMusic()
speaker.init()
physics.init(G)
bodyLifeCycleManager.init(G)
Player.init(G)
mapGen.init(G)
end
|