-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameplay.lua
More file actions
39 lines (33 loc) · 1.23 KB
/
Gameplay.lua
File metadata and controls
39 lines (33 loc) · 1.23 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
local SceneManager = require("SceneManager")
local Transitions = SceneManager.Transitions
local GameplayScene = {
name = "Gameplay",
---@type love.Font
f = nil,
text = "",
---@type love.Image
bg = nil,
transition_in = Transitions.FadeIn.New(),
transition_out = Transitions.FadeOut.New(),
}; GameplayScene.__index = GameplayScene
GameplayScene.Enter = function (self) -- initialization
self.f = love.graphics.newFont(14, "mono"); self.f:setFilter("nearest", "nearest")
self.text = "Press ESC to go back to Main Menu. Press R to reload"
self.text_r = math.rad(0)
self.text_og = self.f:getWidth(self.text)/2
self.bg = love.graphics.newImage("demo/assets/gameplay_bg.jpg")
end
GameplayScene.Update = function (self, dt)
self.text_r = self.text_r - math.rad(5) * dt
if love.keyboard.isDown("escape") then SceneManager.SwitchTo("MainMenu") end
if love.keyboard.isDown("r") then SceneManager.SwitchTo("Gameplay") end
end
GameplayScene.Draw = function (self)
love.graphics.draw(self.bg, 0, 0)
love.graphics.print(self.text, self.f, 200, 100, self.text_r, 1, 1, self.text_og)
end
GameplayScene.Exit = function (self) -- cleanup
self.f:release()
self.bg:release()
end
return GameplayScene