Added pseudo-tutorial

This commit is contained in:
theo@manjaro 2021-09-17 15:00:19 +02:00
parent 932c68d6c3
commit 59a7b97b94
4 changed files with 49 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,40 @@
from gamedata.objects.base import BaseObject
import math
class Demo(BaseObject):
def __init__(self,game):
super().__init__(game.DISPLAY_WIDTH/2,game.DISPLAY_HEIGHT/2,game,0,0)
self.blinktimer = game.lib.Timer(0.5)
self.pinmik = game.gameloop.findname("Lemming")[0]
self.move()
self.maxblink = 6
self.depth = 6
def move(self):
self.rect[0] = self.pinmik.rect.center[0]
self.rect[1] = self.pinmik.rect.center[1]+50
def step(self):
self.blinktimer.tick(self.game.dt)
if self.blinktimer.getloops()>=self.maxblink:
self.game.gameloop.delid(self.id)
self.move()
def draw(self):
sprites = self.game.getSpriteDir("cursor/")
sprite = sprites[self.blinktimer.getloops()%2]
if self.blinktimer.getloops()>=self.maxblink-1:
sprite.set_alpha(self.blinktimer.getratio()*255)
elif self.blinktimer.getloops()==0:
sprite.set_alpha((1-self.blinktimer.getratio())*255)
else:
sprite.set_alpha(255)
if self.blinktimer.getloops()<self.maxblink:
self.game.lib.drawcenter(self.game,sprite,self.rect[0],self.rect[1])

View File

@ -3,6 +3,7 @@ from gamedata.objects.ingame.spawner import Spawner
from gamedata.objects.ingame.tiles import Tiles from gamedata.objects.ingame.tiles import Tiles
from gamedata.objects.ingame.clouds import Clouds from gamedata.objects.ingame.clouds import Clouds
from gamedata.objects.ingame.skies import Skies from gamedata.objects.ingame.skies import Skies
from gamedata.objects.ingame.demo import Demo
class Manager(BaseObject): class Manager(BaseObject):
def __init__(self,game): def __init__(self,game):
@ -38,6 +39,10 @@ class Manager(BaseObject):
# Spawn the first one # Spawn the first one
self.game.gameloop.summon(Spawner(self.game,self.tiles)) self.game.gameloop.summon(Spawner(self.game,self.tiles))
# Demo
self.demo = None
self.demotimer = game.lib.Timer(4)
def step(self): def step(self):
nblemmings = len(self.game.gameloop.findname("Lemming")) + len(self.game.gameloop.findname("Spawner")) nblemmings = len(self.game.gameloop.findname("Lemming")) + len(self.game.gameloop.findname("Spawner"))
# Updating score # Updating score
@ -59,6 +64,10 @@ class Manager(BaseObject):
if self.deathtimer.tick(self.game.dt): if self.deathtimer.tick(self.game.dt):
self.invincible = False self.invincible = False
if not self.demo:
if self.demotimer.tick(self.game.dt):
self.demo = self.game.gameloop.summon(Demo(self.game))
def death(self): def death(self):
if not self.invincible: if not self.invincible:
self.lives-=1 self.lives-=1