Return to repo list

gatemender

Arcade game about fixing warp gates. LibreJam Dec 2020 Entry.
Return to HMagellan.com

commit 269799a81b05c8bbd5a6e730796746f320ea4e34
parent 70af09f6a71ab15437f1f310af9e58a98fbe6962
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Mon,  7 Dec 2020 14:47:09 -0600

Added info screen

Diffstat:
Adata/info.png | 0
Msrc/constants.py | 3++-
Msrc/game.py | 29+++++++++++++++++++++--------
3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/data/info.png b/data/info.png Binary files differ. diff --git a/src/constants.py b/src/constants.py @@ -34,7 +34,8 @@ IMAGE_FILES = { "Big_Gamma_Icon" : os.path.join("data", "gamma_material_big.png"), "UI_Tray" : os.path.join("data", "hud_tray.png"), "Fix_Aura" : os.path.join("data", "fix_aura.png"), - "Vortex" : os.path.join("data", "vortex.png") + "Vortex" : os.path.join("data", "vortex.png"), + "Info" : os.path.join("data", "info.png") } SOUND_FILES = { "Main_Menu_Music" : os.path.join("data", "title_screen.ogg"), diff --git a/src/game.py b/src/game.py @@ -14,6 +14,8 @@ class Game(object): self.frameclock = pygame.time.Clock() self.font = pygame.font.Font(FONTPATH, 24) self.mode = MODES.Play + self.show_info = False + self.just_pressed = False # Loading self.images = { i : pygame.image.load(IMAGE_FILES[i]).convert() for i in IMAGE_FILES } @@ -46,9 +48,9 @@ class Game(object): self.instructions_button = self.font.render("INSTRUCTIONS", False, (255, 255, 255), (20, 20, 20)) self.instructions_button_rect = self.instructions_button.get_rect() self.instructions_button_rect.center = (self.screen_rect.centerx, self.screen_rect.centery + 50) - self.options_button = self.font.render("OPTIONS", False, (255, 255, 255), (20, 20, 20)) - self.options_button_rect = self.options_button.get_rect() - self.options_button_rect.center = (self.screen_rect.centerx, self.screen_rect.centery + 90) + #self.options_button = self.font.render("OPTIONS", False, (255, 255, 255), (20, 20, 20)) + #self.options_button_rect = self.options_button.get_rect() + #self.options_button_rect.center = (self.screen_rect.centerx, self.screen_rect.centery + 90) self.change_mode(MODES.Menu) def clear_level(self): @@ -235,8 +237,16 @@ class Game(object): elif self.mode == MODES.Menu: if pygame.mouse.get_pressed()[0]: mousepos = pygame.mouse.get_pos() - if self.start_button_rect.collidepoint(mousepos): - self.change_mode(MODES.Play) + if not self.show_info: + if self.start_button_rect.collidepoint(mousepos): + self.change_mode(MODES.Play) + elif self.instructions_button_rect.collidepoint(mousepos): + self.show_info = True + self.just_pressed = True + elif not self.just_pressed: + self.show_info = False + else: + self.just_pressed = False def update_screen(self): if self.mode == MODES.Play: @@ -260,9 +270,12 @@ class Game(object): self.screen.blit(self.score_surface, self.score_surface_rect) elif self.mode == MODES.Menu: self.screen.fill((0, 0, 0)) - self.screen.blit(self.start_button, self.start_button_rect) - self.screen.blit(self.instructions_button, self.instructions_button_rect) - self.screen.blit(self.options_button, self.options_button_rect) + if not self.show_info: + self.screen.blit(self.start_button, self.start_button_rect) + self.screen.blit(self.instructions_button, self.instructions_button_rect) + else: + self.screen.blit(self.images["Info"], (0, 0)) + #self.screen.blit(self.options_button, self.options_button_rect) elif self.mode == MODES.Transition: self.screen.fill((0, 0, 0)) self.screen.blit(self.lives_text, (100, 100))