forked from ayte/PinmikPanik
Added falling pinmiks on menu
This commit is contained in:
parent
a5604fa6e6
commit
32467d017d
@ -1,4 +1,6 @@
|
|||||||
from gamedata.objects.base import BaseObject
|
from gamedata.objects.base import BaseObject
|
||||||
|
from gamedata.objects.fallingpinmik import FallingPinmik
|
||||||
|
import random
|
||||||
|
|
||||||
class MenuBackground(BaseObject):
|
class MenuBackground(BaseObject):
|
||||||
|
|
||||||
@ -7,11 +9,14 @@ class MenuBackground(BaseObject):
|
|||||||
|
|
||||||
# Islands
|
# Islands
|
||||||
self.sprite = game.sprite_lib["islands.png"]
|
self.sprite = game.sprite_lib["islands.png"]
|
||||||
|
|
||||||
self.depth = -2
|
self.depth = -2
|
||||||
|
|
||||||
self.cameraratio = 0.1
|
self.cameraratio = 0.1
|
||||||
|
|
||||||
|
# Pinmik falling
|
||||||
|
self.pinmiktimer = game.lib.Timer(1)
|
||||||
|
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
game = self.game
|
game = self.game
|
||||||
@ -20,6 +25,10 @@ class MenuBackground(BaseObject):
|
|||||||
game.globals["camerax"] += (destx-game.globals["camerax"])/6
|
game.globals["camerax"] += (destx-game.globals["camerax"])/6
|
||||||
game.globals["cameray"] += (desty-game.globals["cameray"])/6
|
game.globals["cameray"] += (desty-game.globals["cameray"])/6
|
||||||
|
|
||||||
|
if self.pinmiktimer.tick(self.game.dt):
|
||||||
|
self.pinmiktimer = game.lib.Timer(1+random.random())
|
||||||
|
self.game.gameloop.summon(FallingPinmik(game))
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
game = self.game
|
game = self.game
|
||||||
game.window.blit(self.sprite,[-game.globals["camerax"]*self.cameraratio,-game.globals["cameray"]*self.cameraratio])
|
game.window.blit(self.sprite,[-game.globals["camerax"]*self.cameraratio,-game.globals["cameray"]*self.cameraratio])
|
||||||
|
27
gamedata/objects/fallingpinmik.py
Normal file
27
gamedata/objects/fallingpinmik.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
from gamedata.objects.base import BaseObject
|
||||||
|
import random
|
||||||
|
|
||||||
|
class FallingPinmik(BaseObject):
|
||||||
|
|
||||||
|
def __init__(self,game):
|
||||||
|
|
||||||
|
x = random.randint(0,game.DISPLAY_WIDTH)
|
||||||
|
y = -30
|
||||||
|
|
||||||
|
super().__init__(x,y,game,0,0)
|
||||||
|
|
||||||
|
self.cameraratio = random.random()*0.1+0.05
|
||||||
|
|
||||||
|
self.sprite = game.sprite_lib["lemmings/falling.png"]
|
||||||
|
|
||||||
|
self.offset = 0
|
||||||
|
self.speed = 100*(0.30-self.cameraratio)/0.30
|
||||||
|
|
||||||
|
self.depth = -1.5
|
||||||
|
|
||||||
|
def step(self):
|
||||||
|
|
||||||
|
self.offset+=self.game.dt*self.speed
|
||||||
|
|
||||||
|
def draw(self):
|
||||||
|
self.game.lib.drawcenter(self.game,self.sprite,self.rect[0]-self.game.globals["camerax"]*self.cameraratio,self.rect[1]+self.offset-self.game.globals["cameray"]*self.cameraratio)
|
Loading…
x
Reference in New Issue
Block a user