Circle Jump: A Godot Mobile Game (Part 7)
Key Takeaways
Adds a score and HUD to a mobile game in Godot using GDScript and Godot's built-in features
Full Transcript
welcome back to part 7 of circle jump we're still working out in our Godot Engine mobile game and this time we're gonna make the circles move which is going to add some difficulty to the progression of the game alright let's get started okay the first thing we need to do is we need to fix a bug and when we run the game and we're at the title screen if we spam this button you see it triggers more than once and we wind up crashing we're sending out the signal the press's signal on the button multiple times but our code isn't accounting for that and so there's a couple things we can do about that but I think the easiest is going to be we go to our base screen script here and after we have clicked the button and we call the disappear method we're gonna disable all the buttons because we don't want to capture any more button presses and since we have them all in a group that should be pretty easy we can just say call group to call the same function on every group and the function we're going to call on the buttons group is set disabled and we're going to set it to true and then we want them to come back and be enabled again when they appear so we'll set this to false on up here and that should prevent us from being able to yeah see I'm clicking a bunch of times I can't multiply I can't multiple click on these buttons yeah that fixes the problem ok on to new features so over here in the main we are getting points whenever we get captured but we are gonna use that score to handle the progression the difficulty progression and we want to spawn different types of circles and that kind of thing but we might have other things that give us points besides just being captured and we're gonna want to check that score and when we cross certain thresholds change the the spawn rate of circles and things like that so to make this easier I'm going to take score here and I'm going to make it as set get so we have a function that we can call when we change the score and that means here we can do set score zero now you can do it this way you can say set score zero or if you want to call the set get locally you can say self dot score equals zero now the drawback of that is there is a small performance hit and calling self because you're generating a reference to the to this node in the case of this game performance is far from an issue and I like the clarity of the code looking like this so in this case I'm not going to call the set get directly and then here we'll say self dot square plus equals one and then what we want to do in the set score function is update the score so func set score we pass it's gonna be passed a value we're going to set the score we're going to set the score equal to that value and we're gonna update the HUD so that should be fine that shouldn't change anything at all let's see the score is just going up the same as before but what we also want to do is keep track of what level we're on and that's going to go up every certain number of rings which we put here on setting circles per level five so every five circles that we hit or every five points we get currently that's going to move us up a level we'll check that and they set score as well so if we our score is greater than zero and score we'll divide by circles per level and if the remainder is zero we're at a multiple of five so we will increase the level by one and we should show a message to that effect we moved up to level whatever okay we make sure to initialize level when we're starting a new game and that should do it let's give it a shot here yeah went to level two okay over to the circle where we want to add movement I want the circles to move back and forth so that as the game gets harder we have moving targets that we have to jump to so we're going to do that by using a between and I'm going to call this move between and then in the script we're going to get a reference to it and then moving is going to be separate from the modes right we might have a static circle that's moving we might have a limited circle that's moving or other modes that we add so what we are gonna do is have a move range this is how many how much the distance of the move is how far back and forth if we set this to zero we'll have a non moving circle and then we're also going to have the move speed which is gonna be how fast it moves back and forth and then so now we need to set up that movement and we're gonna do that with a function down here at the bottom I'm going to call this the set between and we're going to call this to start the movement but when the tween completes we want it to repeat again so we're going to call this again every time the tween finishes its cycle and that means that when we call it with the tweens completed signal it's gonna pass in two values which we don't actually need but we have to account for them and if move range is zero we're gonna return we're not going to move so the first time we call this we won't start the tween and now move range we're going to want to reverse every time we call this so that moves back and forth and then the move tween we're going to set up its movement we're gonna interpolate the property on cell of position X : X when you write it in this reference and then we're gonna go from whatever our current position dot X is to position dot X plus move range the duration is move speed and we're going to use between trans quad and tween and out for the easing and then we're just going to say move between dots start now we want to connect the tweens between completed signal and we want to connect it to that same function so that every time it finishes it's going to come back and call this again and then in our in it we can set that for the first time let's give that a shot and see what happens there we go the circles are moving back and forth I only see them that's exactly what we want right that'll do it for this time I hope you enjoyed it and I'll see you in the next video you
Original Description
We're making a mobile game in Godot! In this part, adding a score and HUD.
Download the code for this part:
https://github.com/kidscancode/circle_jump/releases/tag/part07
Text version:
http://kidscancode.org/godot_recipes/games/circle_jump/
Support me on Patreon: http://patreon.com/kidscancode
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from KidsCanCode · KidsCanCode · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Learning to Code with Python: Lesson 1.1 - What is Programming?
KidsCanCode
Learning to Code with Python: Lesson 1.2 - Drawing with Turtles
KidsCanCode
Learning to Code with Python: Lesson 1.3 - Variables
KidsCanCode
Learning to Code with Python: Lesson 1.4 - Loops (and more turtles!)
KidsCanCode
Learning to Code with Python: Lesson 1.5 - Saving and Running Programs
KidsCanCode
Learning to Code with Python: Lesson 1.6 - Functions
KidsCanCode
Learning to Code with Python: Lesson 1.7 - Input and Conditional Statements
KidsCanCode
Learning to Code with Python: Lesson 1.8 - Number Guessing Game
KidsCanCode
KidsCanCode - Patreon Intro Video
KidsCanCode
Learning to Code with Python: Lesson 1.9 - Rock Paper Scissors Game
KidsCanCode
Learning to Code with Python: Lesson 1.10 - Secret Codes
KidsCanCode
Learning to Code with Python: Lesson 2.1 Creating Computer Graphics
KidsCanCode
Learning to Code with Python: Lesson 2.2 Simple Animation
KidsCanCode
Learning to Code with Python: Lesson 2.3: Animating More Objects
KidsCanCode
Learning to Code with Python: Lesson 2.4: More Fun with Animation
KidsCanCode
Extra: Setting up the Atom Editor for Python
KidsCanCode
Game Development 1-1: Getting Started with Pygame
KidsCanCode
Game Development 1-2: Working with Sprites
KidsCanCode
Game Development 1-3: More About Sprites
KidsCanCode
Pygame Shmup Part 1: Player Sprite and Controls
KidsCanCode
Pygame Shmup Part 2: Enemy Sprites
KidsCanCode
Pygame Shmup Part 3: Collisions (and Bullets!)
KidsCanCode
Pygame Shmup Part 4: Adding Graphics
KidsCanCode
Pygame Shmup Part 5: Improved Collisions
KidsCanCode
Pygame Shmup Part 6: Sprite Animation
KidsCanCode
Pygame Shmup Part 7: Score (and Drawing Text)
KidsCanCode
Pygame Shmup Part 8: Sound and Music
KidsCanCode
Pygame Shmup Part 9: Shields
KidsCanCode
Pygame Shmup Part 10: Explosions
KidsCanCode
Pygame Shmup Part 11: Player Lives
KidsCanCode
Pygame Shmup Part 12: Powerups
KidsCanCode
Pygame Shmup Part 13: Powerups (part 2)
KidsCanCode
Pygame Shmup Part 14: Game Over Screen
KidsCanCode
Pygame Platformer Part 1: Setting Up
KidsCanCode
Pygame Platformer Part 2: Player Movement
KidsCanCode
Pygame Platformer Part 3: Gravity and Platforms
KidsCanCode
Pygame Platformer Part 4: Jumping
KidsCanCode
Pygame Platformer Part 5: Scrolling the Window
KidsCanCode
Pygame Platformer Part 6: Game Over
KidsCanCode
Pygame Platformer Part 7: Splash & End Screens
KidsCanCode
Pygame Platformer Part 8: Saving High Score
KidsCanCode
Pygame Platformer Part 9: Using Spritesheets
KidsCanCode
Pygame Platformer Part 10: Character Animation (part 1)
KidsCanCode
Pygame Platformer Part 11: Character Animation (part 2)
KidsCanCode
Pygame Platformer Part 12: Platform Graphics
KidsCanCode
Pygame Platformer Part 13: Improved Jumping
KidsCanCode
Pygame Platformer Part 14: Sound and Music
KidsCanCode
Pygame Platformer Part 15: Powerups
KidsCanCode
Pygame Platformer Part 16: Enemies
KidsCanCode
Pygame Platformer Part 17: Using Collision Masks
KidsCanCode
Pygame Platformer Part 18: Scrolling Background
KidsCanCode
Pygame Platformer Part 19: Wrapping Up
KidsCanCode
Gamedev In-depth Topics: 4-way vs. 8-way Movement
KidsCanCode
Gamedev In-depth Topics: Time-based vs. Frame-based Movement
KidsCanCode
Gamedev In-depth Topics: Non-integer Movement
KidsCanCode
Tile-based game Part 1: Setting up
KidsCanCode
Tile-based game Part 2: Collisions and Tilemap
KidsCanCode
Tile-based game Part 3: Smooth Movement
KidsCanCode
Tile-based game Part 4: Scrolling Map / Camera
KidsCanCode
Tile-based game Part 5: Player Graphics
KidsCanCode
Related Reads
📰
📰
📰
📰
Oracle Just Fired 30,000 People to Pay One Customer’s AI Bill
Medium · AI
Anthropic's Landmark $1.5B Copyright Settlement Approved
Dev.to AI
India’s IT Sector Sees AI Hiring Surge Amid Broader Recruitment Slowdown
Dev.to AI
Anthropic’s landmark $1.5B copyright settlement is approved
TechCrunch AI
🎓
Tutor Explanation
DeepCamp AI