Platformer tutorial game maker


















We create surface objects for each class with a fixed size. We give each of them a color using the fill function RGB format.

Remember, top left hand corner is the origin point with the co-ordinates 0, 0. Finally, we create two objects, PT1 stands for platform 1 and P1 stands for Player 1. These names are completely arbitrary of course, and you can change them to whatever you want. We have no images to show our progress so far, because the screen still shows the same black screen as before. Besides this, we use the fill function on the displaysurface to refresh the screen with each iteration.

Without sprite groups, we would have to individually draw each one of them to screen. Finally, we use the update function to push all the changes to the screen and update it.

The tick function, used on the Clock object we created earlier limits the Game loop to refreshing 60 times per second. This is what our current progress in our Platformer game has resulted in. Now, this is a fairly complex part that uses concepts from Kinematics Physics and the equations of motion to bring in the concept of acceleration and deceleration. Creating two dimensional vectors allows us to keep things simpler.

Remember, velocity and acceleration are vector quantities. There is horizontal acceleration and also vertical acceleration. Same goes for velocity. Next up is the move function that will allow us to control our player.

This first part is pretty simple. The function first re-sets the value of the acceleration to 0, then checks for key presses. If the left key has been pressed, it will update the acceleration with a negative value acceleration in the opposite direction.

If the right key has been pressed, acceleration will have a positive value. This part is a bit complicated, so you can simply copy it if you want. You can see an equation of motion there on the third line. We also use friction to to decrease the value of the velocity. Without friction, our player would not de-accelerate. You can tweak the value of the FRIC variable to adjust the movement. The last line updates the rect object of the Player with the new position that it has gained after being moved.

You can find it anywhere online or at our own Pygame Tutorial here. Simply add the following line into your game loop. This will cause the move function of Player 1 to be called in every iteration of the game loop.

If you have any trouble with some of the code above, I recommend you try running it piece by piece and experimenting with it on your own. Leave out certain lines to discover their effect on the game.

Click on the button below to head over to the next Part in this series of Game Development with Pygame Platformer. Sidebar This documentation is collaborative: you can edit any page to improve it. Site Tools. Step 2: Download the game's assets. Step 6: Change the background color. You'll learn how to: Design a level with platforms, enemies, and collectible coins.

Platformer Tutorial, Part 1. Platformer Tutorial, Part 2. Platformer Tutorial, Part 3. Platformer Tutorial, Part 4. Platformer Tutorial, Part 5. Platformer Tutorial, Part 6. Platformer Tutorial, Part 7.

Platformer Tutorial, Part 8. Naturally though, the game you see in the screenshots will look different from the game you end up creating. To create a project: Launch GDevelop. To add a scene to the game: Expand the Scenes panel if it's not already expanded. If you add multiple scenes to a project, the first scene in the list is the scene that GDevelop loads when the game starts. To create an object: In the Objects panel, click Add a new object. When the object editor opens, click Add an animation.

Even though the label says Add an animation , Sprite objects don't have to be animated. Each copy of an object that appears in a scene is referred to as an instance of that object. The white clouds don't look great on the grey background.

To change the background color of the scene: Right click the scene's background. You can enter a hex Ex: or a name of the color Ex: Black.



0コメント

  • 1000 / 1000