-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtitleScreen.lua
More file actions
86 lines (72 loc) · 2.42 KB
/
titleScreen.lua
File metadata and controls
86 lines (72 loc) · 2.42 KB
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
TitleScreen = {}
local Baton = require "vendor.baton.baton"
require "ecs.entity"
require "components.render.spriteRender"
local input = Baton.new
{
controls = {
start = {'key:x', 'button:a'},
exit = {'key:escape'},
},
joystick = love.joystick.getJoysticks()[1]
}
function TitleScreen:new(obj)
local ts = obj or {}
setmetatable(ts, self)
self.__index = self
ts.image = love.graphics.newImage("assets/magna_cover.png")
ts.render = SpriteRender:new("assets/sprites/evil_crystal.json", "assets/sprites/evil_crystal.png", "spin_full_hp")
ts.entity = Entity:new("", Vector(10, 40), {ts.render})
self.spriteCycleCurrent = 0
self.spriteCycle = 1
self.spriteCycleTime = 3
return ts
end
function TitleScreen:update(dt)
input:update(dt)
self.entity:update(dt)
if input:pressed "start" then
CurrentGame = MainGame
end
if input:pressed "exit" then
love.event.quit()
end
self.spriteCycleCurrent = self.spriteCycleCurrent + dt
if self.spriteCycleCurrent > self.spriteCycleTime then
self.spriteCycleCurrent = 0
self.spriteCycle = self.spriteCycle + 1
if self.spriteCycle > 3 then self.spriteCycle = 1 end
if self.spriteCycle == 3 then
self.render:setTag("spin_critical")
elseif self.spriteCycle == 2 then
self.render:setTag("spin_damaged")
elseif self.spriteCycle == 1 then
self.render:setTag("spin_full_hp")
end
end
end
function TitleScreen:draw()
love.graphics.push()
love.graphics.translate(love.graphics.getWidth()/2, love.graphics.getHeight()/2)
love.graphics.translate(-self.image:getWidth() / 2, -self.image:getHeight() /2)
love.graphics.draw(self.image)
love.graphics.pop()
love.graphics.push()
love.graphics.translate(love.graphics.getWidth()/2, 500)
love.graphics.setColor(0, 0, 0, .33)
love.graphics.rectangle("fill", -75, -5, 160, 70, 3, 3)
love.graphics.setColor(1,1,1,1)
love.graphics.print("Press action (X) to begin", -70)
love.graphics.print("Arrow keys to move", -55, 15)
love.graphics.print("Press M to toggle mute", -65, 30)
love.graphics.print("Press Escape to quit", -60, 45)
love.graphics.pop()
love.graphics.push()
love.graphics.translate(550, 480)
love.graphics.setColor(0, 0, 0, .33)
love.graphics.rectangle("fill", 0, 0, 205, 80, 3, 3)
love.graphics.setColor(1,1,1,1)
self.entity:draw()
love.graphics.print("Destroy these crystals with\nyour earthquake! Be careful\nnot to hit the green ones\nthough - if they're destroyed,\nit's game over!", 25, 3)
love.graphics.pop()
end