Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed hud problem when using other resolution

  • Loading branch information...
commit ab30fcbd9b600e01d5ad79c731d677ae19778ca9 1 parent 121a945
michael authored
View
2  data/config.conf
@@ -1,7 +1,7 @@
(dp0
S'sound'
p1
-I01
+I00
sS'resolution'
p2
I00
View
2  sources/common_pygame.py
@@ -10,4 +10,4 @@
pygame.display.set_caption("MICshooter")
screenwidth=screen.get_width()
-screenheight=screen.get_width()
+screenheight=screen.get_height()
View
33 sources/hud.py
@@ -45,7 +45,7 @@ def __init__(self, single_sprites):
self.score_label = self.tinyfont.render("score", True, (255,255, 0))
self.inf = self.font.render("Inf.", True, (0,130, 255))
- self.offset=0
+ #self.offset=0
def blit(self, ship, level):
# Render the text
@@ -54,30 +54,33 @@ def blit(self, ship, level):
#armor_txt = self.font.render(str(ship.armor), True, (255,255, 0))
level_txt = self.tinyfont.render("level " + str(level), True, (255,255, 0))
#show the HUD
- screen.blit(self.single_sprites['lifemask.png'],(0,
- 600-self.single_sprites['lifemask.png'].get_height() -self.offset))
+ screen.blit(self.single_sprites['lifemask.png'],(0,common_pygame.screenheight
+ - self.single_sprites['lifemask.png'].get_height()))
#show the life and the score
- 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(self.score_label, (680,common_pygame.screenheight-50))
+ screen.blit(score_txt, (725,common_pygame.screenheight-55))
#screen.blit(level_txt, (455,common_pygame.screenheight-215-30 -self.offset))
-
-
+ #print(common_pygame.screenheight)
#progress bar for the armor
- 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))
+ updateProgbar(ship.armor,25, common_pygame.screenheight-23, 150, (7,200,0), 1)
+ screen.blit(self.single_sprites['armorbonus.png'],(0,common_pygame.screenheight-32))
#progress bar for the life
- 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))
+ updateProgbar(ship.life,common_pygame.screenwidth-25-150,
+ common_pygame.screenheight-23, 150, (0,181,200), 0)
+ screen.blit(self.single_sprites['lifebonus.png'],(common_pygame.screenwidth-25,common_pygame.screenheight-32))
+
#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'],(5, common_pygame.screenheight-223-30 -self.offset))
- screen.blit(self.inf,(25, common_pygame.screenheight-227-30 -self.offset))
+ screen.blit(self.single_sprites['sprite_laser.png'],(5,
+ common_pygame.screenheight-55))
+ screen.blit(self.inf,(25, common_pygame.screenheight-55))
else:
ammo_txt = self.font.render(str(ship.ammo), True, (0,130, 255))
- 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))
+ screen.blit(self.single_sprites['ball1.png'],(5,
+ common_pygame.screenheight-55 ))
+ screen.blit(ammo_txt,(25, common_pygame.screenheight-55))
View
29 sources/menu.py
@@ -28,12 +28,15 @@ def __init__ (self):
"sound" : 1,
"resolution" : 0}
-
if self.config['resolution']==0:
common_pygame.pygame.display.set_mode((800,600))
+ common_pygame.screenheight=600
else:
common_pygame.pygame.display.set_mode((800,500))
-
+ common_pygame.screenheight=500
+
+ # self.menustatus=0
+
def init2(self, single_sprites, sounds, background, hud):
self.single_sprites=single_sprites
self.sounds=sounds
@@ -46,14 +49,14 @@ def init2(self, single_sprites, sounds, background, hud):
self.compteur=31
#0: main menu
#1: option menu
- self.menuStatus=0
+ self.menustatus=0
self.font = pygame.font.Font(None,32)
- #self.config={}
+ #self.config={}
self.hud=hud
- if self.config['resolution']==0:
- self.hud.offset=0
- else:
- self.hud.offset=100
+ # if self.config['resolution']==0:
+ # self.hud.offset=0
+ # else:
+ # self.hud.offset=100
@@ -107,7 +110,7 @@ def launch(self, withresume):
- if self.menuStatus==0:
+ if self.menustatus==0:
if pygame.key.get_pressed()[pygame.K_RETURN] and self.selection==1 and self.compteur>=5:
self.compteur=0
effects.fadeToColor(0, 0, 0)
@@ -120,7 +123,7 @@ def launch(self, withresume):
if pygame.key.get_pressed()[pygame.K_RETURN] and self.selection==2 and self.compteur>=5:
self.compteur=0
self.selection=1
- self.menuStatus=1
+ self.menustatus=1
#print the menu accordingly to the selection and the menu state
@@ -163,7 +166,7 @@ def launch(self, withresume):
else:
screen.blit(self.single_sprites['menu_quit.png'],(270-decalx,200+(2*space)-decaly))
- elif self.menuStatus==1:
+ elif self.menustatus==1:
if (pygame.key.get_pressed()[pygame.K_LEFT] or pygame.key.get_pressed()[pygame.K_RIGHT]) \
and self.selection==1 and self.compteur>=5:
@@ -191,7 +194,7 @@ def launch(self, withresume):
self.compteur=0
self.selection=1
- self.menuStatus=0
+ self.menustatus=0
if self.config['sound']:
@@ -223,7 +226,7 @@ def launch(self, withresume):
screen.blit(self.font.render("go back", True, (255,255, 255)),(350,300))
if pygame.key.get_pressed()[K_ESCAPE]:
- self.menuStatus=0
+ self.menustatus=0
pygame.display.flip()
Please sign in to comment.
Something went wrong with that request. Please try again.