Permalink
Browse files

better hud

  • Loading branch information...
1 parent 206cf31 commit 31b6993a908e165f25df6c843769760fbf6fda0d @antismap committed Jun 9, 2012
Showing with 17 additions and 16 deletions.
  1. BIN images/lifemask.png
  2. +1 −1 sources/enemy.py
  3. +14 −13 sources/hud.py
  4. +2 −2 sources/ship.py
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -373,7 +373,7 @@ def update(self, ship):
#if self.typeofship==2:
#if we are the first boss, we print the progress bar
if self.typeofship==2:
- hud.updateProgbar(self.life/30,10, 10,400, (255,0,0))
+ hud.updateProgbar(self.life/30,10, 10,400, (255,0,0), 1)
View
@@ -14,7 +14,7 @@
#self.textHeight=self.y1-80
-def updateProgbar(percent,x1, y1,max_width, color):
+def updateProgbar(percent,x1, y1,max_width, color, direction):
s = pygame.Surface((max_width,15)) # the size of your rect
s.set_alpha(64) # alpha level
s.fill(color) # this fills the entire surface
@@ -27,7 +27,10 @@ def updateProgbar(percent,x1, y1,max_width, color):
##txtpercent = self.font.render(str(percent)+"%", True, self.color)
##screen.blit(txtpercent, (20,y1+30))
- pygame.draw.rect(screen, color, (x1,y1,(percent*max_width)/100,15), 0)
+ if direction==1:
+ pygame.draw.rect(screen, color, (x1,y1,(percent*max_width)/100,15), 0)
+ else:
+ pygame.draw.rect(screen, color, (x1+(max_width-(percent*max_width)/100),y1,(percent*max_width)/100,15), 0)
#pygame.draw.rect(screen, color2, (x1,y1,max_width,15), 1 )
@@ -54,29 +57,27 @@ def blit(self, ship, level):
screen.blit(self.single_sprites['lifemask.png'],(0,
600-self.single_sprites['lifemask.png'].get_height() -self.offset))
#show the life and the score
- #screen.blit(life_txt, (common_pygame.screenwidth-70,common_pygame.screenheight-224 -self.offset))
- screen.blit(self.score_label, (350-35,common_pygame.screenheight-215 -self.offset))
- screen.blit(score_txt, (350,common_pygame.screenheight-224-self.offset ))
- screen.blit(level_txt, (455,common_pygame.screenheight-215 -self.offset))
+ screen.blit(self.score_label, (680,common_pygame.screenheight-215-30 -self.offset))
+ screen.blit(score_txt, (725,common_pygame.screenheight-224-30-self.offset ))
+ #screen.blit(level_txt, (455,common_pygame.screenheight-215-30 -self.offset))
#progress bar for the armor
- updateProgbar(ship.armor,25, common_pygame.screenheight-223, 150, (7,200,0))
+ updateProgbar(ship.armor,25, common_pygame.screenheight-223, 150, (7,200,0), 1)
screen.blit(self.single_sprites['armorbonus.png'],(0,common_pygame.screenheight-232))
#progress bar for the life
- updateProgbar(ship.life,common_pygame.screenwidth-25-150, common_pygame.screenheight-223, 150, (0,181,200))
+ updateProgbar(ship.life,common_pygame.screenwidth-25-150, common_pygame.screenheight-223, 150, (0,181,200), 0)
screen.blit(self.single_sprites['lifebonus.png'],(common_pygame.screenwidth-25,common_pygame.screenheight-232))
#screen.blit(armor_txt, (35,common_pygame.screenheight-227-self.offset ))
#blit the current weapon and the ammo
if ship.weapon==1:
-
- screen.blit(self.single_sprites['sprite_laser.png'],(160+50, common_pygame.screenheight-220 -self.offset))
- screen.blit(self.inf,(185+50, common_pygame.screenheight-227 -self.offset))
+ screen.blit(self.single_sprites['sprite_laser.png'],(5, common_pygame.screenheight-223-30 -self.offset))
+ screen.blit(self.inf,(25, common_pygame.screenheight-227-30 -self.offset))
else:
ammo_txt = self.font.render(str(ship.ammo), True, (0,130, 255))
- screen.blit(self.single_sprites['ball1.png'],(160+50, common_pygame.screenheight-220-self.offset ))
- screen.blit(ammo_txt,(185+50, common_pygame.screenheight-227 -self.offset))
+ screen.blit(self.single_sprites['ball1.png'],(5, common_pygame.screenheight-223-30-self.offset ))
+ screen.blit(ammo_txt,(25, common_pygame.screenheight-227-30 -self.offset))
View
@@ -156,8 +156,8 @@ def updatePosition(self):
self.position_ship_x = self.position_ship_x + self.currentspeed_x
#update de position Y:
- if self.position_ship_y+self.currentspeed_y>screen.get_height()-self.height-32:
- self.position_ship_y = screen.get_height()-self.height-32
+ if self.position_ship_y+self.currentspeed_y>screen.get_height()-self.height:
+ self.position_ship_y = screen.get_height()-self.height
#reset the speed
self.currentspeed_x =0
self.currentspeed_y= 0

0 comments on commit 31b6993

Please sign in to comment.