gdquest / godot-beginner-2d-platformer Goto Github PK
View Code? Open in Web Editor NEWLearn to create a 2d platform game with the Godot game engine. This is a beginner programming tutorial.
License: MIT License
Learn to create a 2d platform game with the Godot game engine. This is a beginner programming tutorial.
License: MIT License
Enemies will have a basic physics implementation, moving left or right and changing their movement direction when they hit a wall, no AI whatsoever.
@NathanLovato can we add support for VisibilityEnabler
on them, so they only start moving when they are inside the screen?
This is a game demo and tutorial series for programming beginners. The goal is to guide the viewer through the process of creating a simple 2d platform game, and creating their first game.
The viewer should have some tiny programming foundations. You can assume they went through scripting in the official docs, and/or our gdscript intro
The demo should feature a complete game loop with:
change_scene
to move between themAnd no extras. You can use debug scripts or anything for yourself, but please don't add any extra autoload or utilities to the final game. This is going to be a complete step-by-step series.
Programming beginners, from ~13 years old. People who have little to no programming experience and experience with Godot.
Keep it simple. No input recording, no physics manipulations on walls. Decent controls in hand: the character should move well, offer a bit of air control, but that's about it.
The code should be well-structured and clean as usual, using clear variable and method names, splitting the content of physics process into several methods to make it easy to read. But try to keep the code dead simple.
We're still going with typed gdscript and the code order we use in our style guide, so it's consistent with the rest of our projects. But you should not use programming patterns like state, command, etc.
I'm submitting a bug
E 0:00:18.391 emit_signal: Error calling method from signal 'body_entered': 'KinematicBody2D(Player.gd)::_on_Area2D_body_entered': Method not found..<C++ Source> core/object.cpp:1260 @ emit_signal()
You forgot to turn on "Expand" to true and to set "Strech Mode" to Scale on Expand(compact) in the EndScreen scene.
When the Player jumps on enemies' heads, they should die.
These Area2Ds will be both One way collisions, Player's will be rotated 180 degrees to make sure the collision only happens from a Vector2(0, -1) collision normal
Levels are build up of Tilemaps, and as such of Tilesets. We will have support for One Way Collision platforms, to introduce this feature and later use it in #4
The Level's Goal is an Area2d
the player must reach to finish a level, it will then trigger the transition to the next screen
Would you accept a PR that updates this project for Godot 4?
When entering the MainScreen from the Pause Menu Main Screen Button, the MainScreen is paused. I fixed this by adding the same script present in the Retry Button (get_tree().paused = false)
When you click Play Again on the EndScreen, the Score of the ended game persists on the new game. I fixed this by adding the script "PlayerData.score = 0"
@NathanLovato
Play a new game.
Get killed.
Click MainScreenButton - Note MainScreenButton didn't work until I set the Next Scene Path to "res://src/Screens/MainScreen.tscn") See #28
The Play and Quit buttons don't do anything.
This bug (minus #28) exists in the free Youtube tutorial if you follow along coding as you go.
Since we have the reload_scene logic on the RetryButton
now, always calling PlayerData.reset()
the player's death count is always reset, making so that at the End Screen the player always has 0 deaths.
Previously only the End Screen made a full PlayerData.reset()
, while the UserInterface' just set the PlayerData.score = 0
when its RetryButton
was pressed
Player character will move with instant acceleration, e.g. going from zero to max speed instantly. Player can also jump and cancel the jump, i.e. the longer the player holds the jump button the higher the jump, still limited by the initial impulse.
Two basic screens to close the game loop. The Main Menu Scene will have 2 buttons, play and quit, the Game Over Screen will have a label with the player's score and two buttons: retry and quit. The Play Screen is a combination of #8 and #7.
A very simple Interface to display how many Coins
(#6) the player collected, how many are still missing, and the player's current score.
I have everything the same as shown in the first tutorial but when I try to run the game I see a blank gray screen and when I run the "TestLevel" scene I see the scene but The Player is not falling and I have collision on and also the script written the same as you have. If someone is feeling free of time can you check the files here - https://github.com/k4b00m-Hozaifa/First2DGame
I'm submitting a...
What is the current behavior?
MainScreen menu not working when the player pauses de game clicks MainScreen then the buttons on that screen don't work.
What is the expected behavior?
To be able to play the game or quit
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
Not sure if this has been addressed but I notice in my game after completing a couple of levels and I die and retry, all score is lost from previous levels, I fixed this by adding another variable to PlayerData "level_score" with a setget and make ememys and coins add there score to this, then I add the level score to the total score in the portal and make the user interface add the scores for display "score.text = "Score: %s" % str(PlayerData.score+PlayerData.level_score)"
now when I die I only lose the score for that level.
Fantastic tutorial BTW
What is the current behavior?
The Player enters the Portal and the scene begins to fade out / change to the next scene. This process is interrupted, however, if an Enemy collides with the Player during the fade out, resulting in the Player's death. Since the Portal scene transition is relatively slow, there is a decent window of time in which the Enemy can collide with you.
You can (barely) see the Pause/Player Died menu overlay through the mostly-opaque ColorRect that was fading in-- screenshot attached.
What is the expected behavior?
Ideally, entering the Portal should pause any enemies on the current level.
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
I coded along step-by-step with the Youtube series, just FYI
When I playing the game and then pause the game - button "Back to main screen" didn't working.
And thanks for awesome tutorial - it helped me a lot! :)
At the moment the coins have a set score value and enemies also have a score on kill.
My proposal would be to make it more Mario-like where the enemies drop coins and instead of a general score board we could use the number of coins collected.
What do you think?
For some reason _on_Area2D_area_entered()
gets (correctly) triggered when the Player stomps on the Enemy while _on_StompArea2D_body_entered()
doesn't get triggered at all. This seems like a Godot bug, but we'll need to find a workaround anyway. Might have to do with the fact that we're using SegmentShape
as the collision shape resource. Will have to investigate.
This can be reproduced easily in my fork: https://github.com/razcore-art/Your-First-Game-Godot-2d-Platformer/tree/feature-artwork, the "artwork" branch by having the player always move to right & jump on the platform falling on the enemy. We can see that the player correctly jumps up but the enemy doesn't die.
Coins
are Area2D
and serve as a reward for the player. When the player collides with them they will be freed and the player will score.
Area2D
CoinPickupArea2d
, an Area2D
dedicated to detect collisions with Coins
@NathanLovato can we add a PopLabel
to them, so that when the player picks one, they pop a label on the screen with how much the player scored?
What Geometry2D.gd
is out of scope for this little project. There's too many advanced concepts in there.
Hi, Thanks for sharing ur tutorial :)
I think there is a little issue with the game, if u have a score and then u go to the level 2,when u select retry in the pause menu, ur score will reset to zero and not to the start score of the level.
so may be the retry button have to point at the first scene and not reload the current scene Or
we can implement a variable. But it's not really a bug but a way of thinking the retry function.
So i've implemented the retry button like this:
extends Button
onready var start_score: = PlayerData.score
func _on_button_up():
PlayerData.score = start_score
get_tree().paused = false
get_tree().reload_current_scene()
what do u think?
(srry for my bad english)
Best regards,
Kyo
Currently the way we change between one level to another is by freeing the current and loading the next level manually, as mentioned in #1 we could simply just call get_tree().change_scene
instead, like Portal2Ds
were designed to do.
Regarding the interface we just need to add it to have it on both scenes, currently PlayScreen has the Levels, but we can invert this relationship somehow.
That was what I was talking about Friday, @razcore-art
I'm submitting a...
What is the current behavior?
At times, when you jump on the enemy, the enemy doesn't die but you still bounce off of them.
What is the expected behavior?
When you bounce off an enemy, it should die all the time.
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
Another way you can trigger this is if the enemy is falling (not sure if falling enemy does anything extra)
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("pause") and pause_title.text != DIED_MESSAGE:
self.paused = not paused
scene_tree.set_input_as_handled()
Try to maintain a nice flat look as we use in the https://github.com/GDquest/make-pro-2d-games-with-godot
Will the project have support for sfx and music @NathanLovato ? We can use mine to avoid spending time producing them and just focus on their implementation in this project we can use the ones from https://pigdev.itch.io/juans-saga 3rd place in music criterea in the JimJam btw ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.