![]() |
VOOZH | about |
In this article, we will learn how to add ladders in Arcade using Python.
In this example, we are going to add one ladder on the screen which our player can climb. For this, we will use some functions:
draw_text(): This function is used to draw text to the screen using Pygletโs label.
Syntax: arcade.draw_text(text, x, y, color, size, width, align, font_name)
Parameters:
- text: Text we want to display
- x : x coordinate
- y : y coordinate
- color : color of the text
- size : Size of the font
- width : Width of the text
- align : Alignment of the text
- font_name : Name of the font
PhysicsEnginePlatformer(): Simplistic physics engine for use in a platformer.
Syntax: arcade.PhysicsEnginePlatformer( player_sprite , platforms, gravity, ladders)
Parameters:
- player_sprite: sprite of the player
- platforms: The sprites it canโt move through
- gravity: Downward acceleration per frame
- ladders: Ladders the user can climb on
Sprites Used():
๐ ImageIn the below example, we are going to create a MainGame() class. Inside this class first, we are going to initialize some variables for velocity, scene, ladder sprite, and player's sprite then we will create 4 functions inside this class.
Output:
๐ Image