PinmikPanik/gamedata/objects/bg/menubackground.py

37 lines
1.2 KiB
Python
Raw Normal View History

2021-09-16 08:19:35 +02:00
from gamedata.objects.base import BaseObject
2021-09-18 17:34:46 +02:00
from gamedata.objects.fallingpinmik import FallingPinmik
import random
2021-09-10 19:22:30 +02:00
2021-09-16 08:19:35 +02:00
class MenuBackground(BaseObject):
2021-09-10 19:22:30 +02:00
def __init__(self,game):
2021-09-16 08:19:35 +02:00
super().__init__(0,0,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT)
2021-09-10 19:22:30 +02:00
2021-09-16 08:19:35 +02:00
# Islands
2021-09-18 11:23:05 +02:00
self.sprite = game.sprite_lib["islands.png"]
2021-09-18 17:34:46 +02:00
2021-09-16 08:34:40 +02:00
self.depth = -2
2021-09-16 08:19:35 +02:00
self.cameraratio = 0.1
2021-09-18 17:34:46 +02:00
# Pinmik falling
self.pinmiktimer = game.lib.Timer(1)
2021-09-18 18:27:52 +02:00
unlocks = game.lib.getunlocks(game.globals["highscore"])
self.skins = unlocks["normal"]+unlocks["specials"]
2021-09-18 17:34:46 +02:00
2021-09-10 19:22:30 +02:00
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
2021-09-18 17:34:46 +02:00
if self.pinmiktimer.tick(self.game.dt):
self.pinmiktimer = game.lib.Timer(1+random.random())
2021-09-18 18:27:52 +02:00
self.game.gameloop.summon(FallingPinmik(game,skins=self.skins))
2021-09-18 17:34:46 +02:00
2021-09-10 19:22:30 +02:00
def draw(self):
game = self.game
2021-09-16 08:19:35 +02:00
game.window.blit(self.sprite,[-game.globals["camerax"]*self.cameraratio,-game.globals["cameray"]*self.cameraratio])