def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcadeplus.SpriteList() self.coin_list = arcadeplus.SpriteList() self.bullet_list = arcadeplus.SpriteList() # Set up the player self.score = 0 # Image from kenney.nl self.player_sprite = arcadeplus.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING_PLAYER) self.player_sprite.center_x = 50 self.player_sprite.center_y = 70 self.player_list.append(self.player_sprite) # Create the coins for i in range(COIN_COUNT): # Create the coin instance # Coin image from kenney.nl coin = arcadeplus.Sprite(":resources:images/items/coinGold.png", SPRITE_SCALING_COIN) # Position the coin coin.center_x = random.randrange(SCREEN_WIDTH) coin.center_y = random.randrange(120, SCREEN_HEIGHT) # Add the coin to the lists self.coin_list.append(coin) # Set the background color arcadeplus.set_background_color(arcadeplus.color.AMAZON)
def __init__(self): super().__init__() self.time_taken = 0 # Sprite lists self.player_list = arcadeplus.SpriteList() self.coin_list = arcadeplus.SpriteList() # Set up the player self.score = 0 self.player_sprite = arcadeplus.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING) self.player_sprite.center_x = 50 self.player_sprite.center_y = 50 self.player_list.append(self.player_sprite) for i in range(5): # Create the coin instance coin = arcadeplus.Sprite(":resources:images/items/coinGold.png", SPRITE_SCALING / 3) # Position the coin coin.center_x = random.randrange(WIDTH) coin.center_y = random.randrange(HEIGHT) # Add the coin to the lists self.coin_list.append(coin)
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcadeplus.SpriteList() self.coin_list = arcadeplus.SpriteList() # Score self.score = 0 # Set up the player # Character image from kenney.nl self.player_sprite = arcadeplus.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING_PLAYER) self.player_sprite.center_x = 50 self.player_sprite.center_y = 50 self.player_list.append(self.player_sprite) # Create the coins for i in range(COIN_COUNT): # Create the coin instance # Coin image from kenney.nl coin = arcadeplus.Sprite(":resources:images/items/coinGold.png", SPRITE_SCALING_COIN) # Position the coin coin.center_x = random.randrange(SCREEN_WIDTH) coin.center_y = random.randrange(SCREEN_HEIGHT) # Set up the initial angle, and the "spin" coin.angle = random.randrange(360) coin.change_angle = random.randrange(-5, 6) # Add the coin to the lists self.coin_list.append(coin)
def __init__(self, width, height, title): super().__init__(width, height, title) file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) arcadeplus.set_background_color(arcadeplus.color.AMAZON) self.character_list = arcadeplus.SpriteList() self.character_sprite = arcadeplus.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", CHARACTER_SCALING) self.character_sprite.center_x = 250 self.character_sprite.center_y = 250 self.character_sprite.change_x = 5 self.character_sprite.change_y = 5 self.character_list.append(self.character_sprite) self.wall_list = arcadeplus.SpriteList() sprite = arcadeplus.Sprite( ":resources:images/tiles/boxCrate_double.png", CHARACTER_SCALING) sprite.position = (330, 330) sprite.angle = 90 self.wall_list.append(sprite) sprite = arcadeplus.Sprite( ":resources:images/tiles/boxCrate_double.png", CHARACTER_SCALING) sprite.position = (170, 170) sprite.angle = 45 self.wall_list.append(sprite) self.physics_engine = arcadeplus.PhysicsEngineSimple( self.character_sprite, self.wall_list)
def setup(self): """ Set up the game here. Call this function to restart the game. """ # Create the Sprite lists self.player_list = arcadeplus.SpriteList() self.wall_list = arcadeplus.SpriteList() self.coin_list = arcadeplus.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 = arcadeplus.Sprite(image_source, CHARACTER_SCALING) self.player_sprite.center_x = 64 self.player_sprite.center_y = 128 self.player_list.append(self.player_sprite) # Create the ground # This shows using a loop to place multiple sprites horizontally for x in range(0, 1250, 64): wall = arcadeplus.Sprite(":resources:images/tiles/grassMid.png", TILE_SCALING) wall.center_x = x wall.center_y = 32 self.wall_list.append(wall) # Put some crates on the ground # This shows using a coordinate list to place sprites coordinate_list = [[512, 96], [256, 96], [768, 96]] for coordinate in coordinate_list: # Add a crate on the ground wall = arcadeplus.Sprite( ":resources:images/tiles/boxCrate_double.png", TILE_SCALING) wall.position = coordinate self.wall_list.append(wall)
def setup(self): self.enemy_list = arcadeplus.SpriteList() self.bullet_list = arcadeplus.SpriteList() self.player_list = arcadeplus.SpriteList() # Add player ship self.player = arcadeplus.Sprite( ":resources:images/space_shooter/playerShip1_orange.png", 0.5) self.player_list.append(self.player) # Add top-left enemy ship enemy = arcadeplus.Sprite( ":resources:images/space_shooter/playerShip1_green.png", 0.5) enemy.center_x = 120 enemy.center_y = SCREEN_HEIGHT - enemy.height enemy.angle = 180 self.enemy_list.append(enemy) # Add top-right enemy ship enemy = arcadeplus.Sprite( ":resources:images/space_shooter/playerShip1_green.png", 0.5) enemy.center_x = SCREEN_WIDTH - 120 enemy.center_y = SCREEN_HEIGHT - enemy.height enemy.angle = 180 self.enemy_list.append(enemy)
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcadeplus.SpriteList() self.coin_list = arcadeplus.SpriteList() # Set up the player # Character image from kenney.nl self.player_sprite = arcadeplus.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING_PLAYER) self.player_sprite.center_x = 50 self.player_sprite.center_y = 150 self.player_list.append(self.player_sprite) # Create the sprites for x in range(100, 800, 100): coin = arcadeplus.Sprite(":resources:images/items/coinGold.png", scale=0.3, center_x=x, center_y=400) coin.intensity = 'dim' coin.alpha = 64 self.coin_list.append(coin) # Create trigger self.trigger_sprite = arcadeplus.Sprite( ":resources:images/pinball/bumper.png", scale=0.5, center_x=750, center_y=50)
def setup(self): """ Set up the game and initialize the variables. """ # Load the background image. Do this in the setup so we don't keep reloading it all the time. # Image from: # http://wallpaper-gallery.net/single/free-background-images/free-background-images-22.html self.background = arcadeplus.load_texture( ":resources:images/backgrounds/abstract_1.jpg") # Sprite lists self.player_list = arcadeplus.SpriteList() self.coin_list = arcadeplus.SpriteList() # Set up the player self.score = 0 self.player_sprite = arcadeplus.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", PLAYER_SCALING) self.player_sprite.center_x = 50 self.player_sprite.center_y = 50 self.player_list.append(self.player_sprite) for i in range(50): # Create the coin instance coin = arcadeplus.Sprite(":resources:images/items/coinGold.png", COIN_SCALING) # Position the coin coin.center_x = random.randrange(SCREEN_WIDTH) coin.center_y = random.randrange(SCREEN_HEIGHT) # Add the coin to the lists self.coin_list.append(coin)
def __init__(self, width, height, title): super().__init__(width, height, title) file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) arcadeplus.set_background_color(arcadeplus.color.AMAZON) self.character_list = arcadeplus.SpriteList() self.character_sprite = arcadeplus.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", CHARACTER_SCALING) self.character_sprite.center_x = 150 self.character_sprite.center_y = 110 self.character_list.append(self.character_sprite) self.wall_list = arcadeplus.SpriteList() for x in range(0, 1200, 64): sprite = arcadeplus.Sprite( ":resources:images/tiles/boxCrate_double.png", CHARACTER_SCALING) sprite.center_x = x sprite.center_y = 32 self.wall_list.append(sprite) self.physics_engine = arcadeplus.PhysicsEnginePlatformer( self.character_sprite, self.wall_list, gravity_constant=GRAVITY)
def test_sprite_collides_with_list(): coins = arcadeplus.SpriteList() for x in range(0, 50, 10): coin = arcadeplus.Sprite(center_x=x, center_y=0) coin.width = 10 coin.height = 10 coins.append(coin) player = arcadeplus.Sprite(center_x=100, center_y=100) player.width = 10 player.height = 10 # collides with none result = player.collides_with_list(coins) assert len(result) == 0, "Should return empty list" # collides with one player.center_x = -5 player.center_y = 0 result = player.collides_with_list(coins) assert len(result) == 1, "Should collide with one" # collides with two player.center_x = 5 result = player.collides_with_list(coins) assert len(result) == 2, "Should collide with two"
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcadeplus.SpriteList() self.wall_list = arcadeplus.SpriteList() # Set up the player self.player_sprite = arcadeplus.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING) self.player_sprite.center_x = 50 self.player_sprite.center_y = 64 self.player_list.append(self.player_sprite) # -- Set up the walls # Create a row of boxes for x in range(173, 650, 64): wall = arcadeplus.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING) wall.center_x = x wall.center_y = 200 self.wall_list.append(wall) # Create a column of boxes for y in range(273, 500, 64): wall = arcadeplus.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING) wall.center_x = 465 wall.center_y = y self.wall_list.append(wall) self.physics_engine = arcadeplus.PhysicsEngineSimple(self.player_sprite, self.wall_list) # Set the background color arcadeplus.set_background_color(arcadeplus.color.AMAZON)
def setup(self): """ 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 = arcadeplus.SpriteList() self.wall_list = arcadeplus.SpriteList() self.coin_list = arcadeplus.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 = arcadeplus.Sprite(image_source, CHARACTER_SCALING) self.player_sprite.center_x = 64 self.player_sprite.center_y = 96 self.player_list.append(self.player_sprite) # Create the ground # This shows using a loop to place multiple sprites horizontally for x in range(0, 1250, 64): wall = arcadeplus.Sprite(":resources:images/tiles/grassMid.png", TILE_SCALING) wall.center_x = x wall.center_y = 32 self.wall_list.append(wall) # Put some crates on the ground # This shows using a coordinate list to place sprites coordinate_list = [[512, 96], [256, 96], [768, 96]] for coordinate in coordinate_list: # Add a crate on the ground wall = arcadeplus.Sprite(":resources:images/tiles/boxCrate_double.png", TILE_SCALING) wall.position = coordinate self.wall_list.append(wall) # Use a loop to place some coins for our character to pick up for x in range(128, 1250, 256): coin = arcadeplus.Sprite(":resources:images/items/coinGold.png", COIN_SCALING) coin.center_x = x coin.center_y = 96 self.coin_list.append(coin) # Create the 'physics engine' self.physics_engine = arcadeplus.PhysicsEnginePlatformer(self.player_sprite, self.wall_list, GRAVITY)
def setup_level_one(self): # Load the textures for the enemies, one facing left, one right self.enemy_textures = [] texture = arcadeplus.load_texture( ":resources:images/enemies/slimeBlue.png", mirrored=True) self.enemy_textures.append(texture) texture = arcadeplus.load_texture( ":resources:images/enemies/slimeBlue.png") self.enemy_textures.append(texture) # Create rows and columns of enemies x_count = 7 x_start = 380 x_spacing = 60 y_count = 5 y_start = 420 y_spacing = 40 for x in range(x_start, x_spacing * x_count + x_start, x_spacing): for y in range(y_start, y_spacing * y_count + y_start, y_spacing): # Create the enemy instance # enemy image from kenney.nl enemy = arcadeplus.Sprite() enemy.scale = SPRITE_SCALING_enemy enemy.texture = self.enemy_textures[1] # Position the enemy enemy.center_x = x enemy.center_y = y # Add the enemy to the lists self.enemy_list.append(enemy)
def __init__(self): super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # Set the working directory (where we expect to find files) to the same # directory this .py file is in. You can leave this out of your own # code, but it is needed to easily run the examples using "python -m" # as mentioned at the top of this program. file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) arcadeplus.set_background_color(arcadeplus.color.BLACK) # collect particle factory functions self.factories = [ v for k, v in globals().items() if k.startswith("emitter_") ] self.emitter_factory_id = -1 self.label = None self.emitter = None self.emitter_timeout = 0 self.obj = arcadeplus.Sprite(":resources:images/pinball/bumper.png", 0.2, center_x=0, center_y=15) self.obj.change_x = 3 self.frametime_plotter = FrametimePlotter() pyglet.clock.schedule_once(self.next_emitter, QUIET_BETWEEN_SPAWNS)
def on_mouse_press(self, x, y, button, modifiers): """ Called whenever the mouse button is clicked. """ # Gunshot sound arcadeplus.sound.play_sound(self.gun_sound) # Create a bullet bullet = arcadeplus.Sprite( ":resources:images/space_shooter/laserBlue01.png", SPRITE_SCALING_LASER) # The image points to the right, and we want it to point up. So # rotate it. bullet.angle = 90 # Give it a speed bullet.change_y = BULLET_SPEED # Position the bullet bullet.center_x = self.player_sprite.center_x bullet.bottom = self.player_sprite.top # Add the bullet to the appropriate lists self.bullet_list.append(bullet)
def setup(self): """ Set up the game and initialize the variables. Call this method if you implement a 'play again' feature. """ self.game_state = PLAY_GAME # Sprite lists self.player_list = arcadeplus.SpriteList() self.enemy_list = arcadeplus.SpriteList() self.player_bullet_list = arcadeplus.SpriteList() self.enemy_bullet_list = arcadeplus.SpriteList() self.shield_list = arcadeplus.SpriteList(is_static=True) # Set up the player self.score = 0 # Image from kenney.nl self.player_sprite = arcadeplus.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING_PLAYER) self.player_sprite.center_x = 50 self.player_sprite.center_y = 40 self.player_list.append(self.player_sprite) # Make each of the shields for x in range(75, 800, 190): self.make_shield(x) # Set the background color arcadeplus.set_background_color(arcadeplus.color.AMAZON) self.setup_level_one()
def __init__(self): # setup my_sprite = arcadeplus.Sprite() hit_box = [-10, -10], [-10, 10], [10, 10], [10, -10] my_sprite.set_hit_box(hit_box) my_sprite.scale = 1.0 my_sprite.angle = 0 my_sprite.center_x = 100 my_sprite.center_y = 100 print() hitbox = my_sprite.get_adjusted_hit_box() print(f'Hitbox: {my_sprite.scale} -> {my_sprite._points} -> {hitbox}') assert hitbox == [[90, 90], [90, 110], [110, 110], [110, 90]] my_sprite.scale = 0.5 hitbox = my_sprite.get_adjusted_hit_box() print(f'Hitbox: {my_sprite.scale} -> {my_sprite._points} -> {hitbox}') assert hitbox == [[95, 95], [95, 105], [105, 105], [105, 95]] my_sprite.scale = 1 hitbox = my_sprite.get_adjusted_hit_box() print(f'Hitbox: {my_sprite.scale} -> {my_sprite._points} -> {hitbox}') assert hitbox == [[90, 90], [90, 110], [110, 110], [110, 90]] my_sprite.scale = 2.0 hitbox = my_sprite.get_adjusted_hit_box() print(f'Hitbox: {my_sprite.scale} -> {my_sprite._points} -> {hitbox}') assert hitbox == [[80, 80], [80, 120], [120, 120], [120, 80]] my_sprite.scale = 2.0 hitbox = my_sprite.get_adjusted_hit_box() print(f'Hitbox: {my_sprite.scale} -> {my_sprite._points} -> {hitbox}') assert hitbox == [[80, 80], [80, 120], [120, 120], [120, 80]]
def spawn_bullet(self, angle_in_deg): # only allow bullet to spawn on an interval if self.bullet_cooldown < BULLET_COOLDOWN_TICKS: return self.bullet_cooldown = 0 bullet = arcadeplus.Sprite( ":resources:images/space_shooter/laserBlue01.png", 0.75) # Position the bullet at the player's current location start_x = self.player.center_x start_y = self.player.center_y bullet.center_x = start_x bullet.center_y = start_y # angle the bullet visually bullet.angle = angle_in_deg angle_in_rad = math.radians(angle_in_deg) # set bullet's movement direction bullet.change_x = math.cos(angle_in_rad) * BULLET_SPEED bullet.change_y = math.sin(angle_in_rad) * BULLET_SPEED # Add the bullet to the appropriate lists self.bullet_list.append(bullet)
def test_sprite_collides_with_sprite(): sprite_one = arcadeplus.Sprite(center_x=0, center_y=0) sprite_one.width = 10 sprite_one.height = 10 # print() # print("--------------", sprite_one.get_adjusted_hit_box()) sprite_two = arcadeplus.Sprite(center_x=5, center_y=5) sprite_two.width = 10 sprite_two.height = 10 # print("--------------", sprite_two.get_adjusted_hit_box()) assert sprite_one.collides_with_sprite(sprite_two) is True sprite_one.center_x = -5 assert sprite_one.collides_with_sprite(sprite_two) is False
def setup(self): """ Set up the game and initialize the variables. """ # Sprite lists self.player_list = arcadeplus.SpriteList() self.coin_list = arcadeplus.SpriteList() # Set up the player self.score = 0 self.player_sprite = arcadeplus.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", 0.5) self.player_sprite.center_x = 50 self.player_sprite.center_y = 50 self.player_list.append(self.player_sprite) for i in range(50): # Create the coin instance coin = Collectable(":resources:images/items/coinGold.png", SPRITE_SCALING) coin.width = 30 coin.height = 30 # Position the coin coin.center_x = random.randrange(SCREEN_WIDTH) coin.center_y = random.randrange(SCREEN_HEIGHT) # Add the coin to the lists self.coin_list.append(coin) # Don't show the mouse cursor self.set_mouse_visible(False) # Set the background color arcadeplus.set_background_color(arcadeplus.color.AMAZON)
def __init__(self): super().__init__() self.player_sprite = arcadeplus.Sprite( ":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING) self.player_sprite.center_x = 50 self.player_sprite.center_y = 50 self.player_sprite.velocity = [3, 3]
def setup_room_1(): """ Create and return room 1. If your program gets large, you may want to separate this into different files. """ room = Room() """ Set up the game and initialize the variables. """ # Sprite lists room.wall_list = arcadeplus.SpriteList() # -- Set up the walls # Create bottom and top row of boxes # This y loops a list of two, the coordinate 0, and just under the top of window for y in (0, SCREEN_HEIGHT - SPRITE_SIZE): # Loop for each box going across for x in range(0, SCREEN_WIDTH, SPRITE_SIZE): wall = arcadeplus.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING) wall.left = x wall.bottom = y room.wall_list.append(wall) # Create left and right column of boxes for x in (0, SCREEN_WIDTH - SPRITE_SIZE): # Loop for each box going across for y in range(SPRITE_SIZE, SCREEN_HEIGHT - SPRITE_SIZE, SPRITE_SIZE): # Skip making a block 4 and 5 blocks up on the right side if (y != SPRITE_SIZE * 4 and y != SPRITE_SIZE * 5) or x == 0: wall = arcadeplus.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING) wall.left = x wall.bottom = y room.wall_list.append(wall) wall = arcadeplus.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING) wall.left = 7 * SPRITE_SIZE wall.bottom = 5 * SPRITE_SIZE room.wall_list.append(wall) # If you want coins or monsters in a level, then add that code here. # Load the background image for this level. room.background = arcadeplus.load_texture(":resources:images/backgrounds/abstract_1.jpg") return room
def test_it_can_extend_a_spritelist(): spritelist = arcadeplus.SpriteList() sprites = [] for i in range(10): sprites.append(arcadeplus.Sprite()) spritelist.extend(sprites) assert len(spritelist) == 10 assert spritelist._vao1 is None
def test_it_can_insert_in_a_spritelist(): spritelist = make_named_sprites(2) sprite = arcadeplus.Sprite() sprite.name = 2 spritelist.insert(1, sprite) assert [s.name for s in spritelist] == [0, 2, 1] assert [spritelist.sprite_idx[s] for s in spritelist] == [0, 1, 2] assert spritelist._vao1 is None
def make_named_sprites(amount): spritelist = arcadeplus.SpriteList() sprites = [] for i in range(amount): sprite = arcadeplus.Sprite() sprite.name = i sprites.append(sprite) spritelist.extend(sprites) return spritelist
def on_update(self, delta_time): """All the logic to move, and the game logic goes here. """ self.frame_count += 1 # Loop through each enemy that we have for enemy in self.enemy_list: # First, calculate the angle to the player. We could do this # only when the bullet fires, but in this case we will rotate # the enemy to face the player each frame, so we'll do this # each frame. # Position the start at the enemy's current location start_x = enemy.center_x start_y = enemy.center_y # Get the destination location for the bullet dest_x = self.player.center_x dest_y = self.player.center_y # Do math to calculate how to get the bullet to the destination. # Calculation the angle in radians between the start points # and end points. This is the angle the bullet will travel. x_diff = dest_x - start_x y_diff = dest_y - start_y angle = math.atan2(y_diff, x_diff) # Set the enemy to face the player. enemy.angle = math.degrees(angle) - 90 # Shoot every 60 frames change of shooting each frame if self.frame_count % 60 == 0: bullet = arcadeplus.Sprite( ":resources:images/space_shooter/laserBlue01.png") bullet.center_x = start_x bullet.center_y = start_y # Angle the bullet sprite bullet.angle = math.degrees(angle) # Taking into account the angle, calculate our change_x # and change_y. Velocity is how fast the bullet travels. bullet.change_x = math.cos(angle) * BULLET_SPEED bullet.change_y = math.sin(angle) * BULLET_SPEED self.bullet_list.append(bullet) # Get rid of the bullet when it flies off-screen for bullet in self.bullet_list: if bullet.top < 0: bullet.remove_from_sprite_lists() self.bullet_list.update()
def read_sprite_list(grid, sprite_list): for row in grid: for grid_location in row: if grid_location.tile is not None: tile_sprite = arcadeplus.Sprite( "../resources/images/" + grid_location.tile.source, SPRITE_SCALING) tile_sprite.center_x = grid_location.center_x * SPRITE_SCALING tile_sprite.center_y = grid_location.center_y * SPRITE_SCALING # print(f"{grid_location.tile.source} -- ({tile_sprite.center_x:4}, {tile_sprite.center_y:4})") sprite_list.append(tile_sprite)
def __init__(self, width, height, title): super().__init__(width, height, title) arcadeplus.set_background_color(arcadeplus.color.AMAZON) self.sprite = arcadeplus.Sprite(":resources:images/items/coinGold.png", CHARACTER_SCALING) self.sprite.center_x = 50 self.sprite.center_y = 50 self.sprite_list = arcadeplus.SpriteList() self.sprite_list.append(self.sprite)
def setup(self): """ Setup """ self.ship = arcadeplus.Sprite( ":resources:images/space_shooter/playerShip1_orange.png", 0.5) self.ship.center_x = SCREEN_WIDTH / 2 self.ship.center_y = SCREEN_HEIGHT / 2 self.ship.angle = 270 self.xy_square = arcadeplus.load_texture( ":resources:images/test_textures/xy_square.png") # Set the background color arcadeplus.set_background_color(arcadeplus.color.BLACK)
def level_1(self): for i in range(20): # Create the coin instance coin = arcadeplus.Sprite(":resources:images/items/coinGold.png", SPRITE_SCALING / 3) # Position the coin coin.center_x = random.randrange(SCREEN_WIDTH) coin.center_y = random.randrange(SCREEN_HEIGHT) # Add the coin to the lists self.coin_list.append(coin)