コード例 #1
0
def change_game_state():
    gs = globals.game_state_label

    if gs == globals.MAIN_MENU:
        globals.game_state = Mainmenu()
    elif gs == globals.RUNNING:
        globals.game_state = Game()
    elif gs == globals.GAME_OVER:
        globals.game_state = Gameover()
コード例 #2
0
ファイル: gluttonous.py プロジェクト: Antastsy7/gluttonous
    def __init__(self):
        super(HelloWorld, self).__init__()
        self.arena = Arena()
        self.add(self.arena)
        self.score = cocos.text.Label('30',
                                      font_name='Times New Roman',
                                      font_size=24,
                                      color=define.GOLD)
        self.score.position = 20, 440
        self.add(self.score, 99999)

        self.gameover = Gameover()
        self.add(self.gameover, 100000)
コード例 #3
0
    def __init__(self):
        super(HelloWorld, self).__init__()
        self.arena = Arena()  # 创建Arena对象
        self.add(self.arena)  # 添加Arena对象
        self.score = cocos.text.Label('30',
                                      font_name='Times New Roman',
                                      font_size=24,
                                      color=define.GOLD)  # 设置得分面板的格式
        self.score.position = 20, 440  # 设置得分面板的位置
        self.add(self.score, 99999)  # 加入得分面板并设置Z轴位置为99999

        self.gameover = Gameover()  # 创建Gameover对象
        self.add(self.gameover, 100000)  # 加入Gameover对象
コード例 #4
0
 def __init__(self):
     pygame.init()
     self.ai_settings = Settings()
     self.screen = pygame.display.set_mode(
         (self.ai_settings.screen_width, self.ai_settings.screen_height))
     pygame.display.set_caption("Super Mario Bros Clone")
     self.mario_player = Mario(self.ai_settings, self.screen)
     self.map = Map(self.ai_settings,
                    self.screen,
                    mapfile='Levels/first_level.txt',
                    blockfile='Images/block_tile.png')
     self.stats = GameStats()
     self.scoreboard = Scoreboard(self.ai_settings, self.screen, self.stats)
     self.clock = pygame.time.Clock()
     self.gameover = Gameover(self.ai_settings, self.screen, self.stats)
コード例 #5
0
 def step(self, char):
     self.machine.input(char)
     if (self.next < time()):
         self.machine.step()
         self.next = time() + (1.0 / self.FPS)
     self.machine.draw(self.driver)
     if (self.machine.nextState):
         state = self.machine.nextState
         if (state == "snake"):
             self.machine = Snake()
         elif (state == "gameover"):
             self.machine = Gameover()
         elif (state == "menu"):
             self.machine = Menu()
         elif (state == "quit"):
             self.machine = False
コード例 #6
0
    def __init__(self):
        '''初始化游戏并创建游戏资源'''
        pygame.init()
        self.settings = Settings()

        self.screen = pygame.display.set_mode(
            (self.settings.screen_width, self.settings.screen_height))
        pygame.display.set_caption('外星人入侵')
        # 设置游戏背景颜色
        self.bg_color = self.settings.bg_color

        # 实例化飞船,并将主程序作为对象传入
        self.ship = Ship(self)
        # 实例化子弹编组
        self.bullets = pygame.sprite.Group()
        # 实例化外星人编组
        self.aliens = pygame.sprite.Group()
        self._create_fleet()

        self.status = GameStatus(self)
        self.gameover = Gameover(self)
コード例 #7
0
 def end_game(self):
     self.stream.stop_stream()
     self.pause_scheduler()
     # self.unschedule(self.update)
     self.gameover = Gameover(self)
     self.add(self.gameover, 100000)
コード例 #8
0
from game import Game
from state import State
from splash_state import SplashScreen
from menu import Menu
from level_01 import Level_01
from level_02 import Level_02
from level_03 import Level_03
from gameover import Gameover

#########################
#          Main         #
#     Entry Point       #
#########################

if __name__ == "__main__":
    pg.init()
    screen = pg.display.set_mode((800, 600))
    states = {
        "SPLASH": SplashScreen(),
        "MENU": Menu(),
        "LEVEL_01": Level_01(),
        "LEVEL_02": Level_02(),
        "LEVEL_03": Level_03(),
        "GAMEOVER": Gameover()
    }

    game = Game(screen, states, "SPLASH")
    game.run()
    pg.quit()
    sys.exit()
コード例 #9
0
pygame.key.set_repeat(75)

while 1:
    area = Area(width - 100, height)

    tetrino_queue = []

    for i in range(5):
        tetrino_queue.append(randint(0, 6))

    tetrino_color = (randint(1, 255), randint(1, 255), randint(1, 255))

    tetrino = Tetrino(tetrino_color, tetrino_queue[0])

    hud = Hud(width, height)
    gameOver = Gameover(width, height, area.score)

    screen.fill((0, 0, 0))
    hud.draw_hud(screen)
    menu = Menu(width, height, (255, 255, 255), (0, 0, 0))
    menu.draw_menu(screen)
    menu.update_menu(screen)
    pygame.display.flip()
    core = Core(tetrino, area, menu, screen)
    core.menu_input()

    init = 1000
    start_time = pygame.time.get_ticks()

    while menu.singlePlayer and tetrino.game_state:
        core.check_input()