def setup(self): self.player_list = arcade.SpriteList() self.coin_list = arcade.SpriteList() # Set up the player self.score = 0 self.player = arcade.AnimatedWalkingSprite() character_scale = 0.75 self.player.stand_right_textures = [] self.player.stand_right_textures.append( arcade.load_texture("images/character_sprites/character0.png", scale=character_scale)) self.player.stand_left_textures = [] self.player.stand_left_textures.append( arcade.load_texture("images/character_sprites/character0.png", scale=character_scale, mirrored=True)) self.player.walk_right_textures = [] self.player.walk_right_textures.append( arcade.load_texture("images/character_sprites/characterw0.png", scale=character_scale)) self.player.walk_right_textures.append( arcade.load_texture("images/character_sprites/characterw1.png", scale=character_scale)) self.player.walk_right_textures.append( arcade.load_texture("images/character_sprites/characterw2.png", scale=character_scale)) self.player.walk_right_textures.append( arcade.load_texture("images/character_sprites/characterw3.png", scale=character_scale)) self.player.walk_left_textures = [] self.player.walk_left_textures.append( arcade.load_texture("images/character_sprites/characterw0.png", scale=character_scale, mirrored=True)) self.player.walk_left_textures.append( arcade.load_texture("images/character_sprites/characterw1.png", scale=character_scale, mirrored=True)) self.player.walk_left_textures.append( arcade.load_texture("images/character_sprites/characterw2.png", scale=character_scale, mirrored=True)) self.player.walk_left_textures.append( arcade.load_texture("images/character_sprites/characterw3.png", scale=character_scale, mirrored=True)) self.player.texture_change_distance = 20 self.player.center_x = SCREEN_WIDTH // 2 self.player.center_y = SCREEN_HEIGHT // 2 self.player.scale = 0.8 self.player_list.append(self.player) for i in range(COIN_COUNT): coin = arcade.AnimatedTimeSprite(scale=0.5) coin.center_x = random.randrange(SCREEN_WIDTH) coin.center_y = random.randrange(SCREEN_HEIGHT) coin.textures = [] coin.textures.append( arcade.load_texture("images/gold_1.png", scale=COIN_SCALE)) coin.textures.append( arcade.load_texture("images/gold_2.png", scale=COIN_SCALE)) coin.textures.append( arcade.load_texture("images/gold_3.png", scale=COIN_SCALE)) coin.textures.append( arcade.load_texture("images/gold_4.png", scale=COIN_SCALE)) coin.textures.append( arcade.load_texture("images/gold_3.png", scale=COIN_SCALE)) coin.textures.append( arcade.load_texture("images/gold_2.png", scale=COIN_SCALE)) coin.cur_texture_index = random.randrange(len(coin.textures)) self.coin_list.append(coin) # Set the background color arcade.set_background_color(arcade.color.AMAZON)
def __init__(self, width, height, title): super().__init__(width, height, title) self.set_mouse_visible(True) arcade.set_background_color(open_color.blue_4) self.animal_list = arcade.SpriteList()
def setup(self): self.wall_list = arcade.SpriteList() self.enemy_list = arcade.SpriteList() self.player_list = arcade.SpriteList() self.coin_list = arcade.SpriteList() for x in range(0, SCREEN_WIDTH, SPRITE_SIZE): wall = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/rpgTile019.png", SPRITE_SCALING) wall.bottom = 0 wall.left = x self.wall_list.append(wall) # Draw the platform for x in range(SPRITE_SIZE * 3, SPRITE_SIZE * 8, SPRITE_SIZE): wall = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/rpgTile019.png", SPRITE_SCALING) wall.bottom = SPRITE_SIZE * 3 wall.left = x self.wall_list.append(wall) # Draw the crates for x in range(0, SCREEN_WIDTH, SPRITE_SIZE * 5): wall = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/boxCrate_double.png", SPRITE_SCALING) wall.bottom = SPRITE_SIZE wall.left = x self.wall_list.append(wall) for i in range(7): # Create the coin instance coin = arcade.Sprite( "C:\Git\Skoli-haust-2020\Forritun\Verkefni með einkunn\Lokaverkefni\images\coinGold.png", SPRITE_SCALING / 2) # Position the coin coin.center_x = random.randrange(SCREEN_WIDTH) coin.center_y = random.randrange(600) # Add the coin to the lists self.coin_list.append(coin) # -- Draw an enemy on the ground enemy = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/character_zombie_idle.png", SPRITE_SCALING) enemy.bottom = SPRITE_SIZE enemy.left = SPRITE_SIZE * 2 # Set enemy initial speed enemy.change_x = 2 self.enemy_list.append(enemy) # -- Draw a enemy on the platform enemy = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/character_zombie_idle.png", SPRITE_SCALING) enemy.bottom = SPRITE_SIZE * 4 enemy.left = SPRITE_SIZE * 4 # Set boundaries on the left/right the enemy can't cross enemy.boundary_right = SPRITE_SIZE * 8 enemy.boundary_left = SPRITE_SIZE * 3 enemy.change_x = 2 self.enemy_list.append(enemy) # -- Set up the player self.player_sprite = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/character1.png", SPRITE_SCALING) self.player_list.append(self.player_sprite) # Starting position of the player self.player_sprite.center_x = 64 self.player_sprite.center_y = 270 self.physics_engine = arcade.PhysicsEnginePlatformer( self.player_sprite, self.wall_list, gravity_constant=GRAVITY) # Set the background color arcade.set_background_color(arcade.color.AMAZON)
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.wall_list = arcade.SpriteList() self.enemy_list = arcade.SpriteList() self.player_list = arcade.SpriteList() # Draw the walls on the bottom for x in range(0, SCREEN_WIDTH, SPRITE_SIZE): wall = arcade.Sprite(":resources:images/tiles/grassMid.png", SPRITE_SCALING) wall.bottom = 0 wall.left = x self.wall_list.append(wall) # Draw the platform for x in range(SPRITE_SIZE * 3, SPRITE_SIZE * 8, SPRITE_SIZE): wall = arcade.Sprite(":resources:images/tiles/grassMid.png", SPRITE_SCALING) wall.bottom = SPRITE_SIZE * 3 wall.left = x self.wall_list.append(wall) # Draw the crates for x in range(0, SCREEN_WIDTH, SPRITE_SIZE * 5): wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING) wall.bottom = SPRITE_SIZE wall.left = x self.wall_list.append(wall) # -- Draw an enemy on the ground enemy = arcade.Sprite(":resources:images/enemies/wormGreen.png", SPRITE_SCALING) enemy.bottom = SPRITE_SIZE enemy.left = SPRITE_SIZE * 2 # Set enemy initial speed enemy.change_x = 2 self.enemy_list.append(enemy) # -- Draw a enemy on the platform enemy = arcade.Sprite(":resources:images/enemies/wormGreen.png", SPRITE_SCALING) enemy.bottom = SPRITE_SIZE * 4 enemy.left = SPRITE_SIZE * 4 # Set boundaries on the left/right the enemy can't cross enemy.boundary_right = SPRITE_SIZE * 8 enemy.boundary_left = SPRITE_SIZE * 3 enemy.change_x = 2 self.enemy_list.append(enemy) # -- Set up the player self.player_sprite = arcade.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING) self.player_list.append(self.player_sprite) self.player = PlayerCharacter() self.player.center_x = SCREEN_WIDTH // 2 self.player.center_y = SCREEN_HEIGHT // 2 self.player.scale = 1.5 # Starting position of the player self.player.center_x = 64 self.player.center_y = 270 self.player._idle() self.player_list.append(self.player) self.physics_engine = arcade.PhysicsEnginePlatformer( self.player, self.wall_list, gravity_constant=GRAVITY) # Set the background color arcade.set_background_color(arcade.color.AMAZON)
def win(self): self.is_game_over = True for k in self.assets.keys(): self.assets[k] = arcade.SpriteList()
def __init__(self, world): self.world = world self.coin = arcade.SpriteList()
def setup(self): self.wall_list = arcade.SpriteList() self.enemy_list = arcade.SpriteList() self.player_list = arcade.SpriteList() self.coin_list = arcade.SpriteList() for x in range(0, SCREEN_WIDTH, SPRITE_SIZE): wall = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/rpgTile019.png", SPRITE_SCALING) #kallar í myndina wall.bottom = 0 wall.left = x self.wall_list.append(wall) # Draw the platform for x in range(SPRITE_SIZE * 3, SPRITE_SIZE * 8, SPRITE_SIZE): wall = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/rpgTile019.png", SPRITE_SCALING) #kallar í myndina wall.bottom = SPRITE_SIZE * 3 wall.left = x self.wall_list.append(wall) # Draw the crates for x in range(0, SCREEN_WIDTH, SPRITE_SIZE * 5): #teiknar kassana wall = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/boxCrate_double.png", SPRITE_SCALING) #kallar í myndina wall.bottom = SPRITE_SIZE wall.left = x self.wall_list.append(wall) for i in range(7): # Býr til peningin coin = arcade.Sprite( "C:\Git\Skoli-haust-2020\Forritun\Verkefni með einkunn\Lokaverkefni\images\coinGold.png", SPRITE_SCALING / 2) #kallar í myndina # staðsetur myntina coin.center_x = random.randrange(SCREEN_WIDTH) coin.center_y = random.randrange(600) # setur peningin í listan self.coin_list.append(coin) # -- setur upp karakterin self.player_sprite = arcade.Sprite( "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/character1.png", SPRITE_SCALING) #kallar í myndina self.player_list.append(self.player_sprite) # etur byrjunarstaðsetningu karakterins self.player_sprite.center_x = 64 self.player_sprite.center_y = 270 self.physics_engine = arcade.PhysicsEnginePlatformer( self.player_sprite, self.wall_list, gravity_constant=GRAVITY) # setur bakrunn arcade.set_background_color(arcade.color.SKY)
def erme_sprite_init(self): self.erme_lista = arcade.SpriteList() self.erme_lista.append(Erme(3, 5, 2)) self.erme_lista.append(Erme(12, 7, 7)) self.erme_lista.append(Erme(13, 2, 13)) self.erme_lista.append(Erme(7, 8, 5))
def kard_sprite_init(self): self.kard_lista = arcade.SpriteList() self.kard_lista.append(Kard(12, 5)) self.kard_lista.append(Kard(3, 7))
def setup(self): arcade.set_background_color(BACKGROUND_COLOR) self.logo_list = arcade.SpriteList() self.logo_list.append(Cisc108Logo())
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcade.SpriteList() self.wall_list = arcade.SpriteList() self.score = 0 # Create the maze maze = make_maze_depth_first(MAZE_WIDTH, MAZE_HEIGHT) # Create sprites based on 2D grid if not MERGE_SPRITES: # This is the simple-to-understand method. Each grid location # is a sprite. for row in range(MAZE_HEIGHT): for column in range(MAZE_WIDTH): if maze[row][column] == 1: wall = arcade.Sprite("images/grassCenter.png", SPRITE_SCALING) wall.center_x = column * SPRITE_SIZE + SPRITE_SIZE / 2 wall.center_y = row * SPRITE_SIZE + SPRITE_SIZE / 2 self.wall_list.append(wall) else: # This uses new Arcade 1.3.1 features, that allow me to create a # larger sprite with a repeating texture. So if there are multiple # cells in a row with a wall, we merge them into one sprite, with a # repeating texture for each cell. This reduces our sprite count. for row in range(MAZE_HEIGHT): column = 0 while column < len(maze): while column < len(maze) and maze[row][column] == 0: column += 1 start_column = column while column < len(maze) and maze[row][column] == 1: column += 1 end_column = column - 1 column_count = end_column - start_column + 1 column_mid = (start_column + end_column) / 2 wall = arcade.Sprite("images/grassCenter.png", SPRITE_SCALING, repeat_count_x=column_count) wall.center_x = column_mid * SPRITE_SIZE + SPRITE_SIZE / 2 wall.center_y = row * SPRITE_SIZE + SPRITE_SIZE / 2 wall.width = SPRITE_SIZE * column_count self.wall_list.append(wall) # Set up the player self.player_sprite = arcade.Sprite("images/character.png", SPRITE_SCALING) self.player_list.append(self.player_sprite) # Randomly place the player. If we are in a wall, repeat until we aren't. placed = False while not placed: # Randomly position self.player_sprite.center_x = random.randrange(MAZE_WIDTH * SPRITE_SIZE) self.player_sprite.center_y = random.randrange(MAZE_HEIGHT * SPRITE_SIZE) # Are we in a wall? walls_hit = arcade.check_for_collision_with_list( self.player_sprite, self.wall_list) if len(walls_hit) == 0: # Not in a wall! Success! placed = True self.physics_engine = arcade.PhysicsEngineSimple( self.player_sprite, self.wall_list) # Set the background color arcade.set_background_color(arcade.color.AMAZON) # Set the viewport boundaries # These numbers set where we have 'scrolled' to. self.view_left = 0 self.view_bottom = 0 print(f"Total wall blocks: {len(self.wall_list)}")
TITLE = "Raiden Py" WINDOW = None WIDTH = 600 HEIGHT = 600 SCREEN_WIDTH = WIDTH SCREEN_HEIGHT = HEIGHT bullets = [] enemies = [] l = Loader() print("load Start") l.load() print("load End") enemyBullets = arcade.SpriteList() playerBullets = arcade.SpriteList() enemies = arcade.SpriteList() explosions = arcade.SpriteList() playerKills = 0 def getPlayerKills(): return playerKills def addOneToPlayerKills(): global playerKills playerKills += 1
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcade.SpriteList() self.wall_list = arcade.SpriteList() self.brain_list = arcade.SpriteList() # Score self.score = 0 # Set up player self.player_sprite = arcade.Sprite("character.png", SPRITE_SCALING) self.player_sprite.center_x = 150 self.player_sprite.center_y = 300 self.player_list.append(self.player_sprite) # Set up the walls # Set up outer walls for x in range(0, 1200): wall = arcade.Sprite("wall.png", SPRITE_SCALING) wall.center_x = x wall.center_y = 25 self.wall_list.append(wall) for x in range(0, 1200): wall = arcade.Sprite("wall.png", SPRITE_SCALING) wall.center_x = x wall.center_y = 675 self.wall_list.append(wall) for y in range(0, 700): wall = arcade.Sprite("wall.png", SPRITE_SCALING) wall.center_x = 25 wall.center_y = y self.wall_list.append(wall) for y in range(0, 700): wall = arcade.Sprite("wall.png", SPRITE_SCALING) wall.center_x = 1175 wall.center_y = y self.wall_list.append(wall) # Set up maze for y in range(200, 500): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = 205 wall.center_y = y self.wall_list.append(wall) for x in range(285, 500): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = x wall.center_y = 200 self.wall_list.append(wall) for y in range(350, 500): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = 350 wall.center_y = y self.wall_list.append(wall) for y in range(275, 500): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = 500 wall.center_y = y self.wall_list.append(wall) for x in range(425, 427): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = x wall.center_y = 500 self.wall_list.append(wall) for y in range(100, 200): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = 675 wall.center_y = y self.wall_list.append(wall) for y in range(350, 600): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = 675 wall.center_y = y self.wall_list.append(wall) for x in range(750, 1050): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = x wall.center_y = 200 self.wall_list.append(wall) for x in range(800, 1100): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = x wall.center_y = 350 self.wall_list.append(wall) for y in range(425, 550): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = 900 wall.center_y = y self.wall_list.append(wall) for x in range(1025, 1100): wall = arcade.Sprite("wood.png", SPRITE_SCALING) wall.center_x = x wall.center_y = 550 self.wall_list.append(wall) # Place brains brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 425 brain.center_y = 450 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 275 brain.center_y = 475 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 400 brain.center_y = 275 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 275 brain.center_y = 325 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 275 brain.center_y = 100 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 425 brain.center_y = 100 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 550 brain.center_y = 100 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 600 brain.center_y = 275 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 735 brain.center_y = 350 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 1110 brain.center_y = 200 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 800 brain.center_y = 275 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 975 brain.center_y = 275 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 735 brain.center_y = 100 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 950 brain.center_y = 100 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 800 brain.center_y = 500 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 900 brain.center_y = 610 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 1110 brain.center_y = 610 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 1110 brain.center_y = 500 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 1110 brain.center_y = 400 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 950 brain.center_y = 400 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 600 brain.center_y = 500 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 500 brain.center_y = 610 self.brain_list.append(brain) brain = arcade.Sprite("brain.png", SPRITE_SCALING_BRAIN) brain.center_x = 350 brain.center_y = 550 self.brain_list.append(brain) self.physics_engine = arcade.PhysicsEngineSimple(self.player_sprite, self.wall_list) arcade.set_background_color(arcade.color.AMAZON)
def setup(self): # Set up your game here self.car_list = arcade.SpriteList() self.cone_list = arcade.SpriteList() self.barreira_list = arcade.SpriteList() self.car = arcade.Sprite("car.png", SPRITE_SCALING_CAR) self.car.center_x = 80 # Starting position self.car.center_y = 300 self.car_list.append(self.car) #self.physics_engine = arcade.PhysicsEngineSimple(self.car,self.barreira_list) fundo = arcade.Sprite("lateral.png", 1.0) fundo.center_x = 492 fundo.center_y = esqYpos self.barreira_list.append(fundo) fundo = arcade.Sprite("lateral.png", 1.0) fundo.center_x = 492 fundo.center_y = dirYpos self.barreira_list.append(fundo) fundo = arcade.Sprite("fundo.png", 1.0) fundo.center_x = 20 fundo.center_y = 300 self.barreira_list.append(fundo) self.sensorE = arcade.Sprite("ponto.png",SPRITE_SCALING_DOT) self.sensorE.center_x = 274 self.sensorE.center_y = 315 self.sensorD = arcade.Sprite("ponto.png",SPRITE_SCALING_DOT) self.sensorD.center_x = 274 self.sensorD.center_y = 285 ''' self.check = arcade.Sprite("cone.png",0.03) self.check.center_x = 600 self.check.center_y = 370 ''' #fundo = arcade.Sprite("fundo.png", 1.0) #fundo.center_x = 800 #fundo.center_y = 300 #self.barreira_list.append(fundo) ''' #Importar rede antiga for filename in os.listdir('Saves/Rede4_4-24-3/'): if filename.startswith('SavedDriver_+'+CODINOME+'_'): dados = re.findall('\d+',filename) self.resetCount = int(dados[0]) print(dados[1]) self.maxDistance = float(dados[1]) print(dados[2]) save = "Saves/Rede4_4-24-3/"+filename storage.load(nn, filepath=save) ''' pass
def setup(self, map_change): self.player_list = arcade.SpriteList() self.background_list = arcade.SpriteList() self.wall_list = arcade.SpriteList(use_spatial_hash=True) self.door_list = arcade.SpriteList(use_spatial_hash=True) # Set up the player self.player = Sara.Sara() self.player.center_x = PLAYER_START_X self.player.center_y = PLAYER_START_Y self.player_list.append(self.player) # Set the background color arcade.set_background_color(arcade.color.DEEP_SKY_BLUE) # Layers setup walls_layer_name = "Walls" doors_progress_layer_name = "DoorsProgress" doors_return_layer_name = "DoorsReturn" npc_layer_name = "NPC" moving_plat_vertical_layer_name = "MovingPlatformsVertical" moving_plat_horizontal_layer_name = "MovingPlatformsHorizontal" bounce_moving_plat_vertical_layer_name = "MovingPlatformsBounceVertical" bounce_moving_plat_horizontal_layer_name = "MovingPlatformsBounceHorizontal" boss_layer_name = "Boss" enemies_shoot_layer_name = "EnemiesShoot" enemies_layer_name = "Enemies" locked_blocks_layer_name = "LockedBlocks" breakable_blocks_layer_name = "BreakableBlocks" movable_blocks_layer_name = "MovableBlocks" switch_blocks_layer_name = "SwitchBlocks" platforms_layer_name = "Platforms" keys_layer_name = "Keys" switches_layer_name = "Switches" hearts_layer_name = "Hearts" dont_touch_layer_name = "DontTouch" background_layer_name = "Background" # name of the map we will load map_name = PATH + f"/maps/game_map_{map_change}.tmx" # reading the tiled map my_map = arcade.tilemap.read_tmx(map_name) # background self.background_list = arcade.tilemap.process_layer( my_map, background_layer_name, TILE_SCALING) # walls self.wall_list = arcade.tilemap.process_layer( map_object=my_map, layer_name=walls_layer_name, scaling=TILE_SCALING, use_spatial_hash=True) # Lists setup self.doors_progress_list = arcade.tilemap.process_layer( my_map, doors_progress_layer_name, TILE_SCALING) self.doors_return_list = arcade.tilemap.process_layer( my_map, doors_return_layer_name, TILE_SCALING) self.npc_list = arcade.tilemap.process_layer(my_map, npc_layer_name, TILE_SCALING) self.boss_list = arcade.tilemap.process_layer(my_map, boss_layer_name, TILE_SCALING) self.enemies_list = arcade.tilemap.process_layer( my_map, enemies_layer_name, TILE_SCALING) self.enemies_shoot_list = arcade.tilemap.process_layer( my_map, enemies_shoot_layer_name, TILE_SCALING) self.locked_blocks_list = arcade.tilemap.process_layer( my_map, locked_blocks_layer_name, TILE_SCALING) self.breakable_blocks_list = arcade.tilemap.process_layer( my_map, breakable_blocks_layer_name, TILE_SCALING) self.movable_blocks_list = arcade.tilemap.process_layer( my_map, movable_blocks_layer_name, TILE_SCALING) self.switch_blocks_list = arcade.tilemap.process_layer( my_map, switch_blocks_layer_name, TILE_SCALING) self.keys_list = arcade.tilemap.process_layer(my_map, keys_layer_name, TILE_SCALING) self.hearts_list = arcade.tilemap.process_layer( my_map, hearts_layer_name, TILE_SCALING) self.switches_list = arcade.tilemap.process_layer( my_map, switches_layer_name, TILE_SCALING) self.bounce_moving_plat_horizontal_list = arcade.tilemap.process_layer( my_map, bounce_moving_plat_horizontal_layer_name, TILE_SCALING) self.bounce_moving_plat_vertical_list = arcade.tilemap.process_layer( my_map, bounce_moving_plat_vertical_layer_name, TILE_SCALING) self.moving_plat_horizontal_list = arcade.tilemap.process_layer( my_map, moving_plat_horizontal_layer_name, TILE_SCALING) self.moving_plat_vertical_list = arcade.tilemap.process_layer( my_map, moving_plat_vertical_layer_name, TILE_SCALING) self.platforms_list = arcade.tilemap.process_layer( my_map, platforms_layer_name, TILE_SCALING) self.dont_touch_list = arcade.tilemap.process_layer( my_map, dont_touch_layer_name, TILE_SCALING) self.pickup_list = arcade.SpriteList() self.charge_list = arcade.SpriteList() self.melee_list = arcade.SpriteList() spawns = enemy.enemy_spawns[self.map_change] if spawns != None: for each in spawns: self.enemies_list.append(enemy.Enemy(spawns[0], spawns[1])) if self.map_change == 5: self.enemies_list.append(enemy.Boss(800, 700)) # Set the background color if my_map.background_color: arcade.set_background_color(my_map.background_color) # simple for over head games self.physics_engine = arcade.PhysicsEngineSimple( self.player, self.wall_list)
def szorny_sprite_init(self): self.szorny_lista = arcade.SpriteList() self.szorny_lista.append(Ork(2, 5)) self.szorny_lista.append(Demon(7, 2))
def setup(self, level, score): self.level = level self.score = score self.player_list = arcade.SpriteList() self.bullet_list = arcade.SpriteList() self.donut_list = arcade.SpriteList() self.enemy_bullet_list = arcade.SpriteList() self.wall_list = arcade.SpriteList() self.enemy_list = arcade.SpriteList() self.player_sprite = Player("assets/player.png", SPRITE_SCALING * 2) self.player_sprite.center_x = 50 self.player_sprite.center_y = 50 self.player_list.append(self.player_sprite) for _ in range((self.level + 1) * 2): donut = arcade.Sprite("assets/donut.png", 1) donut_placed = False while not donut_placed: donut.center_x = random.randrange(SCREEN_WIDTH) donut.center_y = random.randrange(SCREEN_HEIGHT) donut_hit_list = arcade.check_for_collision_with_list( donut, self.donut_list ) wall_hit_list = arcade.check_for_collision_with_list( donut, self.wall_list ) donut_placed = len(donut_hit_list) == 0 and len(wall_hit_list) == 0 self.donut_list.append(donut) for _ in range(25): wall = arcade.Sprite("assets/wall.png", 1) wall_placed = False # Keep trying until success while not wall_placed: wall.center_x = random.randrange(SCREEN_WIDTH) wall.center_y = random.randrange(SCREEN_HEIGHT) wall_hit_list = arcade.check_for_collision_with_list( wall, self.wall_list ) if len(wall_hit_list) == 0: wall_placed = True self.wall_list.append(wall) self.enemy_engines = [] for _ in range(self.level + 1): enemy = Enemy("assets/enemy.png", 1) enemy_placed = False # Keep trying until success while not enemy_placed: enemy.center_x = random.randrange(SCREEN_WIDTH) enemy.center_y = random.randrange(SCREEN_HEIGHT) enemy_hit_list = arcade.check_for_collision_with_list( enemy, self.enemy_list ) if len(enemy_hit_list) == 0: enemy_placed = True engine = arcade.PhysicsEngineSimple(enemy, self.wall_list) self.enemy_engines.append(engine) self.enemy_list.append(enemy) self.physics_engine = arcade.PhysicsEngineSimple( self.player_sprite, self.wall_list )
def lada_sprite_init(self): self.lada_lista = arcade.SpriteList() self.lada_lista.append(Lada(4, 5, ['balta', 'kard'], True)) self.lada_lista.append(Lada(11, 7, ['balta', 'páncél'], False))
def setup(self, level): """ Set up the game here. Call this function to restart the game. """ # Used to keep track of our scrolling self.view_bottom = 0 self.view_left = 0 # Keep track of the score self.score = 0 # Create the Sprite lists self.player_list = arcade.SpriteList() self.foreground_list = arcade.SpriteList() self.background_list = arcade.SpriteList() self.wall_list = arcade.SpriteList() self.coin_list = arcade.SpriteList() # Set up the player, specifically placing it at these coordinates. image_source = ":resources:images/animated_characters/female_adventurer/femaleAdventurer_idle.png" self.player_sprite = arcade.Sprite(image_source, CHARACTER_SCALING) self.player_sprite.center_x = PLAYER_START_X self.player_sprite.center_y = PLAYER_START_Y self.player_list.append(self.player_sprite) # --- Load in a map from the tiled editor --- # Name of the layer in the file that has our platforms/walls platforms_layer_name = 'Platforms' # Name of the layer that has items for pick-up coins_layer_name = 'Coins' # Name of the layer that has items for foreground foreground_layer_name = 'Foreground' # Name of the layer that has items for background background_layer_name = 'Background' # Name of the layer that has items we shouldn't touch dont_touch_layer_name = "Don't Touch" # Map name map_name = f":resources:tmx_maps/map2_level_{level}.tmx" # Read in the tiled map my_map = arcade.tilemap.read_tmx(map_name) # Calculate the right edge of the my_map in pixels self.end_of_map = my_map.map_size.width * GRID_PIXEL_SIZE # -- Background self.background_list = arcade.tilemap.process_layer( my_map, background_layer_name, TILE_SCALING) # -- Foreground self.foreground_list = arcade.tilemap.process_layer( my_map, foreground_layer_name, TILE_SCALING) # -- Platforms self.wall_list = arcade.tilemap.process_layer( map_object=my_map, layer_name=platforms_layer_name, scaling=TILE_SCALING, use_spatial_hash=True) # -- Coins self.coin_list = arcade.tilemap.process_layer(my_map, coins_layer_name, TILE_SCALING, use_spatial_hash=True) # -- Don't Touch Layer self.dont_touch_list = arcade.tilemap.process_layer( my_map, dont_touch_layer_name, TILE_SCALING, use_spatial_hash=True) # --- Other stuff # Set the background color if my_map.background_color: arcade.set_background_color(my_map.background_color) # Create the 'physics engine' self.physics_engine = arcade.PhysicsEnginePlatformer( self.player_sprite, self.wall_list, GRAVITY)
def fal_sprite_init(self): self.fal_lista = arcade.SpriteList() for i in range(4, 15): self.fal_lista.append(Fal(i, 11)) self.fal_lista.append(Fal(i, 3))
def setup(self): """ Setup the game (or reset the game) """ arcade.set_background_color(BACKGROUND_COLOR) self.score = 0 self.sprites = arcade.SpriteList() self.sprites.append(AdaorPotato())
def jatekos_sprite_init(self): self.jatekos_lista = arcade.SpriteList() self.jatekos_lista.append(self.jatekos_1) self.jatekos_lista.append(self.jatekos_2)
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcade.SpriteList() self.wall_list = arcade.SpriteList() self.coin_list = arcade.SpriteList() self.car_list = arcade.SpriteList() # Set up the player self.player_sprite = arcade.Sprite("monkey.png", 0.125) self.player_sprite.center_x = 20 self.player_sprite.center_y = 40 self.player_list.append(self.player_sprite) # -- Set up several columns of walls for y in range(0, 1000, 100): for x in range(0, 1000, 32): # Randomly skip a box so the player can find a way through if random.randrange(5) > 0: wall = arcade.Sprite("slice.png", SPRITE_SCALING) wall.center_x = x wall.center_y = y self.wall_list.append(wall) # Create bottom edge for x in range(0, 1000, 32): wall = arcade.Sprite("slice01_01.png", SPRITE_SCALING) wall.center_x = x self.wall_list.append(wall) # Create left edge for y in range(0, 1000, 32): wall = arcade.Sprite("slice01_01.png", SPRITE_SCALING) wall.center_y = y self.wall_list.append(wall) # --- Place walls with a list coordinate_list = [[0, 1000], [32, 1000], [64, 1000], [96, 1000], [128, 1000], [160, 1000], [192, 1000], [224, 1000], [256, 1000], [288, 1000], [320, 1000], [352, 1000], [384, 1000], [416, 1000], [448, 1000], [480, 1000], [512, 1000], [544, 1000], [576, 1000], [608, 1000], [640, 1000], [672, 1000], [704, 1000], [736, 1000], [768, 1000], [800, 1000], [832, 1000], [864, 1000], [896, 1000], [928, 1000], [960, 1000], [992, 1000]] # Loop through coordinates to create top edge for coordinate in coordinate_list: wall = arcade.Sprite("slice01_01.png", SPRITE_SCALING) wall.center_x = coordinate[0] wall.center_y = coordinate[1] self.wall_list.append(wall) # --- Place walls with a list coordinate_list = [[1000, 0], [1000, 32], [1000, 64], [1000, 96], [1000, 128], [1000, 160], [1000, 192], [1000, 224], [1000, 256], [1000, 288], [1000, 320], [1000, 352], [1000, 384], [1000, 416], [1000, 448], [1000, 480], [1000, 512], [1000, 544], [1000, 576], [1000, 608], [1000, 640], [1000, 672], [1000, 704], [1000, 736], [1000, 768], [1000, 800], [1000, 832], [1000, 864], [1000, 896], [1000, 928], [1000, 960], [1000, 992]] # Loop through coordinates to create right edge for coordinate in coordinate_list: wall = arcade.Sprite("slice01_01.png", SPRITE_SCALING) wall.center_x = coordinate[0] wall.center_y = coordinate[1] self.wall_list.append(wall) # Create the coins for i in range(NUMBER_OF_COINS): coin = arcade.Sprite("flat_medal1.png", SPRITE_SCALING_COIN) coin_placed_successfully = False # Ensure coins do not get placed on walls while not coin_placed_successfully: coin.center_x = random.randrange(0, 1000) coin.center_y = random.randrange(0, 1000) wall_hit_list = arcade.check_for_collision_with_list( coin, self.wall_list) coin_hit_list = arcade.check_for_collision_with_list( coin, self.coin_list) if len(wall_hit_list) == 0 and len(coin_hit_list) == 0: coin_placed_successfully = True self.coin_list.append(coin) # Place the cars for i in range(CAR_COUNT): car = Car("police_E.png", SPRITE_SCALING_CAR) # Position the car car.center_x = random.randrange(SCREEN_WIDTH) car.center_y = random.randrange(SCREEN_HEIGHT) # Add the coin to the lists self.car_list.append(car) self.physics_engine = arcade.PhysicsEngineSimple( self.player_sprite, self.wall_list) # Set the background color arcade.set_background_color(arcade.color.BABY_BLUE) # Set the viewport boundaries # These numbers set where we have 'scrolled' to. self.view_left = 0 self.view_bottom = 0
def erme_jelzo_init(self): self.erme_jelzo_sprite = arcade.Sprite("img/Coin1.png") self.erme_jelzo_sprite.center_x = MEZO_MERET / 2 self.erme_jelzo_sprite.center_y = KEP_MAGASSAG - 1.5 * MEZO_MERET self.erme_jelzo_lista = arcade.SpriteList() self.erme_jelzo_lista.append(self.erme_jelzo_sprite)
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcade.SpriteList() self.wall_list = arcade.SpriteList(use_spatial_hash=True, spatial_hash_cell_size=128) self.enemy_list = arcade.SpriteList() # Set up the player self.player = arcade.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING) self.player.center_x = SPRITE_SIZE * 5 self.player.center_y = SPRITE_SIZE * 1 self.player_list.append(self.player) # Set enemies enemy = arcade.Sprite( ":resources:images/animated_characters/zombie/zombie_idle.png", SPRITE_SCALING) enemy.center_x = SPRITE_SIZE * 4 enemy.center_y = SPRITE_SIZE * 7 self.enemy_list.append(enemy) spacing = SPRITE_SIZE * 3 for column in range(10): for row in range(15): sprite = arcade.Sprite( ":resources:images/tiles/grassCenter.png", SPRITE_SCALING) x = (column + 1) * spacing y = (row + 1) * sprite.height sprite.center_x = x sprite.center_y = y if random.randrange(100) > 30: self.wall_list.append(sprite) self.physics_engine = arcade.PhysicsEngineSimple( self.player, self.wall_list) # --- Path related # This variable holds the travel-path. We keep it as an attribute so # we can calculate it in on_update, and draw it in on_draw. self.path = None # Grid size for calculations. The smaller the grid, the longer the time # for calculations. Make sure the grid aligns with the sprite wall grid, # or some openings might be missed. grid_size = SPRITE_SIZE # Calculate the playing field size. We can't generate paths outside of # this. playing_field_left_boundary = -SPRITE_SIZE * 2 playing_field_right_boundary = SPRITE_SIZE * 35 playing_field_top_boundary = SPRITE_SIZE * 17 playing_field_bottom_boundary = -SPRITE_SIZE * 2 # This calculates a list of barriers. By calculating it here in the # init, we are assuming this list does not change. In this example, # our walls don't move, so that is ok. If we want moving barriers (such as # moving platforms or enemies) we need to recalculate. This can be an # time-intensive process depending on the playing field size and grid # resolution. # Note: If the enemy sprites are the same size, we only need to calculate # one of these. We do NOT need a different one for each enemy. The sprite # is just used for a size calculation. self.barrier_list = arcade.AStarBarrierList( enemy, self.wall_list, grid_size, playing_field_left_boundary, playing_field_right_boundary, playing_field_bottom_boundary, playing_field_top_boundary)
def setup(self): arcade.set_background_color(BACKGROUND_COLOR) self.sprite_list = arcade.SpriteList() self.timer = 0 self.score = 0
def setup(self): """ Set up everything with the game """ self.lives = LIVES_AT_START # Create the sprite lists self.player_list = arcade.SpriteList() self.bullet_list = arcade.SpriteList() # Read in the tiled map map_name = "resources/tmx_maps/pymunk_test_map.tmx" my_map = arcade.tilemap.read_tmx(map_name) # Read in the map layers self.wall_list = arcade.tilemap.process_layer( my_map, 'Platforms', SPRITE_SCALING_TILES, hit_box_algorithm="Detailed") #self.coins_list = arcade.tilemap.process_layer(my_map, # 'Dynamic Items', # SPRITE_SCALING_TILES, # hit_box_algorithm="Detailed") self.coins_list = arcade.tilemap.process_layer( my_map, 'coins_layer', SPRITE_SCALING_TILES, hit_box_algorithm="Detailed") self.key_lock_door_list = arcade.tilemap.process_layer( my_map, 'key_lock_door_layer', SPRITE_SCALING_TILES, hit_box_algorithm="Detailed") self.ladder_list = arcade.tilemap.process_layer( my_map, 'ladders', SPRITE_SCALING_TILES, use_spatial_hash=True, hit_box_algorithm="Detailed") self.trap_list = arcade.tilemap.process_layer( my_map, 'traps', SPRITE_SCALING_TILES, use_spatial_hash=True, hit_box_algorithm="Detailed") self.mechanics_list = arcade.tilemap.process_layer( my_map, 'mechanics', SPRITE_SCALING_TILES, use_spatial_hash=True) #hit_box_algorithm="Detailed") self.mechandler_list = arcade.tilemap.process_layer( my_map, 'mec_handlers_layer', SPRITE_SCALING_TILES, #use_spatial_hash=True, hit_box_algorithm="Detailed") #self.master_status = "leverMid" #self.master_status_cyclist.next() self.master_status = mechandler_texture_names_list[ 0] #self.master_status_cyclist.next() self.mechandlers_textures = MECHANDLERS_TEXTURES #self.master_status_png = arcade.Sprite VA ET VIENT SELON TMX #rint(dir(self.mechandler_list[0])) #print(self.mechandler_list[0].texture) #print(self.mechandler_list[0].textures) self.master_status_png = mechandler_texture_list[0] self.master_status_name = mechandler_texture_names_list[0] #self.master_status_png = self.mechandler_list[0].filename print(f"SETUP self.master_status_png {self.master_status_png}") self.master_status_cyclist = CYCLIST_OF_MECHANDLERS_TEXTURES self.master_status_name_cyclist = cyclist_of_mechandler_texture_names_list self.master_status_index = 0 self.stairs_list = arcade.tilemap.process_layer( my_map, 'Stairs', SPRITE_SCALING_TILES, use_spatial_hash=True, hit_box_algorithm="Detailed") self.enemy_list = arcade.tilemap.process_layer( my_map, 'enemies', SPRITE_SCALING_TILES, use_spatial_hash=True, hit_box_algorithm="Detailed") self.lowfric_list = arcade.tilemap.process_layer( my_map, 'low_friction_platforms', SPRITE_SCALING_TILES, use_spatial_hash=True, hit_box_algorithm="Detailed") startposition_layer_name = 'Startposition' self.startposition_list = arcade.tilemap.process_layer( map_object=my_map, layer_name=startposition_layer_name, scaling=TILE_SCALING, use_spatial_hash=True) start_XY = tuple((self.startposition_list[0].center_x, self.startposition_list[0].center_y)) # Create player sprite self.player_sprite = PlayerSprite(self.ladder_list, hit_box_algorithm="Detailed") # Set player location #grid_x = 1 #grid_y = 1 #grid_x = 7 #grid_y = 15 #self.player_sprite.center_x = SPRITE_SIZE * grid_x + SPRITE_SIZE / 2 #self.player_sprite.center_y = SPRITE_SIZE * grid_y + SPRITE_SIZE / 2 self.player_sprite.center_x = start_XY[0] self.player_sprite.center_y = start_XY[1] # Add to player sprite list self.player_list.append(self.player_sprite) # Moving Sprite self.autonom_moving_sprites_list = arcade.tilemap.process_layer( my_map, 'Moving Platforms', SPRITE_SCALING_TILES) # --- Pymunk Physics Engine Setup --- # The default damping for every object controls the percent of velocity # the object will keep each second. A value of 1.0 is no speed loss, # 0.9 is 10% per second, 0.1 is 90% per second. # For top-down games, this is basically the friction for moving objects. # For platformers with gravity, this should probably be set to 1.0. # Default value is 1.0 if not specified. damping = DEFAULT_DAMPING # Set the gravity. (0, 0) is good for outer space and top-down. gravity = (0, -GRAVITY) # Create the physics engine self.physics_engine = arcade.PymunkPhysicsEngine(damping=damping, gravity=gravity) def wall_hit_handler(bullet_sprite, _wall_sprite, _arbiter, _space, _data): """ Called for bullet/wall collision """ bullet_sprite.remove_from_sprite_lists() self.physics_engine.add_collision_handler( "bullet", "wall", post_handler=wall_hit_handler) def item_hit_handler(bullet_sprite, item_sprite, _arbiter, _space, _data): """ Called for bullet/wall collision """ bullet_sprite.remove_from_sprite_lists() item_sprite.remove_from_sprite_lists() self.physics_engine.add_collision_handler( "bullet", "item", post_handler=item_hit_handler) #def mechanicshandler_hit_handler(self, bullet_sprite, mechandler_sprite, _arbiter, _space, _data): def mechanicshandler_hit_handler(bullet_sprite, mechandler_sprite, _arbiter, _space, _data): """ Called for bullet/wall collision """ bullet_sprite.remove_from_sprite_lists() #print(f"mechandler_sprite.status {mechandler_sprite.status} self.master_status {self.master_status}") print( f"1mechandler_sprite.properties['status'] {mechandler_sprite.properties['status']} self.master_status {self.master_status}" ) #mechandler_sprite.status = leverRight #mechandler_sprite.status = "leverRight" #self.master_status ="leverRight" #self.master_status_index += 1 #self.master_status_cyclist.next() self.master_status_png = next(self.master_status_cyclist) print( f"type(self.master_status_png) {type(self.master_status_png)}" ) #self.master_status_name = next(self.master_status_name) # cyclist_of_mechandler_texture_names_list self.master_status_name = next(self.master_status_name_cyclist) print( f"type(self.master_status_name) {type(self.master_status_name)}" ) #cyclist_of_mechandler_texture_names_list #print(f"self.master_status_png {self.master_status_png}") print( f"2mechandler_sprite.properties['status'] {mechandler_sprite.properties['status']} self.master_status {self.master_status}" ) print("\n") print(f". self.master_status_index {self.master_status_index}") print( f".. self.master_status_cyclist {self.master_status_cyclist}" ) #print(f"... self.master_status_cyclist[self.master_status_index] {self.master_status_cyclist[self.master_status_index]}") CYCLE IS NOT SUSCRIPTABLE self.physics_engine.add_collision_handler( "bullet", "mechandler", post_handler=mechanicshandler_hit_handler) # Add the player. # For the player, we set the damping to a lower value, which increases # the damping rate. This prevents the character from traveling too far # after the player lets off the movement keys. # Setting the moment to PymunkPhysicsEngine.MOMENT_INF prevents it from # rotating. # Friction normally goes between 0 (no friction) and 1.0 (high friction) # Friction is between two objects in contact. It is important to remember # in top-down games that friction moving along the 'floor' is controlled # by damping. self.physics_engine.add_sprite( self.player_sprite, friction=PLAYER_FRICTION, mass=PLAYER_MASS, moment=arcade.PymunkPhysicsEngine.MOMENT_INF, collision_type="player", max_horizontal_velocity=PLAYER_MAX_HORIZONTAL_SPEED, max_vertical_velocity=PLAYER_MAX_VERTICAL_SPEED) # Create the walls. # By setting the body type to PymunkPhysicsEngine.STATIC the walls can't # move. # Movable objects that respond to forces are PymunkPhysicsEngine.DYNAMIC # PymunkPhysicsEngine.KINEMATIC objects will move, but are assumed to be # repositioned by code and don't respond to physics forces. # Dynamic is default. self.physics_engine.add_sprite_list( self.wall_list, friction=WALL_FRICTION, collision_type="wall", body_type=arcade.PymunkPhysicsEngine.STATIC) self.physics_engine.add_sprite_list( self.lowfric_list, friction=ICE_FRICTION, collision_type="ice", body_type=arcade.PymunkPhysicsEngine.STATIC) # Create the items self.physics_engine.add_sprite_list(self.coins_list, friction=DYNAMIC_ITEM_FRICTION, collision_type="item") self.physics_engine.add_sprite_list( self.trap_list, friction=WALL_FRICTION, #collision_type="wall", collision_type="traps", body_type=arcade.PymunkPhysicsEngine.STATIC) self.physics_engine.add_sprite_list( self.key_lock_door_list, friction=WALL_FRICTION, #collision_type="wall", collision_type="kld", body_type=arcade.PymunkPhysicsEngine.STATIC) self.physics_engine.add_sprite_list( self.mechandler_list, friction=WALL_FRICTION, #collision_type="wall", collision_type="mechandler", body_type=arcade.PymunkPhysicsEngine.STATIC) # Add kinematic sprites self.physics_engine.add_sprite_list( self.mechanics_list, body_type=arcade.PymunkPhysicsEngine.KINEMATIC)
def setup(self): # Sprite lists # self.wall_list = arcade.SpriteList() # self.coin_list = arcade.SpriteList() self.background = arcade.load_texture("back.jpg") self.coin_list = arcade.SpriteList() self.splash_list = arcade.SpriteList() # Here is First snail creaeted at x = 35 , y =35 coin = arcade.Sprite("snailone.png") # Creating a splash splash = arcade.Sprite("splash.png") """ x = 35 , y = 35 and add 70 to loop through """ coin.center_x = COIN_START_SCALE coin.center_y = COIN_START_SCALE splash.center_x = COIN_START_SCALE splash.center_y = COIN_START_SCALE splash.scale = 0.131 coin.scale = 0.13 print(coin.bottom) print(coin.left) print(coin.width) print(coin.height) self.coin_list.append(coin) self.splash_list.append(splash) # First snail done # # Generate Sprite in loop in x axis # self.coin_list.append(coin) # for x in range(35,SCREEN_WIDTH,70): # coin = arcade.Sprite("snailone.png") # coin.scale = 0.13 # coin.center_x = x # coin.center_y = 35 # self.coin_list.append(coin) # # Generate Sprite in loop in y axis # for x in range(SCREEN_WIDTH-35 , 0, -70): # coin = arcade.Sprite("snailtwo.png",mirrored=True) # coin.scale = 0.13 # coin.center_x = x # coin.center_y = SCREEN_HEIGHT - 35 # self.coin_list.append(coin) # Set the background color arcade.set_background_color(arcade.color.AMAZON) # list for all possible x places for sprite list_for_x = [] for x in range(COIN_START_SCALE, SCREEN_WIDTH, 70): list_for_x.append(x) print(list_for_x) # list for all possible y places for sprite list_for_y = [] for y in range(COIN_START_SCALE, SCREEN_HEIGHT, 70): list_for_y.append(y) print(list_for_y)
def setup(self): """Set up the game and initialize the variables""" # Sprite lists self.player_list = arcade.SpriteList() self.alien_list = arcade.SpriteList() self.wall_list = arcade.SpriteList() self.level = INSTRUCTIONS # Set up the player self.player_sprite = Player() self.player_list.append(self.player_sprite) # Create the aliens # This code assumes you make multiple aliens. This shows you how you can do so for i in range(NUMBER_ALIENS): alien = Alien() # Position the alien randomly alien.center_x = random.randrange(WALL_WIDTH, SCREEN_WIDTH - WALL_WIDTH) alien.center_y = random.randrange(WALL_WIDTH, SCREEN_HEIGHT - WALL_WIDTH) # Add the alien to the alien list self.alien_list.append(alien) """# Create the walls self.leftWall = Wall("vertical") self.leftWall.center_x = 0 self.leftWall.center_y = SCREEN_HEIGHT // 2 self.wall_list.append(self.leftWall) self.topWall = Wall("horizontal") self.topWall.center_x = SCREEN_WIDTH // 2 self.topWall.center_y = SCREEN_HEIGHT self.wall_list.append(self.topWall) self.rightWall = Wall("vertical") self.rightWall.center_x = SCREEN_WIDTH self.rightWall.center_y = SCREEN_HEIGHT // 2 self.wall_list.append(self.rightWall) self.bottomWall = Wall("horizontal") self.bottomWall.center_x = SCREEN_WIDTH // 2 self.bottomWall.center_y = 100 self.wall_list.append(self.bottomWall)""" # Create a top row of boxes for x in range(0, SCREEN_WIDTH, 35): self.topWall = Wall() self.topWall.center_x = x self.topWall.center_y = SCREEN_HEIGHT - 10 if x == 350 or x == 385 or x == 420 or x == 455: self.topWall.kill() else: self.wall_list.append(self.topWall) # Create a bottom row of boxes for x in range(0, SCREEN_WIDTH, 35): self.bottomWall = Wall() self.bottomWall.center_x = x self.bottomWall.center_y = 15 if x == 350 or x == 385 or x == 420 or x == 455: self.bottomWall.kill() else: self.wall_list.append(self.bottomWall) # Create a right column of boxes for y in range(0, SCREEN_HEIGHT + 1, 35): self.rightWall = Wall() self.rightWall.center_x = SCREEN_WIDTH - 10 self.rightWall.center_y = y if y == 280 or y == 315 or y == 350 or y == 385: self.rightWall.kill() else: self.wall_list.append(self.rightWall) # Create a left column of boxes for y in range(0, SCREEN_HEIGHT, 35): self.leftWall = Wall() self.leftWall.center_x = 15 self.leftWall.center_y = y if y == 280 or y == 315 or y == 350 or y == 385: self.leftWall.kill() else: self.wall_list.append(self.leftWall)
import pathlib import random import main import os import math from pathfinding import * """Global Variables""" image_location = pathlib.Path.cwd() / 'images' sound_loction = pathlib.Path.cwd() / 'sounds' launch_sound_1 = arcade.load_sound(str(sound_loction) + "/launch1.wav") launch_sound_2 = arcade.load_sound(str(sound_loction) + "/launch2.wav") launch_sound_3 = arcade.load_sound(str(sound_loction) + "/launch3.wav") launch_sound_4 = arcade.load_sound(str(sound_loction) + "/launch4.wav") enemy_list = arcade.SpriteList() tower_list = arcade.SpriteList() bullet_list = arcade.SpriteList() explosion_list = arcade.SpriteList() traps_list = arcade.SpriteList() #All Towers, Projectile and Explosinos assests by Chisel Mark #https://www.dafont.com/chisel-mark.font class Projectial(arcade.Sprite): def __init__(self, scale, x_pos, y_pos, imageFileName, angle): super().__init__(scale=scale, center_x=x_pos, center_y=y_pos, filename=imageFileName)