def on_join(self): import multiplayer import game game.start() game.Scene.add(multiplayer.join())
def test_intransitive_commands_should_not_throw_exceptions(self): for word in self.words: game = Game() load_advent_dat(game) game.start() game.do_command(['no']) # WOULD YOU LIKE INSTRUCTIONS? game.do_command([word])
def test_prompt(self): import game event.fire("setup") event.fire("adventure.setup") active_adventure.load_option("final_1") game.mode = "adventure" game.start()
def start(): try: side = int(request.form['side']) rows = int(request.form['rows']) game.start(side=side, rows=rows) return render_template("index.html") except: return jsonify({"message": "error"})
def test_mode(self): import game event.fire("setup") event.fire("dungeon.setup") hero.active_hero.has_sword = True hero.active_hero.has_shield = True game.mode = "dungeon" game.start(nosetup=True)
def start(): # For compatability reasons, i'm going to force pytality to be SDL only for this compo. pytality.term.init(backends=['pygame'], width=screen_width, height=screen_height) pytality.term.set_title('Untitled (Ludum Dare Jam #27: 10 Seconds)') pytality.term.set_cursor_type(2) pytality.term.clear() if '--no-sound' in sys.argv: sys.argv.remove('--no-sound') sound.no_sound = True if 'load-image' in sys.argv: # hack to view images easily import time import os import pygame while True: print "Updating" with open(sys.argv[-1]) as f: buf = pytality.ansi.read_to_buffer(f, width=80, crop=False) pytality.term.clear() buf.draw() pytality.term.flip() mtime = new_mtime = os.stat(sys.argv[-1]).st_mtime while new_mtime == mtime: if pygame.event.peek(pygame.locals.QUIT): sys.exit(0) pygame.event.pump() time.sleep(0.1) new_mtime = os.stat(sys.argv[-1]).st_mtime if 'test' in sys.argv: sys.argv.remove('test') import importlib import unittest unittest.main(importlib.import_module('gamelib.%s' % sys.argv[-1]), argv=['Test']) try: event.fire('setup') game.start() except game.GameShutdown: pytality.term.clear() except KeyboardInterrupt: pytality.term.clear() raise except Exception, e: log.exception(e) traceback.print_exc(e, file=sys.stderr) raise
def post(self, game_name): """ Vote to enter temple/advance to next round. """ player = self.get_player(game_name) if player: game.start(self.db_conn, game_name, player) self.set_status(204) else: self.set_status(400, 'You are not in this game') return self.render()
def test_generate(self): import dungeon import game event.fire("setup") event.fire("adventure.setup") #adventure.active_adventure.start_act() #adventure.active_adventure.start_act() #adventure.active_adventure.start_act() event.fire("dungeon.setup") game.mode = "boss" event.fire("boss.setup", dungeon.active_dungeon) game.start()
def main(): parser = argparse.ArgumentParser(description="P0 Adventure") parser.add_argument('--savefile', default="game.json", help="The save file. default: 'game.json'") parser.add_argument("--new-game", dest="new_game", default=False, action='store_true', help="Create a new save file.") parser.add_argument("-b", dest="bonus_tasks", default=False, action="store_true", help='enable bonus tasks') parser.add_argument("--print-bonus", dest="print_bonus", default=False, action="store_true", help='print bonus task list and exit') args = parser.parse_args() game.start(args)
def on_start(self): import game game.start() player = entity.get_entity_type("player")() player.position.x, player.position.y = (10, 10) game.Game.spawn(player, force=True) game.Game.set_player(player.eid) player.controlled_by = player.eid bow = entity.get_entity_type("BasicMeleeWeapon")(player) player.weapon = bow
def parse_options(): """ Parse all command line options and arguments and return them as a dictionary. """ parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter) parser.add_argument("-v", "--version", action="version", version=VERSION) parser.add_argument("-i", "--info", dest="info", action="store_true", default=False, help="info about the game") parser.add_argument("-a", "--about", dest="about", action="store_true", default=False, help="info about the game's author") parser.add_argument( "-c", "--cheat", dest="cheat", action="store_true", default=False, help="gives you the shortest route to completing the game") args, unknownargs = parser.parse_known_args() readOut = "" for arg in vars(args): if vars(args)[arg]: readOut = arg if readOut: with open("schema/info.json") as jsonData: data = json.load(jsonData) for item in data[readOut]: print(item) if not len(sys.argv) > 1: game.start() options["known_args"] = vars(args) options["unknown_args"] = unknownargs return options
def play(): print("Going to the Game...\n\n") game.start() file=open("gnav.txt") nav=file.read() file.close() if nav=="1": os.system('cls') score() elif nav=="2": os.system('cls') main() else: os.system('cls') main()
def on_host(self): import multiplayer import game game.start() game.Scene.add(multiplayer.host()) player = entity.get_entity_type("player")() player.position.x, player.position.y = (200, 200) game.Game.spawn(player) game.Game.set_player(player.eid) bow = entity.get_entity_type("BasicBow")(player) player.weapon = bow
def main(): log.debug('Starting up') term.init() term.settitle('Mutants Of Melimnor (PyWeek #13: Mutate!)') try: event.fire('setup') game.start() except game.GameShutdown: term.reset() except KeyboardInterrupt: term.reset() raise except Exception, e: log.exception(e) raise
async def onCommand(self, channel, command, args): if command == "start": if game.start("scenario_00_basic.lua", ""): await channel.send('Started server, game paused.') else: await channel.send('Failed to start (server already running?)') elif command == "stop": if game.stop(): await channel.send('Stopped the server') else: await channel.send('Failed to stop the server') elif command == "pause": if game.pause(): await channel.send('Paused the game') else: await channel.send('Failed to pause the game') elif command == "unpause": if game.unpause(): await channel.send('Unpaused the game') else: await channel.send('Failed to unpause the game') elif command == "help": await channel.send('Available commands: start stop pause unpause') else: await channel.send('Unknown command: %s' % (command))
def main(): os.environ["SDL_VIDEO_CENTERED"] = "1" pygame.init() jukebox = music.JukeBox() level = 'menu.txt' was_menu = True fullname = os.path.join('data', 'save', 'save.txt') first_time = False try: f = open(fullname, 'r') except: first_time = True f = open(fullname, 'w') f.close() while level: if level == 'menu.txt': was_menu = True else: was_menu = False first_time = data.first_time(level) level = game.start(jukebox, level, first_time) first_time = False if level == None and not was_menu: level = 'menu.txt' pygame.quit()
def main(): pytality.term.init(width=state.width, height=state.height) pytality.term.set_title('Dungeon Game (LD48 #22: Alone)') try: event.fire('setup') game.start() except game.GameShutdown: pytality.term.reset() except KeyboardInterrupt: pytality.term.clear() pytality.term.reset() raise except Exception, e: log.exception(e) raise
def main(): global surface,FPSCLOCK pygame.init() surface = pygame.display.set_mode((WINDOWWIDTH,WINDOWHEIGHT)) FPSCLOCK = pygame.time.Clock() graphics.init(surface) board = [] for i in range(BOARDROWS): board.append([BLANK]*BOARDCOLS) assert len(board) == BOARDROWS for i in range(BOARDROWS): assert len(board[i]) == BOARDCOLS board[0][0] = TYPE_O board[0][1] = TYPE_O board[1][0] = TYPE_O board[1][1] = TYPE_O board[5][5] = TYPE_I board[6][5] = TYPE_I board[7][5] = TYPE_I board[8][5] = TYPE_I game.start() while (True): if game.checkGameEnd(): print 'the game has ended!!' FPSCLOCK.tick(FPS) continue for event in pygame.event.get(QUIT): terminate() for y in range(BOARDROWS): for x in range(BOARDCOLS): print game.board[y][x], print '' print 'number of pieces: ',len(game.getPieces()) #graphics.drawBoard(board) graphics.reset() for piece in game.getPieces(): # print 'drawing a piece!!!' print piece graphics.drawPiece(piece) graphics.drawStatus(1000,20) pygame.display.update() game.update() FPSCLOCK.tick(FPS)
def test_boxes(self): import game game.mode = 'test' root = pytality.buffer.Buffer(width=0, height=0) for i, cls in enumerate(all_types): p = cls(x=1 + i*17, y=20) clickable.register(p) root.children.append(p) @event.on('test.tick') def on_tick(): for child in root.children: child.tick() @event.on('test.draw') def on_draw(): root.draw() game.start()
def show_options(): while True: clear_screen() # mc_prompt = multichoice prompt option = mc_prompt('What would you like to do?', choices=['play', 'github', 'quit']) # start game if option == 0: start() # open github repo elif option == 1: webbrowser.open('https://github.com/ninest/military-sim') # quit program completely elif option == 2: clear_screen() sys.exit()
def test_buttons(self): import game game.mode = 'test' p = ClickableBox(x=10, y=20, width=10, height=5, border_fg=pytality.colors.DARKGREY) p2 = ClickableBox(x=20, y=20, width=5, height=5, border_fg=pytality.colors.DARKGREY, hover_border_bg=pytality.colors.WHITE) register(p) register(p2) def mouse_down(x, y): p2.mouse_out(x, y) unregister(p2) p2.mouse_down = mouse_down @event.on('test.draw') def on_draw(): p.draw() p2.draw() game.start()
def main(): if len(sys.argv) > 1: pytality.term.init(backends=sys.argv[1:], width=screen_width, height=screen_height) else: pytality.term.init(width=screen_width, height=screen_height) pytality.term.set_title('The Battle For 35 Leukothea (LD48 #23: Tiny World)') pytality.term.clear() try: event.fire('setup') game.start() except game.GameShutdown: pytality.term.reset() except KeyboardInterrupt: pytality.term.clear() pytality.term.reset() raise except Exception, e: log.exception(e) raise
def main(): # Creamos la ventana pasandole como parametros una tupla con los valores # del Alto y ancho definidos para definir las dimensiones de la ventana. screen = pygame.display.set_mode((WIDTH, HEIGHT)) # Definimos el titulo de la ventana. pygame.display.set_caption("Pong Game") cover_image = load_image('images/cover.jpg') sprite_text, sprite_text_rect = get_text("PRESS ANY BUTTON", WIDTH / 2, (HEIGHT * 6) / 8) while True: is_close() screen.blit(cover_image, (0, 0)) screen.blit(sprite_text, sprite_text_rect) for event in pygame.event.get(): if event.type == pygame.KEYDOWN: start(screen) break pygame.display.flip() return 0
def main(): #Intro screen print("Welcom to my rogue like game") print("Please select what you would like to do") sleep(0.5) print("1, New Game") sleep(0.5) print("2, Load Game") sleep(0.5) print("3, Exit Game") sleep(0.5) enter = input("Choice:") enter = int(enter) if enter == 1: #New Game clear() sleep(2) game.start() clear() main() elif enter == 2: #Load Game pass elif enter == 3: #Exit option return ()
sys.exit() if event.type is KEYDOWN and event.key is K_s: selected = selected + 1 if event.type is KEYDOWN and event.key is K_w: selected = selected - 1 #--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- if gamemode is GameMode.error: DISPLAYSURF.blit(cover, (0, 0)) # --STUB-- If a fatal error occurs, this will be like the # blue screen of death or something, telling you what's up, # throwing some error codes and dumping it to a file & etc. #--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- if gamemode is GameMode.playing: gamemsg = game.start() if gamemsg is 'PAUSE': gamemode = GameMode.paused elif gamemsg is 'DIE': gamemode = GameMode.gameover #--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- if gamemode is GameMode.gameover: DISPLAYSURF.blit(gameoverscreen, (0,0)) writescreen('Yes',(25,175)) writescreen('No',(25,200)) if event.type is KEYDOWN and event.key is K_RETURN: if selected is 1: gamemode = GameMode.playing if selected is 2: pygame.quit() sys.exit()
def do_play(): global current_user game.start(current_user) tui.clear() tui.print_menu(rest.get_current_user_amount(), current_user)
print (""" WELCOME TO THE BREAKER-STATION V. 2.0 ======================================= MENU 1 ===> Ahorcado 2 ===> Reglas 3 ===> Funciones 4 ===> Salir """) menu_option = input("Opción: ") menu_option = menu_option.upper() if (menu_option=='1'): import game fer = game.start(); if(fer != False): msg = ("Ganaste esta ronda") else: msg = ("Perdiste la ronda") chose ==True elif(menu_option=='2'): import rules rules.show() chose ==True elif(menu_option=='3'): import functions functions.show() chose ==True elif(menu_option=='4' or menu_option=="Salir" or menu_option=="salir" or menu_option=="SALIR"): break
def test_moraledefeat(self): import game event.fire("moraledefeat.setup") game.mode = "defeat" game.start()
def run(self): """Run the game thread""" from game import start start(get_input, update_textbox, set_choices, mark_temporary, clear_temporary, is_running, set_caption, check_hotkeys, disable_hotkeys, enable_hotkeys, set_dead)
def start(screen, client, id, server=None): game = game.Game(screen, client, id) game.start()
# этот модуль нужно импортировать именно тут, # т.к. в нём происходит загрузка звуков (а это можно делать только # после инициализации pygame.mixer) from UI import start_screen # Экран (он же будет использован везде) screen = pygame.display.set_mode(flags=pygame.FULLSCREEN) # этот модуль нужно импортировать именно тут, # т.к. в нём происходит загрузка изображений (а это можно делать только # после установки экрана выше) import game # Вызов начального экрана code = start_screen.execute(screen) # Словарь с действиями, которые зависят от кода из главного меню ACTIONS = { 1: lambda: game.start(screen), # TODO: 2: lambda: None, # TODO: 3: lambda: None, # так и должно быть, т.к. это выход из игры -1: lambda: None, } # Выполнение действия по коду ACTIONS[code]() # Закрытие pygame pygame.quit()
def main(): game.start()
import game game = game.Game() game.start()
from game import start as start from story import game as go player, characters, items = start() go(player, characters, items)
import game if __name__ == "__main__": play_time = int(input("Enter the amount of times you want to play: ")) n_wins, n_loss, n_draw = game.start(play_time) if n_wins > n_loss: print(""" ######## GAME ENDED! ######## ######## YOU WIN! ######## """) elif n_wins < n_loss: print(""" ######## GAME ENDED! ######## ######## YOU LOSE! ######## """) elif n_wins == n_loss: print(""" ######## GAME ENDED! ######## ######## TIE! ######## """) else: print(""" ######## GAME ERROR! ######## """) print("Wins:", n_wins) print("Loss:", n_loss) print("Draws:", n_draw) # Group members: Darren, Ellyz, Karsten, Vania
import game import pygame import eventos from constants import * from resources import * from player import * from tile import * from tilemap import * from tileset import * from camera import * from gamelogic import * from controlled_character import * # Game starts! game.start(DISP_W*2, DISP_H*2) resourcesMonos = Resources('graphics/arc22.png') resourcesSerpiente = Resources('graphics/arc23.png') player = Player(40, 40, pygame.Rect(0,0,15,35), resourcesMonos.player) ai = ControlledCharacter(100, 40, pygame.Rect(0,0,15,35), resourcesMonos.player) ai2 = ControlledCharacter(120, 40, pygame.Rect(0,0,15,35), resourcesMonos.player) ai3 = ControlledCharacter(128,448,pygame.Rect(0,0,15,35), resourcesSerpiente.player) tilemap = Tilemap() tilemap.load_tilesets('map1.json') tilemap.load_map('map1.json') camera = Camera(0, 0, player, [player,ai,ai2,ai3], tilemap, True, 0.25) gamelogic = Gamelogic([player,ai,ai2,ai3], tilemap) clock = game.clock() #pygame.mixer.init() #pygame.mixer.music.load("sound/hyperfun.mp3")
def main(): Home.start() Game.start() print("{} fez {} ponto(s)!".format(Home.player, Game.COUNT)) Home.writeRanking(Home.player, Game.COUNT) Home.printRanking()
import grab, crop, game if __name__ == '__main__': img = grab.get_img("img.jpg") w, h = map(int, crop.crop(img, 3, 3)) game.start((w, h))
def task_three(): print("Task Three") game.file_exists() game.start() game.reset()
def test_victory(self): import game event.fire("victory.setup") game.mode = "victory" game.start()
def main(): init( strategy=args.strategy, used_map=args.map ) start()
import game game = game.Game() game.add_player(1) game.add_player(2) game.add_player(3) game.add_player(4) game.add_player(5) game.add_player(6) game.add_player(7) game.start() game.input(1, "u", "pressed") for _ in range(50): print(game.tick()) game.input(1, "u", "r") game.input(1, "d", "pressed") game.input(1, "", KeyAction.PRESSED) for i in range(25): print(game.tick()) y_pos = 0 while y_pos > -2490: x = game.tick() y_pos = x[0][1]['position'][1] print(y_pos) print(x)
def main(): """ Main """ game.start()
code = -1 while code != 0: # Вызов начального экрана code = start_screen.execute(screen) # Выполнение действия по коду if code != 0: # Сид сохранения, который будет считан при запуске игры seed = None # Номер уровня с которого начнётся игра level_number = 1 # Читаем файл сохранения, если он существует if os.path.isfile("data/save.txt"): with open('data/save.txt', 'r', encoding="utf-8") as file: seed = ' '.join(file.readlines()) # Если seed пустой, то присваем ему None if not seed: seed = None else: data = seed.split('\n') seed, level_number = '\n'.join(data[:-1]), int(data[-1]) # Результат того, чем закончилась игра code = game.start(screen, level_number=level_number, user_seed=seed) # Закрытие pygame pygame.quit() pygame.mixer.quit()
def load_map(self, path): json_data = open(path) data = json.load(json_data) self.current_height = data['height'] self.current_width = data['width'] self.current_map = [] map_data = data['layers'][0]['data'] for i in range(self.current_height): row = [] for j in range(self.current_width): row.append(map_data[i * self.current_width + j]) self.current_map.append(row) game.start(DISP_W, DISP_H) t = Tilemap() t.load_tilesets('map-sm.json') t.load_map('mapa-sm2.json') clock = game.clock() #pygame.mixer.init() #pygame.mixer.music.load("sound/hyperfun.mp3") #pygame.mixer.music.play(100) # Gameloop while True: events = game.get_events()
from game import start start()
import game import pygame from constants import * from resources import * from player import * from tile import * from tilemap import * from tileset import * from camera import * from gamelogic import * from controlled_character import * # just a comment another one # Game starts! game.start(DISP_W * 2, DISP_H * 2) resources = Resources() moving_actors = [] player = Player(40, 40, pygame.Rect(0, 0, 15, 35), resources.funky_ninja, moving_actors) ai = ControlledCharacter(100, 40, pygame.Rect(0, 0, 15, 35), resources.ninja1) ai2 = ControlledCharacter(120, 40, pygame.Rect(0, 0, 15, 35), resources.ninja) ai10 = ControlledCharacter(40, 40, pygame.Rect(0, 0, 15, 35), resources.blue_guy) #blue_guy1 = ControlledCharacter(80, 40, pygame.Rect(0,0,15,35), resources.blue_guy) tilemap = Tilemap() tilemap.load_tilesets('map1.json') tilemap.load_map('map1.json')
import game import dealer from copy import deepcopy game.verbose = False board = game.start() #game.output_board(board) game.print_board(board) def recurse(board, moves): #print(len(moves)) if game.has_won(board): print(len(moves), " moves") print(moves) exit() elif len(moves) > 200: print("ERR?") print(moves) return if len(moves) == 52: print(".", end='') # Head all for from_stack in range(len(board.stacks)): f = deepcopy(board) if game.to_head(f, from_stack): new_moves = deepcopy(moves) new_moves.append(f"h {from_stack}") recurse(f, new_moves)
def test_run(self): import game event.fire("dunsany.setup") game.mode = "dunsany" game.start()