Added score et lives display

This commit is contained in:
theo@manjaro 2021-09-13 11:33:40 +02:00
parent 0edc8cb3ac
commit 1194ccfd55
3 changed files with 12 additions and 2 deletions

View File

@ -12,7 +12,10 @@ class BaseObject():
def step(self):
pass
def draw(self):
def draw(self): # Drawed on the surface with camera adjustement
if self.sprite:
self.game.window.blit(self.sprite,self.rect[:2])
def afterdraw(self): # Drawed on the surface after camera adjustement, must draw on game.realwindow
pass

View File

@ -66,3 +66,5 @@ class GameLoop():
game.globals["tempsubsurface"].blit(game.window,[0,0])
temp = game.pygame.transform.scale(game.globals["tempsubsurface"],(game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT))
game.realwindow.blit(temp,[0,0])
for i in values:
i.afterdraw() # Draw on the "real screen"

View File

@ -38,7 +38,6 @@ class Manager(BaseObject):
if self.invincible:
if self.deathtimer.tick(self.game.dt):
self.invincible = False
print(self.lives)
def death(self):
if not self.invincible:
@ -48,3 +47,9 @@ class Manager(BaseObject):
def draw(self):
pass
def afterdraw(self):
txtsurfacescore = self.game.fontfile.render("Score : "+str(int(self.score)),False,[150,255,150])
txtsurfacelives = self.game.fontfile.render("Lives : "+str(int(self.lives)),False,[255,150,150])
self.game.realwindow.blit(txtsurfacescore,[20,20])
self.game.realwindow.blit(txtsurfacelives,[20,20*2+txtsurfacescore.get_height()])