Пример #1
0
def pause_menu(game: Properties, won=false):
    """
            pause menu, triggered also when user wins
    """
    while true:
        btn1 = pygame.Rect(((game.width - 200) // 2, 300, 200, 80))
        btn2 = pygame.Rect(((game.width - 200) // 2, 500, 200, 80))
        for event in pygame.event.get():
            if not general_interactions_handler(game, event):
                return false
            if event.type == pygame.MOUSEBUTTONDOWN:
                if event.button == 1:
                    x, y = pygame.mouse.get_pos()
                    if btn1.collidepoint((x, y)):
                        return true
                    if btn2.collidepoint((x, y)):
                        game.level = 0
                        return
        if won:
            text0 = set_text("You Won", game.width // 2, 70, 50)
            text1 = set_text("Continue anyway", game.width // 2, 335, 20)
        else:
            text0 = set_text("Pause", game.width // 2, 70, 50)
            text1 = set_text("Resume", game.width // 2, 335, 20)
        text2 = set_text("Exit", game.width // 2, 535, 20)
        pygame.draw.rect(game.screen, (0, 255, 0), btn1)
        pygame.draw.rect(game.screen, (0, 255, 0), btn2)
        game.screen.blit(text0[0], text0[1])
        game.screen.blit(text1[0], text1[1])
        game.screen.blit(text2[0], text2[1])
        pygame.display.update()
        game.clock.tick(game.fps)
Пример #2
0
def game_over(game: Properties):
    """
        just game over menu
    """
    while true:
        btn1 = pygame.Rect(((game.width - 200) // 2, 300, 200, 80))
        btn2 = pygame.Rect(((game.width - 200) // 2, 500, 200, 80))
        for event in pygame.event.get():
            if not general_interactions_handler(game, event):
                return false
            if event.type == pygame.MOUSEBUTTONDOWN:
                if event.button == 1:
                    x, y = pygame.mouse.get_pos()
                    if btn1.collidepoint((x, y)):
                        return
                    if btn2.collidepoint((x, y)):
                        game.level = 0
                        return
        text0 = set_text("Game Over", game.width // 2, 70, 50)
        text1 = set_text("Retry", game.width // 2, 335, 20)
        text2 = set_text("Exit", game.width // 2, 535, 20)
        pygame.draw.rect(game.screen, (0, 255, 0), btn1)
        pygame.draw.rect(game.screen, (0, 255, 0), btn2)
        game.screen.blit(text0[0], text0[1])
        game.screen.blit(text1[0], text1[1])
        game.screen.blit(text2[0], text2[1])
        pygame.display.update()
        game.clock.tick(game.fps)
Пример #3
0
 def user_interaction_handler(self):
     """
             general user interaction pygame events handling
             """
     for event in pygame.event.get():
         if not general_interactions_handler(self.game,
                                             event):  # if quit==false
             return false
         if event.type == pygame.KEYDOWN:
             if event.key == pygame.K_ESCAPE:
                 self.paused = true
             if event.key == pygame.K_PLUS:  # just for debug
                 self.game.fps += 60
                 print(self.game.fps)
             if event.key == pygame.K_MINUS:  # just for debug
                 self.game.fps -= 60
             if event.key == pygame.K_w:  # time speed up
                 if self.time < 2:
                     self.time += 0.1
                     Sphere.time = self.time
                     text = set_text(
                         str(round(self.time, 1)) + 'x',
                         self.game.width // 2, self.game.height - 100, 50)
                     self.game.screen.blit(text[0], text[1])
             if event.key == pygame.K_s:  # time speed down
                 if self.time > 0.6:
                     self.time -= 0.1
                     Sphere.time = self.time
                     text = set_text(
                         str(round(self.time, 1)) + 'x',
                         self.game.width // 2, self.game.height - 100, 50)
                     self.game.screen.blit(text[0], text[1])
         if not self.paused:
             if event.type == pygame.MOUSEBUTTONDOWN:
                 if event.button == 4:  # scroll up -> zoom in
                     if self.game.width / self.player.scaled_size() > 15:
                         self.scale += 0.1
                 if event.button == 5:
                     if self.scale > 0.1 and self.game.width / self.player.scaled_size(
                     ) < 40:
                         self.scale -= 0.1
                 if event.button == 1:
                     self.clicks += 50  #TODO Fix
                     # x, y = pygame.mouse.get_pos()
                     # # print((x-player.x)/player.size,(y-player.y)/player.size)
                     # print(get_trig(x - player.pos()[0],y -  player.pos()[1]))
                     # print(get_trig(player))
                     self.enemies.append(
                         self.player.accelerate(trig=get_trig(self.player),
                                                power=self.clicks // 30))
                 Sphere.scale = self.scale  # updates sphere scale property according to the desired zoom level
     return true
Пример #4
0
def main_menu(game: Properties):
    """
                main menu with level selector
    """
    while true:
        btn1 = pygame.Rect(((game.width - 200) // 2, 300, 200, 80))
        btn2 = pygame.Rect(((game.width - 200) // 2, 500, 200, 80))
        btn3 = pygame.Rect(((game.width - 200) // 2, 700, 200, 80))
        game.screen.fill((0, 0, 255))
        game.screen.blit(menu_background,(0,0))
        for event in pygame.event.get():
            if not general_interactions_handler(game, event):
                return false
            if event.type == pygame.MOUSEBUTTONDOWN:
                if event.button == 1:
                    x, y = pygame.mouse.get_pos()
                    if btn1.collidepoint((x, y)):
                        game.level = 1
                        return
                    if btn2.collidepoint((x, y)):
                        game.level = 2
                        return
                    if btn3.collidepoint((x, y)):
                        game.level = -1
                        return

        text0 = set_text("OSMOS REMIX", game.width // 2, 70, 50)
        text1 = set_text("Level 1", game.width // 2, 335, 20)
        text2 = set_text("Level 2", game.width // 2, 535, 20)
        text3 = set_text("Exit", game.width // 2, 735, 20)
        pygame.draw.rect(game.screen, (0, 255, 0), btn1)
        pygame.draw.rect(game.screen, (0, 255, 0), btn2)
        pygame.draw.rect(game.screen, (0, 255, 0), btn3)
        game.screen.blit(text0[0], text0[1])
        game.screen.blit(text1[0], text1[1])
        game.screen.blit(text2[0], text2[1])
        game.screen.blit(text3[0], text3[1])
        pygame.display.update()
        game.clock.tick(game.fps)
Пример #5
0
def first_update():
    score_str = "%010d" % score_mod.total
    text.set_text(score_id, score_str)

    player_id = player.player_id
    current_health = health.get_health(player_id)
    shield_str = ">" * current_health
    text.set_text(shield_id, "[%s]" % shield_str)

    requirement = player.get_next_upgrade_requirement()
    if requirement:
        collected_str = "%d" % (requirement - evoseed.collected)
    else:
        collected_str = "at maximum"
    text.set_text(progress_id, collected_str)

    text.set_text(weapon_id, player.current_weapon)
Пример #6
0
def update():
    if score_mod.new_score:
        score_str = "%010d" % score_mod.total
        text.set_text(score_id, score_str)

    player_id = player.player_id
    if player_id in health.damaged or player_id in health.healed:
        current_health = health.get_health(player_id)
        shield_str = ">" * current_health
        text.set_text(shield_id, "[%s]" % shield_str)

    if evoseed.collected_change or player.current_path_changed:
        requirement = player.get_next_upgrade_requirement()
        if requirement:
            collected_str = "%d" % (requirement - evoseed.collected)
        else:
            collected_str = "maximum"
        text.set_text(progress_id, collected_str)

    if player.current_weapon_changed:
        text.set_text(weapon_id, player.current_weapon)
Пример #7
0
def hide_text(action, text):
    text.set_text('', '')
Пример #8
0
from scene import Scene
from cocos.actions import *
import random
import common


def show_name(action, (name, text)):
    persons = {
        'hugoruscitti': ('Hugo Ruscitti', 'Programming', 320, 330),
        'cristian': ('Cristian Villalba', 'Programming and musics', 290, 230),
        'walter': ('Walter Velazquez', 'Art', 320, 350),
        'javi': ('Javier Da Silva', 'Art', 280, 340),
        }

    fullname, task, x, y = persons[name]
    text.set_text(fullname, task)
    text.set_position(x, y)


def hide_text(action, text):
    text.set_text('', '')

class About(Scene):
    
    def __init__(self, world):
        Scene.__init__(self, world)
        self.step = 0
        self._load_background()
        self.name = text.AboutText()
        self._create_sprites()