def new_map(self, size_x, size_y, wall_prob, monster_list, monster_prob): self.map_data = map_class.map(size_x, size_y) self.map_data.gen_map(wall_prob, monster_list, monster_prob, self) ############### new_player = player_class.player() self.map_data.spawn_player(new_player) self.player = new_player
def __init__(self, screen_width, screen_height, max_enemies, num_players=1): ''' Initialize the game object and all it's variables. :param screen_width: Given an integer screen width :param screen_height: Given an integer screen height :param enemies: Given a list of enemy objects :param num_players: Given an integer amount for number of players - more for ai training. ''' pygame.display.set_caption('Gen Dino Game') # Game caption self.screen_width = screen_width # Screen width self.screen_height = screen_height # Screen height self.window = pygame.display.set_mode( (screen_width, screen_height)) # Game window self.bg = pygame.image.load( 'images/bg4.png').convert_alpha() # Background image self.bg_len = self.bg.get_size()[0] # Background image width self.crash = False # Collision self.players = [ plc.player(200, 425, 45, 52, i, COLOR[i]) for i in range(num_players) ] # Summon player class self.population = num_players # Number of players self.score = 0 # Game score self.speed = 10 # Game speed that will increment self.got_points = False # Flag for points self.dodge_points = 0 # Actual dodge_points self.got_dodge_points = False # Flag for dodge_points self.got_walk_points = False # Flag for walk points # Make the bird sprites game objects and specifications self.bird_sprite = [ pygame.image.load('images/bird_L1.png').convert_alpha(), pygame.image.load('images/bird_L2.png').convert_alpha() ] self.bird_w = [46, 46, 46] # Bird widths self.bird_h = [42, 42, 42] # Bird heights self.bird_y = [440, 370, 300] # Bird initial y coordinate # Set cactus sprite object specifications self.cactus_sprite = [ pygame.image.load('images/cactus_1.png').convert_alpha() ] self.cact_w = [25, 35, 40] # Cactus widths self.cact_h = [50, 70, 80] # Cactus heights self.cact_y = [420, 400, 390] # Cactus initial y coordinates self.Enemies = [self.init_enemies(i) for i in range(max_enemies)] # Summon list of enemies self.max_enemies = max_enemies # Max Enemies
SCREENHEIGHT = 800 size = (SCREENWIDTH, SCREENHEIGHT) screen = pygame.display.set_mode(size) pygame.display.set_caption("...'") pygame.mixer.pre_init(frequency=44100, size=-16, channels=2, buffer=4096) pygame.mixer.music.load('The Pink Panther Theme Song (Original Version).mp3') pygame.mixer.music.play(-1) #-1 means loops for ever, 0 means play just once) background = pygame.image.load("MainGameBackground.png") background = pygame.transform.scale(background, (SCREENWIDTH, SCREENHEIGHT)) all_sprites_list = pygame.sprite.Group() playerplayer = player(75, 70, 70) playerplayer.rect.x = 0 playerplayer.rect.y = 0 treasure1 = Treasure(60, 80) treasure1.rect.x = 900 treasure1.rect.y = 100 treasure2 = Treasure(60, 80) treasure2.rect.x = 550 treasure2.rect.y = 700 treasure3 = Treasure(60, 80) treasure3.rect.x = 100 treasure3.rect.y = 700
clock = pygame.time.Clock() dt = clock.tick(60) flag = 0 ultrahot = 0 time_limit = 8 font = pygame.font.SysFont('Consolas', 30) font2 = pygame.font.SysFont('Consolas', 20) #gameover_music = pygame.mixer.music.load("music/GameOver.mp3") #inisialisasi karakter pemain player_x = size[0] - 565 player_y = size[1] - 220 player_w = 32 player_h = 32 player_speed = 0.3 pemain = player_class.player(player_x, player_y, player_w, player_h, player_speed) #invisible wall guard_upper_limit = 40 guard_lower_limit = 355 #inisialisasi penjaga 1 guard1_x = 260 - 26 guard1_y = 165 - 26 guard1_w = 48 guard1_h = 48 guard1_speed = 0.2 guard1_image = [ pygame.image.load("image/Penjaga 1/Penjaga 1-1.png"), pygame.image.load("image/Penjaga 1/Penjaga 1-1.png"), pygame.image.load("image/Penjaga 1/Penjaga 1-1.png"),
def run_game(): global reveal_dealer_hand global last_hand name = input("Who would like to play Blackjack? ") while True: try: buyin = int(input("And how much would you like to play for? ")) break except: print("That is not a valid buyin please enter only full dolar amounts. ") new_player = player_class.player(name, buyin) while True: try: decks = int(input("How many decks will be in this shoe 1-10: ")) if decks > 10 or decks < 1: print("Invalid number of decks, please try again: ") else: break except: print("That is not a valid number, try again ") #start playing while True: play_again = "" if last_hand: play_again = input("The shoe is over would you like to play another shoe? Y, N: ") if play_again.lower() == "n" or play_again.lower() == 'no': break last_hand = False while not last_hand: print("shuffling shoe......") create_shoe(decks) bet = 0 while not last_hand: print(f"the shoe has {len(current_shoe)} cards left in it") reveal_dealer_hand = False #deal begin the shoe while True: try: bet = int(input(f"How much would you like to bet {new_player.name}? You have {new_player.balance} remaining ")) while not new_player.withdraw_funds(bet): print("You do not have that balance avilable: ") while True: try: bet = int(input(f"How much would you like to bet {new_player.name}? You have {new_player.balance} remaining ")) except: print("that isn't a valid bet: ") else: break # stop player from being able to pull out more then they have except: print("that isn't a valid bet: ") else: break deal(new_player) show_current_hand(new_player) #check for black jacks if chk_black_jack(new_player.current_hand) and not chk_black_jack(dealers_hand): print("Winner winner Chicken Dinner!") new_player.hand_result(bet, bet*2.5) reveal_dealer_hand = True show_current_hand(new_player) elif chk_black_jack(new_player.current_hand): new_player.hand_result(bet, bet) reveal_dealer_hand = True show_current_hand(new_player) elif chk_black_jack(dealers_hand): reveal_dealer_hand = True new_player.hand_result(bet, 0) show_current_hand(new_player) # this if refers to if a player doesn't bust, then the dealer gets a turn elif play_hand(new_player) == "Bust": reveal_dealer_hand = True show_current_hand(new_player) else: # run out dealer hand while True: show_current_hand(new_player) dealer_total = count_hand(dealers_hand) # if dealer has a staying hand # dealer busts if dealer_total[0] > 21: # dealer busts pay out player and anounce win and ask to play again reveal_dealer_hand = True show_current_hand(new_player) print(f"Dealer busts with {dealer_total[0]}, you win! ") new_player.hand_result(bet,bet*2) break # dealer has a hand to stay elif dealer_total[0] >= 17 or (dealer_total[0] > 7 and dealer_total[1] == True): # compare hands pay out winners or pushes if does_player_wins(dealers_hand, new_player.current_hand) == "Push": new_player.hand_result(bet, bet) reveal_dealer_hand = True show_current_hand(new_player) print("You Push ") elif does_player_wins(dealers_hand, new_player.current_hand): new_player.hand_result(bet, bet*2) reveal_dealer_hand = True show_current_hand(new_player) print("You Win!!!! ") else: new_player.hand_result(bet, 0) reveal_dealer_hand = True show_current_hand(new_player) print("Dealer wins") break # dealer stays else: #dealer keeps hitting draw_card(dealers_hand) time.sleep(0.5)
mp.set_start_method('fork') GPIO.setmode(GPIO.BOARD) # ここを直そう N = 2 # 子機の数 inpin = [12, 16] # スイッチ側のピン番号 outpin = [11, 15] # LED側のピン番号 if N != len(inpin) or N != len(outpin): print("wrong input") sys.exit(1) players = [] for i, o in zip(inpin, outpin): players.append(player_class.player(i, o)) lock = Lock() loop = True push = False cnt = Value('i', 0) itr = Value('i', 0) que = Array('i', N + 2) press = Array('i', N + 2) for j in range(N + 2): que[j] = -1 process = [] for j in range(N): process.append( Process(target=players[j].proc, args=[lock, j, itr, cnt, que, press]))