def CharCreation(): Con = 5; Agi = 5; Pwr = 5; Stg = 5; Itl = 5; free_points = 20 while 1: gui.win.setscreencolors(None, None, True) gui.win.putchars('New Character', 0, 0, fgcolor=pygame.Color(255,255,255)) # Con Agi Pwr Stg Itl # options = ['Constitution:', 'Agility:', 'Power:', 'Strength:', 'Intelligence:'] gui.menu([gui.header('Base Skills:', pygame.Color(170, 170, 170))], options, 3, width=0) gui.win.putchars('Press the letter to increment; Press SHIFT + the letter to decrement.', 0, gui.WIN_HEIGHT - 2, pygame.Color(170, 170, 170)) gui.win.putchars('Press \'>\' to continue', 0, gui.WIN_HEIGHT - 1, pygame.Color(0,0,255)) gui.win.putchars('Free Skill Points Remaining: ' + str(free_points), gui.WIN_WIDTH // 2, 3, pygame.Color(0,170,0)) gui.win.putchars(str(Con), 25, 6) gui.win.putchars(str(Agi), 25, 7) gui.win.putchars(str(Pwr), 25, 8) gui.win.putchars(str(Stg), 25, 9) gui.win.putchars(str(Itl), 25, 10) gui.win.update() gui.win.blittowindow() choice = handle_keys() if choice == 'a' and free_points > 0: Con += 1 free_points -= 1 elif choice == 'b' and free_points > 0: Agi += 1 free_points -= 1 elif choice == 'c' and free_points > 0: Pwr += 1 free_points -= 1 elif choice == 'd' and free_points > 0: Stg += 1 free_points -= 1 elif choice == 'e' and free_points > 0: Itl += 1 free_points -= 1 elif choice == 'A' and Con > 5: Con -= 1 free_points += 1 elif choice == 'B' and Agi > 5: Agi -= 1 free_points += 1 elif choice == 'C' and Pwr > 5: Pwr -= 1 free_points += 1 elif choice == 'D' and Stg > 5: Stg -= 1 free_points += 1 elif choice == 'E' and Itl > 5: Itl -= 1 free_points += 1 elif choice == '>': gen.player_cognitive = ait.Cognitive(Con, Agi, Pwr, Stg, Itl) gui.win.setscreencolors(None, None, True) ait.game_state = 'normal' game = Game()
def __init__(self, flags=None): global mp mp = gen.init() if flags == 'debug': for y in range(gui.MAPHEIGHT): for x in range(gui.MAPWIDTH): mp[x][y].explored = True debug_mode = True gui.message('You hear zombies all around you.', pygame.Color(0,0,255)) gen.render_all() mainloop()
def die(self): global game_state if self.status == 'alive': self.owner.send_to_back() self.owner.char = '%' self.owner.color = pygame.Color(100,0,0) self.owner.blocks = False self.status = 'dead' if self.owner.name == 'player': game_state = 'dead' gui.message('You have died.', pygame.Color(150,0,0)) else: self.ai = None
def MainMenu(): while 1: ait.game_state = 'menu' gui.win.setscreencolors(None, None, True) options = ['Start New Game'] headers = [gui.header('XTRICATE OUTLAST: A zombie apocalypse roguelike', pygame.Color(255,0,0)), gui.header('By Alasdair McLean', pygame.Color(170,170,170))] gui.menu(headers, options, gui.WIN_HEIGHT // 3) # gui.win.putchars('XTRICATE OUTLAST: A zombie apocalypse roguelike', (gui.WIN_WIDTH // 2) - 23, gui.WIN_HEIGHT // 3, pygame.Color(255,0,0)) # gui.win.putchars('By Alasdair McLean', (gui.WIN_WIDTH // 2) - 7, (gui.WIN_HEIGHT // 3) + 1, pygame.Color(255,255,255)) # gui.win.putchars('1) Start New Game', (gui.WIN_WIDTH // 2) - 6, (gui.WIN_HEIGHT // 3) + 3, pygame.Color(150,150,150)) gui.win.update() gui.win.blittowindow() choice = handle_keys() if choice == 'a': gui.win.setscreencolors(None, None, True) CharCreation()
def render_all(): global mp, dirtytiles, fov_mp, MSGX, HBAR_WID fov_mp = fov.compute(mp, player.x, player.y, gui.MAPHEIGHT, gui.MAPWIDTH) ait.fov_mp = fov_mp for y in range(gui.MAPHEIGHT): for x in range(gui.MAPWIDTH): if fov_mp[x][y] == 1: mp[x][y].explored = True wall = mp[x][y].block_sight if wall: gui.win.putchars('#', x, y, fgcolor=(90,40,0,255)) #BROWN else: gui.win.putchars('.', x, y, fgcolor=(255,255,255,255)) #WHITE elif mp[x][y].explored: wall = mp[x][y].block_sight if wall: gui.win.putchars('#', x, y, fgcolor=(70,70,70,255)) else: gui.win.putchars('.', x, y, fgcolor=(70,70,70,255)) for Object in objects: if fov_mp[Object.x][Object.y] == 1: gui.win.putchars(Object.char, x=Object.x, y=Object.y, fgcolor=Object. color) if player.cognitive.hp > (7 * player.cognitive.con): healthcolor = (0,255,0,255) elif player.cognitive.hp > (4 * player.cognitive.con): healthcolor = (255,255,0,255) else: healthcolor = (255,0,0,255) healthbar = pygcurse.PygcurseTextbox(gui.win, region = (0, gui.MAPHEIGHT, gui.HBARWID, 1), bgcolor=None, fgcolor=healthcolor, border=None, text="Health: " + str(player.cognitive.hp), wrap=False) healthbar.update() gui.win.putchars('Level ' + str(level) + ' of the ' + area, 0, gui.MAPHEIGHT + 1, fgcolor = pygame.Color(125, 170, 125)) gui.win.putchars(player.char, player.x, player.y, player.color) gui.msg_update() gui.win.update() gui.win.blittowindow() gui.win.putchars(' ', 8, gui.MAPHEIGHT, fgcolor = (0,0,0,255)) gui.win.setscreencolors(pygame.Color(215,215,215), None, False) gui.win.fill(region=(gui.MSGX, gui.MAPHEIGHT, gui.MSG_MAX_WID, gui.MSG_HEIGHT))
def mel_attack(self, target): damage = ((self.pwr * 2) + (round(.5 * self.stg))) dice = random.randint(0, 100) if dice == 100: gui.message('The ' + self.owner.name.capitalize() + ' misses ' + target.name + '.', pygame.Color(255,255,0)) elif dice <= target.cognitive.agi: gui.message('The ' + target.name.capitalize() + ' dodges the ' + self.owner.name.capitalize() + '\'s attack!', pygame.Color(0,0,255)) else: gui.message('The ' + self.owner.name.capitalize() + ' hits the ' + target.name + ' for ' + str(damage) + ' damage.', pygame.Color(255,0,0)) target.cognitive.take_damage(damage)
import simulatorIntro import GuiHandler import ActionHandler #set up people Gui and the number according to the user GuiHandler.setPeople(simulatorIntro.numberOfPeople) #set the infection time specified by the user ActionHandler.infectionTime = simulatorIntro.infectionTime #set the infection radius specified by the user ActionHandler.radius = simulatorIntro.radius #loop through the 1 - percentage and add those numbers to the list for i in range(1,simulatorIntro.percentage): ActionHandler.randIList.append(i) #spawn patient zero and set the GUI ActionHandler.spawnPatientZero() #choose which simulation to run if simulatorIntro.choice == "S": ActionHandler.socialDistance() elif simulatorIntro.choice == "R": ActionHandler.randomWalk()
return output if (__name__ == "__main__"): TABS_FILE = 'CSV/tabs.csv' META_FILE = 'engine/meta.csv' MODULE_DIR = 'modules' WIDTH = 600 HEIGHT = 300 TABS_LIST = CSV_handler.loadCSV(TABS_FILE) if linux_distribution(): #print (platform.linux_distribution()) gui = GuiHandler.GuiHandler(); #gui.left_Button_With_Command("Quit", "root.destroy()") #gui.left_Button_With_Command("Hello", "print ('test')") gui.set_title("Testing") gui.set_dimensions(WIDTH, HEIGHT) gui.add_tabs(TABS_LIST) gui.run() gui_output = (gui.get_output()) mh = metahandler.metahandler(dict_list = gui_output, meta = META_FILE) mh.write_output_using_meta() dirs = mh.get_csv_dirs() #print (dirs) modules = modulehandler.modulehandler()
def spawnPatientZero(): GuiHandler.setPatientZero() infectedDays[GuiHandler.patient0] = 0 infected.append(GuiHandler.patient0)
def handle_keys(): global playerx, playery, game_state turnkeys = (pygame.K_UP, pygame.K_DOWN, pygame.K_LEFT, pygame.K_RIGHT, pygame.K_1, pygame.K_2, pygame.K_3, pygame.K_4, pygame.K_5, pygame.K_6, pygame.K_7, pygame.K_8, pygame.K_9) for event in pygame.event.get(): if event.type == QUIT or (event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE): quit() elif event.type == pygame.KEYUP and pygcurse.interpretkeyevent(event) == '`' and ait.game_state == 'menu': gui.win.setscreencolors(None, None, True) ait.game_state = 'normal' game = Game(flags = 'debug') break elif event.type == pygame.KEYUP and event.key == pygame.K_BACKSLASH: if gui.win.fullscreen == True: gui.win.fullscreen = False else: gui.win.fullscreen = True gen.render_all() if ait.game_state == 'normal': if event.type == pygame.KEYUP and event.key in turnkeys: if event.key == pygame.K_UP: gen.player.check(0, -1) if event.key == pygame.K_DOWN: gen.player.check(0, 1) if event.key == pygame.K_LEFT: gen.player.check(-1, 0) if event.key == pygame.K_RIGHT: gen.player.check(1, 0) if event.key == pygame.K_7: gen.player.check(-1, -1) if event.key == pygame.K_8: gen.player.check(0, -1) if event.key == pygame.K_9: gen.player.check(1, -1) if event.key == pygame.K_4: gen.player.check(-1, 0) if event.key == pygame.K_6: gen.player.check(1, 0) if event.key == pygame.K_1: gen.player.check(-1, 1) if event.key == pygame.K_2: gen.player.check(0, 1) if event.key == pygame.K_3: gen.player.check(1, 1) gui.msgs_updated = False gen.ai_go() gen.render_all() elif event.type == pygame.KEYUP and pygcurse.interpretkeyevent(event) == '>': for stairs in gen.down_stairs: if gen.player.x == stairs.x and gen.player.y == stairs.y: gen.level += 1 gen.area = 'dungeon' gen.create_mp() elif event.type == pygame.KEYUP and pygcurse.interpretkeyevent(event) == '<': for stairs in gen.up_stairs: if gen.player.x == stairs.x and gen.player.y == stairs.y: if gen.level > 0: gen.area = 'dungeon' gen.create_mp() else: gen.area == 'city' gen.create_mp() elif event.type == pygame.KEYUP and pygcurse.interpretkeyevent(event) == '`': for y in range(gui.MAPHEIGHT): for x in range(gui.MAPWIDTH): gen.mp[x][y].explored = True for Object in gen.objects: gui.win.putchar(Object.char, Object.x, Object.y, fgcolor=pygame.Color(170, 0, 170)) gui.win.update() gui.win.blittowindow() elif event.type == pygame.KEYUP and pygcurse.interpretkeyevent(event) == '?': gui.win.setscreencolors(None, None, True) gui.list(('7 8 9', '4 5 6 Movement Keys', '1 2 3', '', 'Arrow Keys:', ' UP', 'LEFT DOWN RIGHT', '', '\ : fullscreen', 'ESC: Quit', '', 'press any key to return')) gui.win.update() gui.win.blittowindow() gui.win.setscreencolors(None, None, True) elif ait.game_state == 'dead': gen.render_all() elif ait.game_state == 'menu': if event.type == pygame.KEYUP: return pygcurse.interpretkeyevent(event) # elif ait.game_state == 'test': else: return 'didnt-take-turn'
def victory_check(): global victory if len(gen.all_enemies) == 0 and victory == False: gui.message('It is quiet.', pygame.Color(255,255,0)) victory = True