Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions arcade/examples/platform_tutorial/12_animate_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class PlayerCharacter(arcade.Sprite):
"""Player Sprite"""

def __init__(self):

# Set up parent class
super().__init__()

Expand Down Expand Up @@ -94,12 +93,19 @@ def __init__(self):
self.texture = self.idle_texture_pair[0]

# Hit box will be set based on the first image used. If you want to specify
# a different hit box, you can do it like the code below.
# set_hit_box = [[-22, -64], [22, -64], [22, 28], [-22, 28]]
self.hit_box = self.texture.hit_box_points
# a different hit box, you can do it like the code below. Doing this when
# changing the texture for example would make the hitbox update whenever the
# texture is changed. This can be expensive so if the textures are very similar
# it may not be worth doing.
#
# self.hit_box = arcade.hitbox.RotatableHitBox(
# self.texture.hit_box_points,
# position=self.position,
# scale=self.scale_xy,
# angle=self.angle,
# )

def update_animation(self, delta_time: float = 1 / 60):

# Figure out if we need to flip face left or right
if self.change_x < 0 and self.character_face_direction == RIGHT_FACING:
self.character_face_direction = LEFT_FACING
Expand Down Expand Up @@ -245,7 +251,7 @@ def setup(self):
platforms=self.scene[LAYER_NAME_MOVING_PLATFORMS],
gravity_constant=GRAVITY,
ladders=self.scene[LAYER_NAME_LADDERS],
walls=self.scene[LAYER_NAME_PLATFORMS]
walls=self.scene[LAYER_NAME_PLATFORMS],
)

def on_draw(self):
Expand Down Expand Up @@ -389,7 +395,6 @@ def on_update(self, delta_time):

# Loop through each coin we hit (if any) and remove it
for coin in coin_hit_list:

# Figure out how many points this coin is worth
if "Points" not in coin.properties:
print("Warning, collected a coin without a Points property.")
Expand Down
22 changes: 12 additions & 10 deletions arcade/examples/platform_tutorial/13_add_enemies.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,33 @@ def __init__(self, name_folder, name_file):
self.texture = self.idle_texture_pair[0]

# Hit box will be set based on the first image used. If you want to specify
# a different hit box, you can do it like the code below.
# set_hit_box = [[-22, -64], [22, -64], [22, 28], [-22, 28]]
self.hit_box = self.texture.hit_box_points
# a different hit box, you can do it like the code below. Doing this when
# changing the texture for example would make the hitbox update whenever the
# texture is changed. This can be expensive so if the textures are very similar
# it may not be worth doing.
#
# self.hit_box = arcade.hitbox.RotatableHitBox(
# self.texture.hit_box_points,
# position=self.position,
# scale=self.scale_xy,
# angle=self.angle,
# )


class Enemy(Entity):
def __init__(self, name_folder, name_file):

# Setup parent class
super().__init__(name_folder, name_file)


class RobotEnemy(Enemy):
def __init__(self):

# Set up parent class
super().__init__("robot", "robot")


class ZombieEnemy(Enemy):
def __init__(self):

# Set up parent class
super().__init__("zombie", "zombie")

Expand All @@ -115,7 +120,6 @@ class PlayerCharacter(Entity):
"""Player Sprite"""

def __init__(self):

# Set up parent class
super().__init__("male_person", "malePerson")

Expand All @@ -125,7 +129,6 @@ def __init__(self):
self.is_on_ladder = False

def update_animation(self, delta_time: float = 1 / 60):

# Figure out if we need to flip face left or right
if self.change_x < 0 and self.facing_direction == RIGHT_FACING:
self.facing_direction = LEFT_FACING
Expand Down Expand Up @@ -295,7 +298,7 @@ def setup(self):
platforms=self.scene[LAYER_NAME_MOVING_PLATFORMS],
gravity_constant=GRAVITY,
ladders=self.scene[LAYER_NAME_LADDERS],
walls=self.scene[LAYER_NAME_PLATFORMS]
walls=self.scene[LAYER_NAME_PLATFORMS],
)

def on_draw(self):
Expand Down Expand Up @@ -439,7 +442,6 @@ def on_update(self, delta_time):

# Loop through each coin we hit (if any) and remove it
for coin in coin_hit_list:

# Figure out how many points this coin is worth
if "Points" not in coin.properties:
print("Warning, collected a coin without a Points property.")
Expand Down
23 changes: 12 additions & 11 deletions arcade/examples/platform_tutorial/14_moving_enemies.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,27 @@ def __init__(self, name_folder, name_file):
self.texture = self.idle_texture_pair[0]

# Hit box will be set based on the first image used. If you want to specify
# a different hit box, you can do it like the code below.
# self.set_hit_box([[-22, -64], [22, -64], [22, 28], [-22, 28]])
self.set_hit_box(self.texture.hit_box_points)
# a different hit box, you can do it like the code below. Doing this when
# changing the texture for example would make the hitbox update whenever the
# texture is changed. This can be expensive so if the textures are very similar
# it may not be worth doing.
#
# self.hit_box = arcade.hitbox.RotatableHitBox(
# self.texture.hit_box_points,
# position=self.position,
# scale=self.scale_xy,
# angle=self.angle,
# )


class Enemy(Entity):
def __init__(self, name_folder, name_file):

# Setup parent class
super().__init__(name_folder, name_file)

self.should_update_walk = 0

def update_animation(self, delta_time: float = 1 / 60):

# Figure out if we need to flip face left or right
if self.change_x < 0 and self.facing_direction == RIGHT_FACING:
self.facing_direction = LEFT_FACING
Expand All @@ -131,14 +137,12 @@ def update_animation(self, delta_time: float = 1 / 60):

class RobotEnemy(Enemy):
def __init__(self):

# Set up parent class
super().__init__("robot", "robot")


class ZombieEnemy(Enemy):
def __init__(self):

# Set up parent class
super().__init__("zombie", "zombie")

Expand All @@ -147,7 +151,6 @@ class PlayerCharacter(Entity):
"""Player Sprite"""

def __init__(self):

# Set up parent class
super().__init__("male_person", "malePerson")

Expand All @@ -157,7 +160,6 @@ def __init__(self):
self.is_on_ladder = False

def update_animation(self, delta_time: float = 1 / 60):

# Figure out if we need to flip face left or right
if self.change_x < 0 and self.facing_direction == RIGHT_FACING:
self.facing_direction = LEFT_FACING
Expand Down Expand Up @@ -331,7 +333,7 @@ def setup(self):
platforms=self.scene[LAYER_NAME_MOVING_PLATFORMS],
gravity_constant=GRAVITY,
ladders=self.scene[LAYER_NAME_LADDERS],
walls=self.scene[LAYER_NAME_PLATFORMS]
walls=self.scene[LAYER_NAME_PLATFORMS],
)

def on_draw(self):
Expand Down Expand Up @@ -497,7 +499,6 @@ def on_update(self, delta_time):

# Loop through each coin we hit (if any) and remove it
for coin in coin_hit_list:

# Figure out how many points this coin is worth
if "Points" not in coin.properties:
print("Warning, collected a coin without a Points property.")
Expand Down
23 changes: 12 additions & 11 deletions arcade/examples/platform_tutorial/15_collision_with_enemies.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,27 @@ def __init__(self, name_folder, name_file):
self.texture = self.idle_texture_pair[0]

# Hit box will be set based on the first image used. If you want to specify
# a different hit box, you can do it like the code below.
# self.set_hit_box([[-22, -64], [22, -64], [22, 28], [-22, 28]])
self.set_hit_box(self.texture.hit_box_points)
# a different hit box, you can do it like the code below. Doing this when
# changing the texture for example would make the hitbox update whenever the
# texture is changed. This can be expensive so if the textures are very similar
# it may not be worth doing.
#
# self.hit_box = arcade.hitbox.RotatableHitBox(
# self.texture.hit_box_points,
# position=self.position,
# scale=self.scale_xy,
# angle=self.angle,
# )


class Enemy(Entity):
def __init__(self, name_folder, name_file):

# Setup parent class
super().__init__(name_folder, name_file)

self.should_update_walk = 0

def update_animation(self, delta_time: float = 1 / 60):

# Figure out if we need to flip face left or right
if self.change_x < 0 and self.facing_direction == RIGHT_FACING:
self.facing_direction = LEFT_FACING
Expand All @@ -131,14 +137,12 @@ def update_animation(self, delta_time: float = 1 / 60):

class RobotEnemy(Enemy):
def __init__(self):

# Set up parent class
super().__init__("robot", "robot")


class ZombieEnemy(Enemy):
def __init__(self):

# Set up parent class
super().__init__("zombie", "zombie")

Expand All @@ -147,7 +151,6 @@ class PlayerCharacter(Entity):
"""Player Sprite"""

def __init__(self):

# Set up parent class
super().__init__("male_person", "malePerson")

Expand All @@ -157,7 +160,6 @@ def __init__(self):
self.is_on_ladder = False

def update_animation(self, delta_time: float = 1 / 60):

# Figure out if we need to flip face left or right
if self.change_x < 0 and self.facing_direction == RIGHT_FACING:
self.facing_direction = LEFT_FACING
Expand Down Expand Up @@ -331,7 +333,7 @@ def setup(self):
platforms=self.scene[LAYER_NAME_MOVING_PLATFORMS],
gravity_constant=GRAVITY,
ladders=self.scene[LAYER_NAME_LADDERS],
walls=self.scene[LAYER_NAME_PLATFORMS]
walls=self.scene[LAYER_NAME_PLATFORMS],
)

def on_draw(self):
Expand Down Expand Up @@ -505,7 +507,6 @@ def on_update(self, delta_time):

# Loop through each coin we hit (if any) and remove it
for collision in player_collision_list:

if self.scene[LAYER_NAME_ENEMIES] in collision.sprite_lists:
arcade.play_sound(self.game_over)
self.setup()
Expand Down
28 changes: 13 additions & 15 deletions arcade/examples/platform_tutorial/16_shooting_bullets.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,28 @@ def __init__(self, name_folder, name_file):
self.texture = self.idle_texture_pair[0]

# Hit box will be set based on the first image used. If you want to specify
# a different hit box, you can do it like the code below.
# self.set_hit_box([[-22, -64], [22, -64], [22, 28], [-22, 28]])
self.set_hit_box(self.texture.hit_box_points)
# a different hit box, you can do it like the code below. Doing this when
# changing the texture for example would make the hitbox update whenever the
# texture is changed. This can be expensive so if the textures are very similar
# it may not be worth doing.
#
# self.hit_box = arcade.hitbox.RotatableHitBox(
# self.texture.hit_box_points,
# position=self.position,
# scale=self.scale_xy,
# angle=self.angle,
# )


class Enemy(Entity):
def __init__(self, name_folder, name_file):

# Setup parent class
super().__init__(name_folder, name_file)

self.should_update_walk = 0
self.health = 0

def update_animation(self, delta_time: float = 1 / 60):

# Figure out if we need to flip face left or right
if self.change_x < 0 and self.facing_direction == RIGHT_FACING:
self.facing_direction = LEFT_FACING
Expand All @@ -139,7 +145,6 @@ def update_animation(self, delta_time: float = 1 / 60):

class RobotEnemy(Enemy):
def __init__(self):

# Set up parent class
super().__init__("robot", "robot")

Expand All @@ -148,7 +153,6 @@ def __init__(self):

class ZombieEnemy(Enemy):
def __init__(self):

# Set up parent class
super().__init__("zombie", "zombie")

Expand All @@ -159,7 +163,6 @@ class PlayerCharacter(Entity):
"""Player Sprite"""

def __init__(self):

# Set up parent class
super().__init__("male_person", "malePerson")

Expand All @@ -169,7 +172,6 @@ def __init__(self):
self.is_on_ladder = False

def update_animation(self, delta_time: float = 1 / 60):

# Figure out if we need to flip face left or right
if self.change_x < 0 and self.facing_direction == RIGHT_FACING:
self.facing_direction = LEFT_FACING
Expand Down Expand Up @@ -357,7 +359,7 @@ def setup(self):
platforms=self.scene[LAYER_NAME_MOVING_PLATFORMS],
gravity_constant=GRAVITY,
ladders=self.scene[LAYER_NAME_LADDERS],
walls=self.scene[LAYER_NAME_PLATFORMS]
walls=self.scene[LAYER_NAME_PLATFORMS],
)

def on_draw(self):
Expand Down Expand Up @@ -563,10 +565,7 @@ def on_update(self, delta_time):
bullet.remove_from_sprite_lists()

for collision in hit_list:
if (
self.scene[LAYER_NAME_ENEMIES]
in collision.sprite_lists
):
if self.scene[LAYER_NAME_ENEMIES] in collision.sprite_lists:
# The collision was with an enemy
collision.health -= BULLET_DAMAGE

Expand Down Expand Up @@ -595,7 +594,6 @@ def on_update(self, delta_time):

# Loop through each coin we hit (if any) and remove it
for collision in player_collision_list:

if self.scene[LAYER_NAME_ENEMIES] in collision.sprite_lists:
arcade.play_sound(self.game_over)
self.setup()
Expand Down
Loading