def __init__(self, sm): self.state_manager = sm self.title_bg_animation = Animation(assetsmanager.get('TITLEGIF'), 30) self.title_font = assetsmanager.get('EXPLANATION').render('APERTE ALGUM BOTAO', 0, (186, 214, 166)).convert() self.title_alpha = 255 self.decrease_alpha = True self.title_image = assetsmanager.get('TITLEIMG')
class TitleState: def __init__(self, sm): self.state_manager = sm self.title_bg_animation = Animation(assetsmanager.get('TITLEGIF'), 30) self.title_font = assetsmanager.get('EXPLANATION').render('APERTE ALGUM BOTAO', 0, (186, 214, 166)).convert() self.title_alpha = 255 self.decrease_alpha = True self.title_image = assetsmanager.get('TITLEIMG') def fade_title(self, dt): if self.title_alpha >= 255: self.decrease_alpha = True elif self.title_alpha <= 25: self.decrease_alpha = False if self.decrease_alpha: self.title_alpha -= 0.2 * dt * 1000 else: self.title_alpha += 0.2 * dt * 1000 def handle_input(self, event): if event.type == JOYBUTTONDOWN: self.state_manager.change_state(2) #self.state_manager.transition.set_start_showing(True) def update(self, dt): self.fade_title(dt) self.title_font.set_alpha(self.title_alpha) self.title_bg_animation.update(dt) def draw(self, screen): screen.blit(self.title_bg_animation.get_frame(), (0, 0)) screen.blit(self.title_font, (100, 500)) screen.blit(self.title_image, (100, 50))
def __init__(self, sm): self.state_manager = sm self.is_playstate_reset = False self.final_score = -1 self.frames = [] for f in range(0, 24): self.frames.append( pygame.image.load('img/ending/frame_' + str(f) + '_delay-0.08s.gif')) self.animation = Animation(self.frames, 40) self.font = pygame.font.Font('fonts/8-bit-Madness.ttf', 58) self.font36 = pygame.font.Font('fonts/8-bit-Madness.ttf', 36)
class GameOver: def __init__(self, sm): self.state_manager = sm self.is_playstate_reset = False self.final_score = -1 self.frames = [] for f in range(0, 24): self.frames.append( pygame.image.load('img/ending/frame_' + str(f) + '_delay-0.08s.gif')) self.animation = Animation(self.frames, 40) self.font = pygame.font.Font('fonts/8-bit-Madness.ttf', 58) self.font36 = pygame.font.Font('fonts/8-bit-Madness.ttf', 36) def set_final_score(self, score): self.final_score = score def handle_input(self, event): if event.type == JOYBUTTONDOWN: pygame.mixer.music.fadeout(1000) self.state_manager.change_state(0) self.final_score = -1 def update(self, dt): if not pygame.mixer.music.get_busy() and self.final_score > -1: pygame.mixer.music.load('audio/music/ending.ogg') pygame.mixer.music.play(0) if not self.is_playstate_reset: self.state_manager.states.pop(2) self.state_manager.states.insert( 2, playstate.PlayState(self.state_manager)) self.is_playstate_reset = True self.animation.update(dt) def draw(self, screen): pygame.gfxdraw.box(screen, (0, 0, 800, 600), (23, 23, 23)) screen.blit(self.animation.get_frame(), (145, 100)) screen.blit( self.font.render('OBRIGADO POR JOGAR!', 0, (254, 254, 254)), (145, 45)) screen.blit( self.font.render('SUA PONTUACAO FOI: ' + str(self.final_score), 0, (126, 248, 109)), (125, 420)) screen.blit( self.font36.render( 'GRACAS A VOCE, O MUNDO E AGORA UM LUGAR MAIS LIMPO!', 0, (254, 254, 254)), (10, 500)) screen.blit( self.font36.render('JOGO PRODUZIDO POR SUBMERSIVO GAME STUDIO', 0, (254, 254, 254)), (70, 540))
def __init__(self, x, y): pygame.sprite.Sprite.__init__(self) self.img = pygame.image.load('img/dirt.png') self.frames = [] for yf in range(0, 3): for xf in range(0, 6): self.frames.append( self.img.subsurface((xf * 128, yf * 128, 128, 128))) self.animation = Animation(self.frames, 1) self.image = self.animation.get_frame() self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.x = x - 20 self.y = y - 20
def __init__(self, x, y): pygame.sprite.Sprite.__init__(self) self.img = pygame.image.load('img/magic.png') self.frames = [] for yf in range(0, 5): for xf in range(0, 5): self.frames.append( self.img.subsurface((xf * 96, yf * 96, 96, 96))) self.animation = Animation(self.frames, 20) self.image = self.animation.get_frame() self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.x = x self.y = y
class Dirt(pygame.sprite.Sprite): def __init__(self, x, y): pygame.sprite.Sprite.__init__(self) self.img = pygame.image.load('img/dirt.png') self.frames = [] for yf in range(0, 3): for xf in range(0, 6): self.frames.append( self.img.subsurface((xf * 128, yf * 128, 128, 128))) self.animation = Animation(self.frames, 1) self.image = self.animation.get_frame() self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.x = x - 20 self.y = y - 20 def update(self, dt): if self.animation.is_on_last_frame(): self.kill() self.animation.update(dt) self.image = self.animation.get_frame() self.rect.x = self.x self.rect.y = self.y def draw(self, screen): screen.blit(self.animation.get_frame(), self.rect)
class Spell(pygame.sprite.Sprite): def __init__(self, x, y): pygame.sprite.Sprite.__init__(self) self.img = pygame.image.load('img/magic.png') self.frames = [] for yf in range(0, 5): for xf in range(0, 5): self.frames.append( self.img.subsurface((xf * 96, yf * 96, 96, 96))) self.animation = Animation(self.frames, 20) self.image = self.animation.get_frame() self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.x = x self.y = y def update(self, dt): if self.animation.is_on_last_frame(): self.kill() self.animation.update(dt) self.image = self.animation.get_frame() self.rect.x = self.x self.rect.y = self.y def draw(self, screen): screen.blit(self.animation.get_frame(), self.rect)