Skip to content

Commit

Permalink
add lives and level to viewer and explosion bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipeMiguelVale committed Oct 22, 2019
1 parent 6d30aa0 commit fb144bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Binary file modified data/nes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 16 additions & 4 deletions viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def update(self, bombs_state):
self.radius * 2 * CHAR_LENGTH + CHAR_LENGTH,
)
)
self.image.set_colorkey((0,0,0))
self.image.blit(
SPRITES,
scale((self.radius, self.radius)),
Expand Down Expand Up @@ -348,7 +349,6 @@ def draw_info(SCREEN, text, pos, color=(0, 0, 0), background=None):
else:
erase = pygame.Surface(textsurface.get_size())
erase.fill(COLORS["grey"])
# SCREEN.blit(erase, pos)

SCREEN.blit(textsurface, pos)

Expand All @@ -375,15 +375,17 @@ async def main_game():
mapa = Map(size=newgame_json["size"], mapa=newgame_json["map"])
TIMEOUT = newgame_json["timeout"]
SCREEN = pygame.display.set_mode(scale(mapa.size))
SPRITES = pygame.image.load("data/nes.png").convert_alpha()

SPRITES = pygame.image.load("data/nes.png").convert_alpha() # if in your terminal appears: "libpng warning: iCCP: known incorrect sRGB profile"
# do this command in your project directory convert data/nes.png data/nes.png
BACKGROUND = draw_background(mapa)
SCREEN.blit(BACKGROUND, (0, 0))

main_group.add(BomberMan(pos=mapa.bomberman_spawn))

state = {"score": 0, "player": "player1", "bomberman": (1, 1)}

while True:
SCREEN.blit(BACKGROUND, (0, 0))
pygame.event.pump()
if pygame.key.get_pressed()[pygame.K_ESCAPE]:
asyncio.get_event_loop().stop()
Expand All @@ -396,7 +398,17 @@ async def main_game():
text = str(state["score"])
draw_info(SCREEN, text.zfill(6), (0, 0))
text = str(state["player"]).rjust(32)
draw_info(SCREEN, text, (4000, 0))
draw_info(SCREEN, text, (650, 0))

if "lives" in state and "level" in state:
text = "lives: "
draw_info(SCREEN, text, (300,1))
text = " " + str(state["lives"])
draw_info(SCREEN, text, (300,1),color=(255, 0, 0))
text = "level: "
draw_info(SCREEN, text, (450,1))
text = " " + str(state["level"])
draw_info(SCREEN, text, (450,1),color=(255, 0, 0))

if "bombs" in state:
for bomb in bombs_group:
Expand Down

0 comments on commit fb144bd

Please sign in to comment.