Transition effect
This commit is contained in:
parent
6d35f1a9d3
commit
683eb16833
10
game.lua
10
game.lua
@ -11,6 +11,7 @@ function Game:reinit()
|
|||||||
self.objects.circle = require "objects/circle"
|
self.objects.circle = require "objects/circle"
|
||||||
self.objects.ending = require "objects/end"
|
self.objects.ending = require "objects/end"
|
||||||
self.objects.background = require "objects/background"
|
self.objects.background = require "objects/background"
|
||||||
|
self.objects.transition= require "objects/transition"
|
||||||
self.rect = require "lib/rect"
|
self.rect = require "lib/rect"
|
||||||
self.maxobjects = 0
|
self.maxobjects = 0
|
||||||
self.camerax = 0
|
self.camerax = 0
|
||||||
@ -228,6 +229,15 @@ function Game:MouseCallback(x,y,presses)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Game:delid(id)
|
||||||
|
local i
|
||||||
|
for i=0,#self.gameloop do
|
||||||
|
if self.gameloop[i]~=nil then
|
||||||
|
if self.gameloop[i].id==id then self.gameloop[i]=nil end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Game:bint(bool) -- Convert Boolean to Integer
|
function Game:bint(bool) -- Convert Boolean to Integer
|
||||||
local result = 0
|
local result = 0
|
||||||
if bool then result = 1 end
|
if bool then result = 1 end
|
||||||
|
@ -13,7 +13,8 @@ function gen:new(game,winner)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function End:MouseCallback(x,y)
|
function End:MouseCallback(x,y)
|
||||||
self.game.scenes:main(game)
|
local t = self.game.objects.transition:new(game,0.7,"main")
|
||||||
|
self.game:summon(t)
|
||||||
end
|
end
|
||||||
|
|
||||||
return End
|
return End
|
||||||
|
@ -61,8 +61,10 @@ function gridgen:new(game,x,y,cellsize)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Grid:endgame(winner)
|
function Grid:endgame(winner)
|
||||||
print(winner.." won !")
|
local args = {}
|
||||||
self.game.scenes:ending(self.game,winner)
|
args.winner = winner
|
||||||
|
local t = self.game.objects.transition:new(game,0.7,"ending",args)
|
||||||
|
self.game:summon(t)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Grid:draw()
|
function Grid:draw()
|
||||||
|
38
objects/transition.lua
Normal file
38
objects/transition.lua
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
local gen = {}
|
||||||
|
|
||||||
|
function gen:new(game,time,func,args)
|
||||||
|
|
||||||
|
local Transition = game.objects.base:new(game,0,0)
|
||||||
|
|
||||||
|
Transition.color = {0.161,0.157,0.192,1}
|
||||||
|
Transition.func = func
|
||||||
|
Transition.args = args
|
||||||
|
|
||||||
|
Transition.timer = game:Timer(time or 0.7)
|
||||||
|
|
||||||
|
Transition.depth = 99
|
||||||
|
|
||||||
|
function Transition:step(dt)
|
||||||
|
if self.timer:tick(dt) then
|
||||||
|
if self.func then
|
||||||
|
self.game.scenes[func](self.game.scenes,self.game,self.args)
|
||||||
|
local t = self.game.objects.transition:new(self.game,self.timer.maxcount)
|
||||||
|
self.game:summon(t)
|
||||||
|
end
|
||||||
|
self.game:delid(self.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Transition:draw()
|
||||||
|
local offset = self.game.HEIGHT
|
||||||
|
if not self.func then offset = 0 end
|
||||||
|
lg.setColor(self.color)
|
||||||
|
lg.rectangle("fill",0,offset-self.game.HEIGHT*(1-self.timer:getratio()), self.game.WIDTH,self.game.HEIGHT)
|
||||||
|
lg.setColor({1,1,1,1})
|
||||||
|
end
|
||||||
|
|
||||||
|
return Transition
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return gen
|
13
scenes.lua
13
scenes.lua
@ -7,19 +7,20 @@ function scenes:main(game)
|
|||||||
local y = (game.HEIGHT-cellsize*5)/2
|
local y = (game.HEIGHT-cellsize*5)/2
|
||||||
local grid = game.objects.grid:new(game,x,y,cellsize)
|
local grid = game.objects.grid:new(game,x,y,cellsize)
|
||||||
game:summon(grid)
|
game:summon(grid)
|
||||||
local background = game.objects.background:new(game,game:newImage("pattern.png"))
|
local background = game.objects.background:new(game,game:newImage("pattern.png"),30,15)
|
||||||
game:summon(background)
|
game:summon(background)
|
||||||
local background = game.objects.background:new(game,game:newImage("pattern2.png"),22,18)
|
local background = game.objects.background:new(game,game:newImage("pattern2.png"),30,-15)
|
||||||
game:summon(background)
|
game:summon(background)
|
||||||
end
|
end
|
||||||
|
|
||||||
function scenes:ending(game,winner)
|
function scenes:ending(game,args)
|
||||||
|
print(args.winner)
|
||||||
game.gameloop = {}
|
game.gameloop = {}
|
||||||
local ending = game.objects.ending:new(game,winner)
|
local ending = game.objects.ending:new(game,args.winner)
|
||||||
game:summon(ending)
|
game:summon(ending)
|
||||||
local background = game.objects.background:new(game,game:newImage("pattern.png"))
|
local background = game.objects.background:new(game,game:newImage("pattern.png"),30,15)
|
||||||
game:summon(background)
|
game:summon(background)
|
||||||
local background = game.objects.background:new(game,game:newImage("pattern2.png"),22)
|
local background = game.objects.background:new(game,game:newImage("pattern2.png"),30,-15)
|
||||||
game:summon(background)
|
game:summon(background)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user