Return to repo list

gatemender

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

commit cbe98ea5e6fd590d26571c49368f08a2e648b35a
parent 815ce8abb74fe12ff3c8934f140433dafd04027c
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Wed, 16 Dec 2020 17:43:37 -0600

Mostly minor performance improvements

Diffstat:
Ddata/font-license.txt | 13-------------
Mhs.json | 4++--
Msrc/game.py | 44++++++++++++++++++++++----------------------
Msrc/sprites.py | 13+++++++------
4 files changed, 31 insertions(+), 43 deletions(-)

diff --git a/data/font-license.txt b/data/font-license.txt @@ -1,12 +0,0 @@ -The FontStruction “Computer Speak v0.3” -(https://fontstruct.com/fontstructions/show/1436469) by “Mcguy215” is -licensed under a Creative Commons Attribution license -(http://creativecommons.org/licenses/by/3.0/). -“Computer Speak v0.3” was originally cloned (copied) from the FontStruction -“Computer Speak v0.2” (https://fontstruct.com/fontstructions/show/1432943) -by “Mcguy215”, which is licensed under a Creative Commons Attribution -license (http://creativecommons.org/licenses/by/3.0/). -“Computer Speak v0.2” was in turn cloned (copied) from the FontStruction -“Computer Speak” (https://fontstruct.com/fontstructions/show/1431517) by -“Mcguy215”, which is licensed under a Creative Commons Attribution license -(http://creativecommons.org/licenses/by/3.0/).- \ No newline at end of file diff --git a/hs.json b/hs.json @@ -1 +1 @@ -{"SCORES": [30, 280, 500, 1000]}- \ No newline at end of file +{"SCORES": [500, 1000]}+ \ No newline at end of file diff --git a/src/game.py b/src/game.py @@ -172,6 +172,20 @@ class Game(object): if mode == MODES.Play: self.load_level() self.play_sound("Game_Music", 0) + self.hp_heading = self.font.render("HP", False, (255, 255, 255)) + self.hp_heading_rect = self.hp_heading.get_rect() + self.hp_heading_rect.center = (41, 720) + self.burst_heading = self.font.render("BURST", False, (0, 255, 255)) + self.burst_heading_rect = self.burst_heading.get_rect() + self.burst_heading_rect.center = (240, 720) + self.hp_meter = pygame.Surface((32, 80)) + self.hp_meter.fill((135, 0, 22)) + self.hp_meter_rect = self.hp_meter.get_rect() + self.hp_meter_rect.center = (40, 720) + self.burst_meter = pygame.Surface((100, 32)) + self.burst_meter.fill((135, 0, 22)) + self.burst_meter_rect = self.burst_meter.get_rect() + self.burst_meter_rect.center = (236, 720) elif mode == MODES.Transition: pygame.mixer.stop() self.level_text = self.font.render("GATE " + str(self.level_factor), False, (255, 255, 255)) @@ -201,6 +215,9 @@ class Game(object): def render_hud(self): if self.mode == MODES.Play: + self.num_lives = self.font.render("X " + str(self.lives), False, (255, 255, 255)) + self.num_lives_rect = self.num_lives.get_rect() + self.num_lives_rect.center = (150, 720) self.num_alpha = self.font.render(str(self.ship.materials[MATERIALS.Alpha]), False, (255, 255, 255)) self.num_alpha_rect = self.num_alpha.get_rect() self.num_alpha_rect.center = (440, 710) @@ -210,34 +227,18 @@ class Game(object): self.num_gamma = self.font.render(str(self.ship.materials[MATERIALS.Gamma]), False, (255, 255, 255)) self.num_gamma_rect = self.num_gamma.get_rect() self.num_gamma_rect.center = (600, 710) - self.num_lives = self.font.render("X " + str(self.lives), False, (255, 255, 255)) - self.num_lives_rect = self.num_lives.get_rect() - self.num_lives_rect.center = (150, 720) - self.hp_heading = self.font.render("HP", False, (255, 255, 255)) - self.hp_heading_rect = self.hp_heading.get_rect() - self.hp_heading_rect.center = (41, 720) - self.hp_meter = pygame.Surface((32, 80)) - self.hp_meter.fill((135, 0, 22)) - self.hp_meter_rect = self.hp_meter.get_rect() self.hp_meter_fill = pygame.Surface((32, round((self.ship.hp / 3) * 80))) self.hp_meter_fill.fill((0, 200, 0)) self.hp_meter_fill_rect = self.hp_meter_fill.get_rect() - self.hp_meter_rect.center = (40, 720) self.hp_meter_fill_rect.bottom = self.hp_meter_rect.bottom - 1 self.hp_meter_fill_rect.centerx = self.hp_meter_rect.centerx - burst_fill_colo = (0, 0, 200) if self.ship.burst_counter == 100: burst_fill_colo = (255, 255, 255) - self.burst_heading = self.font.render("BURST", False, (0, 255, 255)) - self.burst_heading_rect = self.burst_heading.get_rect() - self.burst_heading_rect.center = (240, 720) - self.burst_meter = pygame.Surface((100, 32)) - self.burst_meter.fill((135, 0, 22)) - self.burst_meter_rect = self.burst_meter.get_rect() + else: + burst_fill_colo = (0, 0, 200) self.burst_meter_fill = pygame.Surface((self.ship.burst_counter, 32)) self.burst_meter_fill.fill(burst_fill_colo) self.burst_meter_fill_rect = self.burst_meter_fill.get_rect() - self.burst_meter_rect.center = (236, 720) self.burst_meter_fill_rect.bottom = self.burst_meter_rect.bottom - 1 self.burst_meter_fill_rect.centerx = self.burst_meter_rect.centerx self.score_surface = self.font.render("SCORE: " + str(self.score), False, (255, 255, 255)) @@ -310,7 +311,6 @@ class Game(object): def update_screen(self): if self.mode == MODES.Play: self.screen.fill((44, 44, 44)) - self.camera_surface.fill((0, 0, 0)) self.camera_surface.blit(self.images["Space_Background"], (0, 0)) self.camera_draw_group.update(self.camera_surface) self.render_hud() @@ -328,9 +328,9 @@ class Game(object): self.screen.blit(self.burst_heading, self.burst_heading_rect) 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.title, self.title_rect) if not self.show_info: + self.screen.fill((0, 0, 0)) + self.screen.blit(self.title, self.title_rect) 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) @@ -352,7 +352,7 @@ class Game(object): self.screen.blit(self.options_back_button, self.options_back_button_rect) self.music_on_checkbox.update(self.screen) self.sound_on_checkbox.update(self.screen) - pygame.display.update() + pygame.display.flip() def update_logic(self): # Non-modal logic diff --git a/src/sprites.py b/src/sprites.py @@ -473,9 +473,10 @@ class ThrustSprite(CustomSprite): self.flip_timer = 10 def act(self): - if self.flip_timer > 0: - self.flip_timer -= 1 - else: - self.base_image = pygame.transform.flip(self.base_image, True, False) - self.flip_timer = 10 - self.rotate(self.ship.angle) + if self.visible: + if self.flip_timer > 0: + self.flip_timer -= 1 + else: + self.base_image = pygame.transform.flip(self.base_image, True, False) + self.flip_timer = 10 + self.rotate(self.ship.angle)