-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
58 lines (53 loc) · 1.57 KB
/
main.lua
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
local updates = require "updates"
local render = require "render"
local ctrl = require "controllers"
function love.load(arg)
params = {
canShootTimerMax = 0.1,
createEnemyTimerMax = 0.4,
var = {
debug = true,
isAlive = true,
score = 0
}
}
local img = love.graphics.newImage('assets/aircraft.png')
local initial = {
x = (love.graphics.getWidth() / 2) - (img:getWidth() / 2),
y = ((love.graphics.getHeight() / 4) * 3) - (img:getHeight() / 2)
}
objs = {
player = {
initial = initial,
x = initial.x,
y = initial.y,
speed = love.graphics.getWidth() * 0.50,
img = img
},
bullet = {
canShoot = true,
canShootTimer = params.canShootTimerMax,
all = {},
img = love.graphics.newImage('assets/bullet.png')
},
enemy = {
createEnemyTimer = params.createEnemyTimerMax,
all = {},
img = love.graphics.newImage('assets/enemy.png')
}
}
end
function love.update(dt)
ctrl.keyboard(love, dt, params, objs)
ctrl.touch(love, dt, params, objs)
updates.bullet(love, dt, params.canShootTimerMax, objs.bullet)
updates.enemy(love, dt, params.var, params.createEnemyTimerMax,
objs.enemy, objs.player, objs.bullet)
end
function love.draw(dt)
if params.var.isAlive then
render.play(love, params.var, objs.player, objs.enemy, objs.bullet)
else
render.endgame(love)
end
end