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
8 changes: 4 additions & 4 deletions top-python-game-engines/arcade/arcade_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def on_draw(self):
"""Called once per frame to render everything on the screen"""

# Start rendering
arcade.start_render()
self.clear()

# Draw a blue circle with a radius of 50 in the center of the screen
arcade.draw_circle_filled(
Expand All @@ -52,7 +52,7 @@ def on_draw(self):
)

# Draw a red-outlined square in the top-left corner of the screen
arcade.draw_lrtb_rectangle_outline(
arcade.draw_lrbt_rectangle_outline(
left=50,
top=HEIGHT - 50,
bottom=HEIGHT - 100,
Expand All @@ -64,8 +64,8 @@ def on_draw(self):
# Draw an orange caption along the bottom in 60-point font
arcade.draw_text(
text="Hello, World! From Arcade!",
start_x=100,
start_y=50,
x=100,
y=50,
font_size=28,
color=arcade.color.ORANGE,
)
Expand Down
16 changes: 8 additions & 8 deletions top-python-game-engines/arcade/arcade_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def setup(self):
# Set up the player
sprite_image = ASSETS_PATH / "images" / "alien_green_stand.png"
self.player = arcade.Sprite(
filename=sprite_image, center_x=WIDTH // 2, center_y=HEIGHT // 2
sprite_image, center_x=WIDTH // 2, center_y=HEIGHT // 2
)

# Spawn a new coin
Expand All @@ -95,7 +95,7 @@ def add_coin(self, dt: float):
# Create a new coin
coin_image = ASSETS_PATH / "images" / "coin_gold.png"
new_coin = arcade.Sprite(
filename=coin_image,
coin_image,
center_x=randint(20, WIDTH - 20),
center_y=randint(20, HEIGHT - 20),
)
Expand Down Expand Up @@ -131,8 +131,8 @@ def on_mouse_motion(self, x: float, y: float, dx: float, dy: float):
"""

# Ensure the player doesn't move off-screen
self.player.center_x = arcade.clamp(x, 0, WIDTH)
self.player.center_y = arcade.clamp(y, 0, HEIGHT)
self.player.center_x = arcade.math.clamp(x, 0, WIDTH)
self.player.center_y = arcade.math.clamp(y, 0, HEIGHT)

def on_update(self, delta_time: float):
"""Update all the game objects
Expand Down Expand Up @@ -172,19 +172,19 @@ def on_draw(self):
"""Draw everything"""

# Start the rendering pass
arcade.start_render()
self.clear()

# Draw the coins
self.coins.draw()

# Draw the player
self.player.draw()
arcade.draw_sprite(self.player)

# Draw the score in the lower-left corner
arcade.draw_text(
text=f"Score: {self.score}",
start_x=50,
start_y=50,
x=50,
y=50,
font_size=32,
color=arcade.color.BLACK,
)
Expand Down
4 changes: 2 additions & 2 deletions top-python-game-engines/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
adventurelib==1.2.1
arcade==2.6.10
arcade==3.3.3
pgzero==1.2.1
pygame==2.1.2
pygame==2.6.1
Loading