Added ending screen

This commit is contained in:
theo@manjaro 2022-03-04 14:34:54 +01:00
parent d32ef8ef0a
commit e41a42fda4
6 changed files with 30 additions and 1 deletions

BIN
assets/text/win/blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/text/win/pink.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -9,6 +9,7 @@ function Game:reinit()
self.objects.base = require "objects/base"
self.objects.grid = require "objects/grid"
self.objects.circle = require "objects/circle"
self.objects.ending = require "objects/end"
self.rect = require "lib/rect"
self.maxobjects = 0
self.camerax = 0

22
objects/end.lua Normal file
View File

@ -0,0 +1,22 @@
local gen= {}
function gen:new(game,winner)
local End = game.objects.base:new(game,0,0,0,0)
End.sprite = game:newImage("text/win/"..winner..".png")
End:register("End")
function End:step(dt) end
function End:draw()
lg.draw(self.sprite,(self.game.WIDTH-self.sprite:getWidth())/2,(self.game.HEIGHT-self.sprite:getHeight())/2)
end
function End:MouseCallback(x,y)
self.game.scenes:main(game)
end
return End
end
return gen

View File

@ -62,7 +62,7 @@ function gridgen:new(game,x,y,cellsize)
function Grid:endgame(winner)
print(winner.." won !")
self.game.scenes:main(self.game)
self.game.scenes:ending(self.game,winner)
end
function Grid:draw()

View File

@ -9,4 +9,10 @@ function scenes:main(game)
game:summon(grid)
end
function scenes:ending(game,winner)
game.gameloop = {}
local ending = game.objects.ending:new(game,winner)
game:summon(ending)
end
return scenes