forked from ayte/PinmikPanik
Added screenshake
This commit is contained in:
parent
e28f8c8958
commit
2ca249f666
@ -83,6 +83,8 @@ class Lemming(BaseObject):
|
|||||||
dead = False
|
dead = False
|
||||||
if dead:
|
if dead:
|
||||||
self.manager.death()
|
self.manager.death()
|
||||||
|
self.game.globals["scamerax"]+=5
|
||||||
|
self.game.globals["scameray"]+=5
|
||||||
self.game.gameloop.delid(self.id)
|
self.game.gameloop.delid(self.id)
|
||||||
|
|
||||||
def launch(self):
|
def launch(self):
|
||||||
@ -109,14 +111,14 @@ class Lemming(BaseObject):
|
|||||||
def draw(self):
|
def draw(self):
|
||||||
orientation = self.orientations[int(self.direction%360/361*4)]
|
orientation = self.orientations[int(self.direction%360/361*4)]
|
||||||
sprites = self.sprites[orientation]
|
sprites = self.sprites[orientation]
|
||||||
self.game.lib.drawcenter(self.game,self.game.sprite_lib["lemmings/shadow.png"],self.rect.center[0],self.rect.center[1])
|
self.game.lib.drawcenter(self.game,self.game.sprite_lib["lemmings/shadow.png"],self.rect.center[0]-self.game.globals["camerax"],self.rect.center[1]-self.game.globals["cameray"])
|
||||||
self.game.lib.drawcenter(self.game,sprites[int(self.spriteindex)%len(sprites)],self.rect.center[0],self.rect.center[1])
|
self.game.lib.drawcenter(self.game,sprites[int(self.spriteindex)%len(sprites)],self.rect.center[0]-self.game.globals["camerax"],self.rect.center[1]-self.game.globals["cameray"])
|
||||||
if self.game.globals["debug"]:
|
if self.game.globals["debug"]:
|
||||||
s = self.game.pygame.Surface(self.rect.size)
|
s = self.game.pygame.Surface(self.rect.size)
|
||||||
s.fill([255,0,0])
|
s.fill([255,0,0])
|
||||||
s.set_alpha(30)
|
s.set_alpha(30)
|
||||||
self.game.window.blit(s,self.rect[:2])
|
self.game.window.blit(s,(self.rect[0]-self.game.globals["camerax"],self.rect[1]-self.game.globals["cameray"]))
|
||||||
s = self.game.pygame.Surface(self.holdrect.size)
|
s = self.game.pygame.Surface(self.holdrect.size)
|
||||||
s.fill([0,255,0])
|
s.fill([0,255,0])
|
||||||
s.set_alpha(30)
|
s.set_alpha(30)
|
||||||
self.game.window.blit(s,self.holdrect[:2])
|
self.game.window.blit(s,(self.holdrect[0]-self.game.globals["camerax"],self.holdrect[1]-self.game.globals["cameray"]))
|
||||||
|
@ -19,12 +19,14 @@ class Spawner(BaseObject):
|
|||||||
lemming.move(-lemming.rect[2]/2,-lemming.rect[3]/2)
|
lemming.move(-lemming.rect[2]/2,-lemming.rect[3]/2)
|
||||||
self.game.gameloop.summon(lemming)
|
self.game.gameloop.summon(lemming)
|
||||||
self.game.gameloop.delid(self.id)
|
self.game.gameloop.delid(self.id)
|
||||||
|
self.game.globals["scamerax"]+=3
|
||||||
|
self.game.globals["scameray"]+=3
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
# Display the lemming falling
|
# Display the lemming falling
|
||||||
currentdistance = self.distance*self.timer.getratio()**2
|
currentdistance = self.distance*self.timer.getratio()**2
|
||||||
self.game.lib.drawcenter(self.game,self.fallsprite,self.rect[0],self.rect[1]-currentdistance)
|
self.game.lib.drawcenter(self.game,self.fallsprite,self.rect[0]-self.game.globals["camerax"],self.rect[1]-currentdistance-self.game.globals["cameray"])
|
||||||
|
|
||||||
# Draw the shadow
|
# Draw the shadow
|
||||||
self.game.lib.drawcenter(self.game,self.sprite,self.rect[0],self.rect[1])
|
self.game.lib.drawcenter(self.game,self.sprite,self.rect[0]-self.game.globals["camerax"],self.rect[1]-self.game.globals["cameray"])
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@ class Tiles(BaseObject):
|
|||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
# Drawing the ground
|
# Drawing the ground
|
||||||
self.game.window.blit(self.game.sprite_lib["ingame.png"],(0,0))
|
self.game.window.blit(self.game.sprite_lib["ingame.png"],(-self.game.globals["camerax"],-self.game.globals["cameray"]))
|
||||||
if self.game.globals["debug"]:
|
if self.game.globals["debug"]:
|
||||||
# Drawing the grid
|
# Drawing the grid
|
||||||
for y in range(len(self.grid)):
|
for y in range(len(self.grid)):
|
||||||
for x in range(len(self.grid[y])):
|
for x in range(len(self.grid[y])):
|
||||||
if self.grid[y][x]==1:
|
if self.grid[y][x]==1:
|
||||||
self.game.window.blit(self.debugcell,[self.rect[0]+x*self.cellsize,self.rect[1]+y*self.cellsize])
|
self.game.window.blit(self.debugcell,[self.rect[0]+x*self.cellsize-self.game.globals["camerax"],self.rect[1]+y*self.cellsize-self.game.globals["cameray"]])
|
||||||
# Draw spawn points
|
# Draw spawn points
|
||||||
for point in self.spawns:
|
for point in self.spawns:
|
||||||
self.game.pygame.draw.circle(self.game.window,[100,100,0],point,radius=3)
|
self.game.pygame.draw.circle(self.game.window,[100,100,0],[point[0]-self.game.globals["camerax"],point[1]-self.game.globals["cameray"]],radius=3)
|
||||||
|
@ -18,6 +18,8 @@ def main(game):
|
|||||||
|
|
||||||
def ingame(game):
|
def ingame(game):
|
||||||
game.gameloop.reinit()
|
game.gameloop.reinit()
|
||||||
|
game.globals["camerax"] = 0
|
||||||
|
game.globals["cameray"] = 0
|
||||||
game.gameloop.summon(Manager(game))
|
game.gameloop.summon(Manager(game))
|
||||||
|
|
||||||
def options(game):
|
def options(game):
|
||||||
|
Loading…
Reference in New Issue
Block a user