当前位置: 首页>>代码示例>>Python>>正文


Python Game.run方法代码示例

本文整理汇总了Python中Game.Game.run方法的典型用法代码示例。如果您正苦于以下问题:Python Game.run方法的具体用法?Python Game.run怎么用?Python Game.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game.Game的用法示例。


在下文中一共展示了Game.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_onmouseclick

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
 def start_onmouseclick(self, event):
     self.start.onmouseclick(event)
     self.on_exit()
     game = Game()
     game.run()
     self.start.onmouseclickup(event)
     self.on_enter()
开发者ID:reality3d,项目名称:molefusion,代码行数:9,代码来源:MainMenu.py

示例2: test

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
def test():
    abilities = [AbilitiesAbility(), TruthtellAbility(), SaveAbility(), KillAbility(), CoerceAbility(), StealAbility()]
    abilityNames = map(lambda a: a.getName(), abilities)

    samira = Player("Samira", "[email protected]", Character("Char",[], abilityNames, "desc"))
    will = Player("Will", "[email protected]", Character("Char",[], abilityNames, "desc"))
    players = [None, will]

    game = Game(abilities, players)
    game.run()
开发者ID:fimad,项目名称:TextToKill,代码行数:12,代码来源:Test.py

示例3: game_looper

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
def game_looper(level):
	game = Game(level)
	result  = 0
	while not result == -5:
		result = game.run()
		again = 'n'
		if result == -1:
			print 'You were crushed'
			again = raw_input('Try again? (Y/N): ')
		elif result == -2:
			print 'You fell to your death'
			again = raw_input('Try again? (Y/N): ')
		else:
			print 'You escaped that room!'
			again = result
		if again:
			if again[0] == 'N' or again[0] == 'n':
				break
			elif again[0] == 'Y' or again[0] == 'y':
				game = Game(level)
			elif result != -1 and result !=-2:
				game = Game(again)
			else:
				break
		else:
			break
开发者ID:chaseberry,项目名称:DungeonJumper,代码行数:28,代码来源:run.py

示例4: main

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
def main():
    
       
    game = Game()
    
    game.run()
开发者ID:osgcc,项目名称:osgcc4-ReleaseTheKraken,代码行数:8,代码来源:Main.py

示例5: Game

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
#!/usr/bin/python

from Game import Game

game = Game()
game.run()
开发者ID:mhendren,项目名称:Tic-Tac-Toe,代码行数:8,代码来源:Main.py

示例6: play

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
def play():
    game = None
    game = Game(screen, inputs)
    return game.run()
开发者ID:mortie,项目名称:zonelauncher,代码行数:6,代码来源:multipong.py

示例7: get_board_params

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
def get_board_params(args=sys.argv):
    if len(args) != 4:
        return (None, None, None)
    arg1, arg2, arg3 = args[1:4]
    try:
        return_value = (int(arg1), int(arg2), int(arg3))
        if any(map(lambda x: x <= 0, return_value)):
            return (None, None, None)
        return return_value
    except ValueError:
        return (None, None, None)

if __name__ == "__main__":
    x, y, bombs = get_board_params()
    if not any([x, y, bombs]):
        print "Usage: python GameRunner.py <x-dimension> <y-dimension> <# of bombs>"
        sys.exit(-1)
    try:
        game = Game(x, y, bombs)
    except InvalidBoardException as e:
        print "Too many bombs: Board size is %d, bombs specified is %d" % (
            e.spaces, e.bombs)
        sys.exit(-1)

    victory_status = game.run()
    print game.board
    if victory_status:
        print "You win!"
    else:
        print "You lose, try again"
开发者ID:CaptainMaximum,项目名称:Minesweeper-TDD,代码行数:32,代码来源:GameRunner.py

示例8: main

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
def main():
  game  = Game()
  scene = SceneMenu(game)
  game.set_scene(scene)
  game.run()
开发者ID:doctordesh,项目名称:pygame-pong,代码行数:7,代码来源:main.py

示例9: run

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
    def run(self):
        self.camera = 0
        lastTime = jngl.getTime()
        needDraw = True
        timePerStep = 0.01
        counter = 0
        fps = 0
        self.box = None
        self.port1 = None

        while jngl.running():
            x = jngl.getMouseX() - self.camerax
            y = jngl.getMouseY() - self.cameray
            if self.gridEnabled:
                x = int(x / self.gridSize) * self.gridSize
                y = int(y / self.gridSize) * self.gridSize
                if self.box:
                    x += self.gridSize
                    y += self.gridSize
            if jngl.getTime() - lastTime > timePerStep:
                lastTime += timePerStep
                needDraw = True
                if jngl.keyDown("z"):
                    if not self.zoom:
                        self.camerax += self.windowWidth / 2
                        self.cameray += self.windowHeight / 2
                        self.zoom = True
                    # self.gridEnabled = False
                    self.scale = 0.5
                elif self.zoom:
                    self.zoom = False
                    self.camerax -= self.windowWidth / 2
                    self.cameray -= self.windowHeight / 2
                jngl.scale(self.scale)
                self.scale = 1
                if jngl.keyPressed("s"):  # and jngl.keyDown(jngl.key.ControlL):
                    jngl.hideWindow()
                    file = asksaveasfile(mode="wb", defaultextension=".slv", filetypes=[("Somyeol Level", "*.slv")])
                    if file != None:
                        self.level.saveLevel(file)
                        file.close()
                    self.showWindow()

                if jngl.keyPressed("g"):
                    self.toggleGrid()

                if jngl.keyPressed(jngl.key.ControlL) and jngl.keyPressed("n"):
                    self.camerax = 0
                    self.cameray = 0
                    self.level = Map.Map()
                    self.gridEnabled = True
                    self.add10 = False
                    self.scale = 1
                    self.zoom = False

                if jngl.keyPressed("l"):  # and jngl.keyDown(jngl.key.ControlL):
                    jngl.hideWindow()
                    self.level.loadLevel()
                    self.showWindow()

                if jngl.keyPressed("i"):
                    self.addImage(x, y)

                if jngl.keyPressed("t"):
                    jngl.hideWindow()
                    from Game import Game

                    game = Game()
                    tempMap = copy.deepcopy(self.level)
                    game.setMap(tempMap)
                    game.enable_credits = False
                    game.testmode = True
                    game.run()
                    jngl.hideWindow()
                    self.showWindow()
                if jngl.keyPressed("m"):
                    self.add10 = not self.add10

                # Change the Placeable
                if jngl.mousePressed(jngl.mouse.Right) or jngl.keyPressed(jngl.key.PageUp):
                    self.box = None
                    self.port1 = None
                    self.placeable_count += 1
                    if self.placeable_count >= len(self.placeable):
                        self.placeable_count = 0

                if jngl.keyPressed(jngl.key.PageDown):
                    self.box = None
                    self.port1 = None
                    self.placeable_count -= 1
                    if self.placeable_count < 0:
                        self.placeable_count = len(self.placeable) - 1

                for i in range(len(self.quickselect) - 1):
                    if jngl.keyPressed(self.quickselect[i]):
                        self.box = None
                        self.port1 = None
                        self.placeable_count = i % (len(self.placeable))

                if jngl.mousePressed(jngl.mouse.Middle) or jngl.keyPressed(jngl.key.Delete):
#.........这里部分代码省略.........
开发者ID:jhasse,项目名称:somyeol2d,代码行数:103,代码来源:LevelEditor.py

示例10: Game

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
from Game import Game

g = Game()

g.run()

#g.exit()
开发者ID:bsautron,项目名称:ft_minirogue,代码行数:9,代码来源:main.py

示例11: main

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
def main():
    """ Main Program """
    pygame.init()

    # Set the height and width of the screen
    size = [constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT]
    screen = pygame.display.set_mode(size)

    pygame.display.set_caption("(Alpha) No More Pixies")
    main_loop = True
    first = True
    level_dif = "" #difficulty level chosen
    player = None #character chosen
    level_nbr = 0 #level number chosen
    slot = '' #choix de la sauvegarde
    # nmp_data = Data("gamedata.txt")
    nmp_data = Data("gamedata_dev.txt", "A,2,2,6,2\nB,0,0,6,0\nC,1,1,6,1\n") #slot A has everything already unlocked for dev purpose
    choices = None #choices for the different menus

    while main_loop:
        if constants.GAME_STATUS == "menuDiff":
            from DifficultyMenu import DifficultyMenu

            #DIFFICULTY SELECTION MENU
            background_image = pygame.image.load("data/back.jpg").convert()
            screen.blit(background_image, [0, 0])
            menu = DifficultyMenu()

            if nmp_data.unlocked_skills == 0:
                choices = ['Princess']
            elif nmp_data.unlocked_skills == 1:
                choices = ['Princess','Little Boy']
            else:
                choices = ['Princess','Little Boy','Death Wish']

            menu.init(choices, screen)
            menu.draw()
            pygame.key.set_repeat(199,69)#(delay,interval)
            pygame.display.update()
            level_dif = menu.run(joystick)

        elif constants.GAME_STATUS == "menuChar":
            from characters.Bob import Bob
            from characters.Hulk import Hulk
            from characters.LittleFat import LittleFat
            from CharacterMenu import CharacterMenu

            #CHARACTER SELECTION MENU
            menu = CharacterMenu(screen,nmp_data.unlocked_chars)
            selected = menu.run(joystick)
            # player = None
            if selected == 0:
                player = Bob()
            elif selected == 1:
                player = Hulk()
            elif selected == 2:
                player = LittleFat()

            if player != None:
                player.lives = nmp_data.remaining_lives

        elif constants.GAME_STATUS == "menuLevel":
            #LEVEL SELECTION MENU
            from LevelMenu import LevelMenu
            background_image = pygame.image.load("data/back.jpg").convert()
            screen.blit(background_image, [0, 0])
            menu = LevelMenu()

            if nmp_data.unlocked_stages == 0:
                choices = ['Level 1']
            elif nmp_data.unlocked_stages == 1:
                choices = ['Level 1','Level 2']
            else:
                choices = ['Level 1','Level 2','Level 3']

            menu.init(choices, screen)
            menu.draw()
            pygame.key.set_repeat(199,69)#(delay,interval)
            pygame.display.update()
            level_nbr = menu.run(joystick)

        elif constants.GAME_STATUS == "level":
            from Game import Game
            # Create all the levels
            game = Game(player,level_nbr,level_dif,screen,joystick,nmp_data)
            game.run()

        elif constants.GAME_STATUS == "menuSave":
            from SaveMenu import SaveMenu
            background_image = pygame.image.load("data/back.jpg").convert()
            screen.blit(background_image, [0, 0])
            menu = SaveMenu()
            menu.init(['Slot A','Slot B','Slot C'], screen)
            menu.draw()
            pygame.key.set_repeat(199,69)#(delay,interval)
            pygame.display.update()
            slot = menu.run(joystick)
            nmp_data.slot = slot
            nmp_data.load_data()#prepare the data to load for other menus

#.........这里部分代码省略.........
开发者ID:Mizua,项目名称:game_project,代码行数:103,代码来源:NMP.py

示例12: runGame

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
 def runGame(self):
     game = Game(self.startX, self.startY)
     game.run()
     print("self.level:", self.level)
     self.setScoreList(game.score, self.level)
     self.run()
开发者ID:xiaokelunjian,项目名称:15112-Term-Project-Honey-Collector,代码行数:8,代码来源:Main.py

示例13: main

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
def main():
    pygame.init()
    game = Game()
    game.run()
开发者ID:hoffa2,项目名称:mayhemclone,代码行数:6,代码来源:testmain.py

示例14: print

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
    for option in options:
        if option.rect.collidepoint(pygame.mouse.get_pos()):
            option.hovered = True
        else:
            option.hovered = False
        option.draw()
    pygame.display.update()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            # for el in text:
            done = True
        elif event.type == pygame.MOUSEBUTTONDOWN:
            pos = pygame.mouse.get_pos()
            print(pos)
            if pos[0] > 140 and pos[0] < 140 + 330 and pos[1] > 155 and pos[1] < 155 + 60:
                new_txt = game.run()
                for i in range(0, 10):
                    if int(text[i]["name"]) < int(new_txt):
                        a = text[i]["name"]
                        text[i]["name"] = new_txt
                        rewrite(text, i, a)
                        break
                json.dump(text, open('Recoreds.json', "w"))
                print(text)
            elif pos[0] > 135 and pos[0] < 135 + 276 and pos[1] > 255 and pos[1] < 255 + 60:
                print('optg')
            elif pos[0] > 140 and pos[0] < 140 + 280 and pos[1] > 355 and pos[1] < 355 + 60:
                run_rec(text)
            elif pos[0] > 145 and pos[0] < 145 + 140 and pos[1] > 455 and pos[1] < 455 + 60:
                done = True
开发者ID:PeshkovDanil,项目名称:Game1,代码行数:32,代码来源:fhs.py

示例15:

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import run [as 别名]
            if event.key == pygame.K_q:
                game.player.alive = False

    # control the game state
    # an object will always return its own state
    # number unless input events set otherwise
    if state == home_state:
        state = home.run(event_list)
        player.reset()
        health_bar.reset(player)
        game.reset(player)
        shop.reset(player, health_bar)
    elif state == info_state:
        state = info.run(event_list)
    elif state == game_state:
        state = game.run(event_list)
    elif state == pause_state:
        state = paused.run(event_list)
    elif state == shop_state:
        state = shop.run(event_list)
    elif state == settings_state:
        state = settings.run(event_list)
    elif state == game_over_state:
        state = game_over.run(event_list)
    elif state == reset_game_state:
        player.reset()
        game.reset(player)
        shop.reset(player)
        state = game_state
    elif state == quit_state:
        running = False
开发者ID:YJoe,项目名称:SpaceShips,代码行数:33,代码来源:Loop.py


注:本文中的Game.Game.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。