PinmikPanik/gamedata/objects/bg/menubackground.py

37 lines
1.2 KiB
Python

from gamedata.objects.base import BaseObject
from gamedata.objects.fallingpinmik import FallingPinmik
import random
class MenuBackground(BaseObject):
def __init__(self,game):
super().__init__(0,0,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT)
# Islands
self.sprite = game.sprite_lib["islands.png"]
self.depth = -2
self.cameraratio = 0.1
# Pinmik falling
self.pinmiktimer = game.lib.Timer(1)
unlocks = game.lib.getunlocks(game.globals["highscore"])
self.skins = unlocks["normal"]+unlocks["specials"]
def step(self):
game = self.game
destx = (game.inputs["mouse"]["pos"][0]-game.DISPLAY_WIDTH/2)
desty = (game.inputs["mouse"]["pos"][1]-game.DISPLAY_HEIGHT/2)
game.globals["camerax"] += (destx-game.globals["camerax"])/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,skins=self.skins))
def draw(self):
game = self.game
game.window.blit(self.sprite,[-game.globals["camerax"]*self.cameraratio,-game.globals["cameray"]*self.cameraratio])