Two layer background
This commit is contained in:
parent
50d489b598
commit
6d35f1a9d3
Binary file not shown.
Before Width: | Height: | Size: 839 B After Width: | Height: | Size: 6.5 KiB |
BIN
assets/pattern2.png
Normal file
BIN
assets/pattern2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 747 B |
@ -1,6 +1,6 @@
|
||||
gen = {}
|
||||
|
||||
function gen:new(game,sprite)
|
||||
function gen:new(game,sprite,speedx,speedy,depth)
|
||||
|
||||
local Background = game.objects.base:new(game,0,0,game.WIDTH,game.HEIGHT)
|
||||
Background.sprite = sprite
|
||||
@ -8,14 +8,15 @@ function gen:new(game,sprite)
|
||||
Background.spriteheight = sprite:getHeight()
|
||||
Background.nbwidth = game.WIDTH%sprite:getWidth()+2
|
||||
Background.nbheight = game.HEIGHT%sprite:getHeight()+2
|
||||
Background.speed = 30
|
||||
Background.depth = -2
|
||||
Background.speedx = speedx or 30
|
||||
Background.speedy = speedy or 30
|
||||
Background.depth = depth or -2
|
||||
Background.offx = 0
|
||||
Background.offy = 0
|
||||
|
||||
function Background:step(dt)
|
||||
self.offx = (self.offx + dt*self.speed)%self.spritewidth
|
||||
self.offy = (self.offy + dt*self.speed)%self.spriteheight
|
||||
self.offx = (self.offx + dt*self.speedx)%self.spritewidth
|
||||
self.offy = (self.offy + dt*self.speedy)%self.spriteheight
|
||||
end
|
||||
|
||||
function Background:draw()
|
||||
|
@ -9,6 +9,8 @@ function scenes:main(game)
|
||||
game:summon(grid)
|
||||
local background = game.objects.background:new(game,game:newImage("pattern.png"))
|
||||
game:summon(background)
|
||||
local background = game.objects.background:new(game,game:newImage("pattern2.png"),22,18)
|
||||
game:summon(background)
|
||||
end
|
||||
|
||||
function scenes:ending(game,winner)
|
||||
@ -17,6 +19,8 @@ function scenes:ending(game,winner)
|
||||
game:summon(ending)
|
||||
local background = game.objects.background:new(game,game:newImage("pattern.png"))
|
||||
game:summon(background)
|
||||
local background = game.objects.background:new(game,game:newImage("pattern2.png"),22)
|
||||
game:summon(background)
|
||||
end
|
||||
|
||||
return scenes
|
||||
|
Loading…
Reference in New Issue
Block a user