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
91
92
93
94
95
96
97
98
|
local baton = require'libs/baton'
local Object = require'src/object'
local Player = require'src/player'
local count = require'src/count' --count the number of instances
local shake = require'src/screenshake'
local PauseMenu = require'src/menu/pause'
local conf = require'menu_conf'
local Results = Object:extend()
function Results:new()
self.active = false
self.candraw = false
self.character = {"saw-man", "neon", "scarlet", "theophile",
"jean-luc", "brave-scientist"}
self.character_win = {}
self.character_lose = {}
for i = 1, 6, 1 do
local path = 'assets/art/characters/' .. self.character[i] .. '/' ..
self.character[i]
self.character_win[i] = love.graphics.newImage(path..'-win.png')
self.character_lose[i]= love.graphics.newImage(path..'-lose.png')
end
self.input = baton.new(conf.controls[1])
end
function Results:update()
self.input:update()
if not self.active then
self.active = count(Player) < 2
self.timer = love.timer.getTime()
end
if self.active and love.timer.getTime() - self.timer > 1 then
pause = true
for _, v in pairs(entities) do
if v:is(PauseMenu) then
v:destroy()
end
end
for _, v in pairs(entities) do
if v:is(Player) then
self.winner = v.player_id
break
end
end
if not self.candraw then
win_streak[self.winner] = win_streak[self.winner] + 1
shake(5)
end
self.candraw = true
if self.input:pressed'yes' then
already_started = true
pause = false
local Stage = require'src/stage'
stage = Stage'mainmenu'
end
end
end
function Results:draw_gui()
if self.candraw then
love.graphics.setColor(0, 0, 0, 1)
love.graphics.rectangle('fill', 0, 0, gameWidth, gameHeight)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(self.character_win[skins[self.winner + 2]]
, 50, 20)
love.graphics.draw(self.character_lose[skins[
(self.winner == 1 and 2 or 1) + 2]],
40, 90)
love.graphics.setColor(1, 0, 77/255, 1)
love.graphics.printf('-Results-', 0, 4,
gameWidth, 'center')
love.graphics.printf('Press enter or action', 0, 160, gameWidth, 'center')
love.graphics.print('Player ' .. self.winner .. ' wins !', 124, 22)
love.graphics.print('Player ' .. (self.winner == 1 and 2 or 1) ..
' loses !', 114, 92)
love.graphics.print(skins[self.winner], 124, 32)
love.graphics.print(skins[self.winner == 1 and 2 or 1], 114, 102)
love.graphics.print('Wins- ' .. win_streak[self.winner], 124, 42)
love.graphics.print('Wins- ' .. win_streak
[self.winner == 1 and 2 or 1], 114, 112)
love.graphics.print('disk thrown- ' .. stats[self.winner].throw, 124, 52)
love.graphics.print('disk thrown- ' .. stats[self.winner == 1 and 2 or 1].throw, 114, 122)
love.graphics.print('slash precision- ' ..
math.floor(stats[self.winner].slash_success / (stats[self.winner].slash ~= 0
and stats[self.winner].slash or 1) * 100),
124, 62)
love.graphics.print('slash precision- ' ..
math.floor(stats[self.winner == 1 and 2 or 1].slash_success / (stats[self.winner == 1 and 2 or 1].slash~= 0
and stats[self.winner == 1 and 2 or 1].slash or 1) * 100),
114, 132)
love.graphics.print('jumps- ' .. stats[self.winner].jump, 124, 72)
love.graphics.print('jumps- ' .. stats[self.winner == 1 and 2 or 1].jump, 114, 142)
end
end
return Results
|