def __init__(self): self.isRunning = True self.difficulty = 0 self.FPS = 60 self.GameOver = False # Initialize all Objects self.player = Player(black, player_width, player_height, 0, 0) self.cactus = Obstacle('cactus', 'normal', black, 0, 0, 11, 27, 800) self.cactus_flipped = Obstacle('cactus', 'flipped', black, 0, 0, 11, 27, 1200) self.bird_low = Bird('bird', 'normal', black, 0, 0, 20, 14, 1000, y_val=(game_height / 1.70)) self.bird_high = Bird('bird', 'normal', black, 0, 0, 20, 14, 1400, y_val=(game_height / 1.69))
def __init__(self, name="Wizard"): stats = [name, 4, 8, 18, 1, 3, 6] Player.__init__(self, stats) self.player_class = "Wizard" # Class Specific Stat # The wizard uses MANA as a resource. self.class_stat_name = "Mana"
def __init__(self, name="Ranger"): stats = [name, 6, 15, 9, 2, 5, 3] Player.__init__(self, stats) self.player_class = "Ranger" # Class Specific Stat # The ranger uses ARROWS as a resource. self.class_stat_name = "Arrows"
def __init__(self, name="Barbarian"): stats = [name, 15, 10, 5, 6, 3, 1] Player.__init__(self, stats) self.player_class = "Barbarian" self.skills = [("Rage", self.skill_rage), ("Brutal Critical", self.skill_brutal_critical), ("Primal Champion", self.skill_primal_champion)] # Class Specific Stat # Rage Builds up when the player takes damage, or after a turn. # Rage is the resource cost for the Barbarian's abilities. self.class_stat_name = "Rage" self.mp = 0 # Start at 0 rage.
def map_row(self, row, metadata=None): player = Player(key=row[0], name=row[1], team=row[2], fTeam=row[3], positions=row[4]) return player
def __init__(self): self.board = [] self.currentPlayer = Player('O') for x in range(3): self.board.append([]) for y in range(3): self.board[x].append("-") """
def add_new_player(): with open('Players.txt', 'a+') as player_file: new_player = Player((input("username:\n")), "") while True: new_player.password = input("Password:\n") if len(new_player.password) not in range(6, 12): print("Make sure your password is at least 6 and less than 12 letters") elif re.search('[0-9]', new_player.password) is None: print("Make sure your password has a number in it") elif re.search('[A-Z]', new_player.password) is None: print("Make sure your password has a capital letter in it") else: break if (new_player.name + " " + new_player.password) in open('Players.txt').read(): print("sorry that username has been taken") sys.exit() player_file.write(new_player.name) player_file.write(" ") player_file.write(new_player.password) player_file.write("\n") main_menu()
def LoadPlayers(self): Players = [] counter = 0 file = open('PlayersDatabase.dat', 'r') cont = file.readlines() try: while 1: cont1 = cont[counter].split() Players.append(Player(cont1)) counter += 1 except: Pool = PoolPlayers(Players) return Pool
def post(self): npc_org = NPCOrganizations() player = Player( "Vincent", "Merle", SharedData().organizations[next( (org for org in SharedData().organizations if SharedData().organizations[org].name == "X-COM"))], random.randint(1000000, 10000000), SharedData().get_default_sector()) SharedData().add_online_player(self.session_id, player) AWaiters().deliver(AWaiters.WAIT_FOR_CHAT_PLAYERS, player) player.CurrentSector.add_object(player.MapObject) self.redirect("/") pass
def generateplayingfield(info, tournament): """ Generates the playing field given the raw data. Gets passed the file name and the tournament. """ # load workbook data print "Loading workbook data." players = [] wb = load_workbook(info, read_only=True, data_only=True) ws = wb.active # construct players from each row value for row in ws: if str(row[0].value).lower() in ['none']: continue name = str(row[0].value) + " " + str(row[1].value) division = str(row[2].value) hometown = str(row[3].value) school = str(row[4].value) anniversary = str(row[5].value).lower() in ['yes'] sande = str(row[6].value).lower() in ['yes'] citizen = str(row[7].value).lower() in ['yes'] military = str(row[8].value).lower() in ['military'] geography = str(row[9].value).lower() in ['geography'] fqn = str(row[10].value).lower in ['yes'] bowl = str(row[11].value).lower() in ['yes'] bee = str(row[12].value).lower() in ['yes'] seed = str(row[13].value).lower() newplayer = Player(name, division, hometown, school, bee, bowl, anniversary, sande, citizen, military, geography, fqn, seed, tournament) players.append(newplayer) # remove header players.pop(0) # close workbook and return players wb.close() return players
class RexRun: def __init__(self): self.isRunning = True self.difficulty = 0 self.FPS = 60 self.GameOver = False # Initialize all Objects self.player = Player(black, player_width, player_height, 0, 0) self.cactus = Obstacle('cactus', 'normal', black, 0, 0, 11, 27, 800) self.cactus_flipped = Obstacle('cactus', 'flipped', black, 0, 0, 11, 27, 1200) self.bird_low = Bird('bird', 'normal', black, 0, 0, 20, 14, 1000, y_val=(game_height / 1.70)) self.bird_high = Bird('bird', 'normal', black, 0, 0, 20, 14, 1400, y_val=(game_height / 1.69)) def upDifficulty(self): self.cactus.speed += self.difficulty self.cactus_flipped.speed += self.difficulty self.bird_low.speed += self.difficulty self.bird_high.speed += self.difficulty def gameOver(self): screen.fill(white) text = font.render('Game Over', True, black) text_rect = text.get_rect() text_x = screen.get_width() / 2 - text_rect.width / 2 text_y = screen.get_height() / 2 - text_rect.height / 2 screen.blit(text, [text_x, text_y]) text = font.render('Press Up or Down Key to Play Again', True, black) text_rect = text.get_rect() text_x = screen.get_width() / 2 - text_rect.width / 2 text_y = screen.get_height() / 1.5 - text_rect.height / 1.5 screen.blit(text, [text_x, text_y]) pygame.display.update() waiting = True while waiting: clock.tick(self.FPS) for event in pygame.event.get(): if event.type == pygame.QUIT: print("QUIT") pygame.quit() self.isRunning = False quit() if event.type == pygame.KEYUP: waiting = False self.__init__() def draw(self): screen.fill(white) pygame.draw.line(screen, black, (0, (game_height / 2 + player_height)), (game_width, (game_height / 2 + player_height))) # Update Score score = font.render(f'Score {self.player.score}', 1, black) screen.blit(score, (5, 10)) self.player.score += (1 / 2) # Update Objects self.player.update() if self.cactus.update(self.player): self.GameOver = True if self.cactus_flipped.update(self.player): self.GameOver = True if self.bird_low.update(self.player): self.GameOver = True if self.bird_high.update(self.player): self.GameOver = True if self.player.score % 500 == 0: print(self.player.score) self.upDifficulty() self.difficulty += 1 # Update Display pygame.display.update() clock.tick(self.FPS) def main(self): while self.isRunning: if self.GameOver: self.gameOver() for event in pygame.event.get(): if event.type == pygame.QUIT: print("QUIT") pygame.quit() self.isRunning = False quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: if self.player.Ypos == self.player.player_starty: self.player.isJumping = True elif event.key == pygame.K_DOWN: if not self.player.isDucking: # self.player.isJumping = True pass self.draw()
#arrange button groups depending on level level1_buttons = [button_HELLO, button_SETTINGS, button_QUIT] level2_buttons = [ button_Previous2, button_Sound, ] level3_buttons = [button_ON, button_OFF, button_Previous2] level4_buttons = [button_Previous3, button_CONTINUE] level5_buttons = [button_Previous3] #create groups for sprites all_sprites_list = pygame.sprite.Group() all_enemies_list = pygame.sprite.Group() #create player playerMain = Player(80, 80, 20) playerMain.rect.x = SCREENWIDTH / 2 playerMain.rect.y = SCREENHEIGHT - 100 all_sprites_list.add(playerMain) #create zombies for i in range(5): # make 5 zombies for now zombie = Enemy(80, 80, 2) #make enemies the same size as the player zombie.rect.x = random.randint(0, SCREENWIDTH - 80) zombie.rect.y = random.randint(-400, -200) all_sprites_list.add(zombie) all_enemies_list.add(zombie) #---------Main Program Loop---------- screen.blit(background, (0, 0))
def super_player(self): Player.__init__(self, self.key, self.first_name, self.last_name)
from PlayerClass import Player Player1 = Player(name='Debi', attack=2, defense=2, agility=2, brutality=2, extraLife=2) Player1.RegisterPlayer() Player2 = Player(name='Loyd', attack=2, defense=2, agility=2, brutality=2, extraLife=2) Player2.RegisterPlayer() Player1.Turn(Player2)
from CardClass import Card from PlayerClass import Player from BlackjackHandClass import BlackjackHand c1 = Card(1, 1) #Ace c2 = Card(13, 1) #King p1 = Player("test") h1 = BlackjackHand() p1.addHand(h1) h1.addCard(c1) h1.addCard(c2) print("Hand 1: ") print(h1.cards) print("Hard: " + str(h1.getHardScore())) #11 print("Soft: " + str(h1.getSoftScore())) #Blackjack! h2 = BlackjackHand() c1 = Card(1, 1) #Ace c2 = Card(4, 1) #4 c3 = Card(6, 3) #6 h2.addCard(c1) h2.addCard(c2) h2.addCard(c3) p1.addHand(h2) print("Hand 2") print(h2.cards) print("Hard: " + str(h2.getHardScore())) #11 print("Soft: " + str(h2.getSoftScore())) #21 c4 = Card(5, 4) #6
def getPlayerByName(self, name): for idx, item in enumerate(self.playerList): if (name == str(item)): return self.playerList[idx] return Player()
from PlayerClass import Player from BlackjackHandClass import BlackjackHand from HelperFunctions import * ''' [ ] ''' ''' Player Objects. This table can hold a max of 5 players. ''' player1 = Player("p1", 10000000) player2 = Player("p2") player3 = Player("p3") player4 = Player("p4") player5 = Player("p5") dealer = Player("dealer") #Global objects ''' table list and players list are sort of duplicates because it makes looping a bit easier, but I should consider consolidating... Generating tableScores list based on the number of players ''' tableMinBet = 10 tableMaxBet = 1000 players = [player1] table = [player1, dealer] cardShoe = [] isShuffleTime = False