Space Rocks! Godot Tutorial Part 6

KidsCanCode · Beginner ·🛠️ AI Tools & Apps ·9y ago

Key Takeaways

Develops a version of the classic game Asteroids using Godot game engine

Full Transcript

welcome back to space rocks the go-to game engine series where we're making a asteroids cloud in the last part we did work on making them asteroids explode when we hit them and split into smaller ones and so this time we're going to add some nice-looking explosion and sound effects to our asteroids okay now that we are shooting asteroids we want to add two nice looking explosions so I'm going to make a new scene flood that and we're going to use an animated sprite we handle this and I've added some art in here of an explosion of the eight frames of animation so make a new right frames I'm going to call this the regular explosion this is the normal sized one maybe we'll add some different sizes for the different sized explosions I started for the different sized asteroids after there we go okay for this one I think the FPS we have about ten we want the loop to be off I don't want it to repeat let's see we're going to start on zero it's not playing like it's playing to see it run through once that's all we need all right let's just name this explosion and save it in the scenes folder and add a script all right all we're going to do here with this script really we don't even need the ready function because what we're going to do is attach the event for finished I'm going to connect that and we're just going to say when it's finished we'll delete it so when we spawn one of these it's going to play out and then it's going to disappear now on our main we just want to instance one of these whenever we blow them and afterwards so explosion we're going to preload that and then down here is where we explode the asteroid so we just need to create an instance of this we need to add it as a child we need to set its position to position of B that's where we exploded and then we just need to tell it to play and that should be that let's go over here and shoot this guy comes on to the screen a little slow I think I'm gonna adjust to be speed a little bit maybe twelve things per second that'll be a little better yeah okay looking much nicer all right let's get some sound in here now so we're going to go to the players scene and we're going to add a sample player sample player with the little speaker icon next to it this is going to be the shoot shoot sounds and we have a little warning here because it needs a sample library well right here samples no we're going to make a new library go over here and add some stuff so in the audio folder I have some different wav files I'm going to use laser one and laser two these are one sound like this plays the two sounds like this so I have some options on how we can you know make our lasers sound as we have upgrades and things like that so playing a sound is super easy in your code you just have to tell it when you want to happen go over to our player script and let's get that node and we're going to use that down in our shoot function I'm shoot function here fires off when we are able to shoot so we're just going to say put this on the end shoot sound dot play and then you just put the name of the sound that you want to play actually I think I want to for this one and that should be it there go much gutter you know we just need to get a sound happening during explosion and we're going to do it the exact same way we're gets to in main I have just made another sample player called explosion sound expl sounds and I'm just playing explosion number one I've got three explosion sounds in here now which we could use for different things or even randomize but I'm giving it simple right now you know later we could even go in and make different explosions here that are named the same as the sizes right so big medium small and tiny and then have matching sounds so we would play and we would just use the size variable here to play the matching one and we can do that at some point but I'm not really really ready to do that yet this is good enough for us to be able to have a little bit of feedback it will fill up okay and finally we're going to do some music by adding a stream player node stream players what you use for background music because it just plays doesn't load the whole music file which might be a big song something like that and it streams it as it goes and just plays it in the background on its own thread and that is what we want so you need something in the stream property right and I happen to have an auxiliary and game art that works pretty well we put that in in there and we just have to tell it to play when we start the new game and so in our I'm just going to put this in our ready I'm just going to say get node music dot play that's all we have to do we go we have some background music and sound it back okay I'm going to get fun now in the next video I want to do some more work on the player and say I want to add a couple things here I'm going to add a sprite it's going to be our shield around the player ship because we have a nice shield graphic from our sprite sheet here there's actually where the there's there's actually three levels of shield I'm just going to grab the full one here and we need to resize that because just like we've scaled the ship to point 6 we're going to want to scale the shield the same I actually might make it even a little smaller yeah so it looks like it's around the ship and so the shield is going to just be the visual indication that we have our shields on and we'll be if we can just hide and show it the to make it look like this ship has a shield up shield down it's also pretty boring when we're flying around and so I'm going to add a little animated sprite here and this is going to be the exhaust from the ship's engine that is going to have a couple of frames in and one we're going to use our there's a bunch of different animations for different kinds of exhaust in here let's plow all-beef ones so we're just going to grab one of these blue ones here this one and we got this one and we need to move those down a bit take the position of the exhaust and I'm going to shift it let's see 30 a little more 35 yeah so it looks like it's coming out the back of the sniffs I'm going to put playing alright using about that it's going to look like not quite what I wanted let's try this other one yeah it looks like kind of like it's pulsing okay so we want that to be on when we're thrusting and off when we're not so we're just going to add into our code to turn it to show and hide it right just set it to visible or not visible which is our can be a little property right here so we already have here in our script where we're thrusting or not thrusting and so this is where we just want to set that property to so we're going to say get node exhaust and we're going to if we're trusting we're going to set grants a show and then do the same thing take the same line and we're going to duplicate here and put hide and now when we want to when we thrust we have a little fire coming out the back and when we let go of the key it's not there okay give the ship a little bit more personality as always thanks for watching I hope you're enjoying this series and I will see you in the next video you

Original Description

This is a complete end-to-end game development tutorial using the Godot Game Engine. We're going to be making a version of the classic game "Asteroids". We're making it as we go, so there will be bugs, mistakes, etc. - but this is how real development works, exploring possible solutions, refactoring (this means going back and changing code you already wrote). I hope you enjoy it and learn something. Code for each part can be found here: https://github.com/kidscancode/godot_tutorials/tree/master/Space_Rocks_tutorial 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 Learning to Code with Python: Lesson 1.1 - What is Programming?
Learning to Code with Python: Lesson 1.1 - What is Programming?
KidsCanCode
2 Learning to Code with Python: Lesson 1.2 - Drawing with Turtles
Learning to Code with Python: Lesson 1.2 - Drawing with Turtles
KidsCanCode
3 Learning to Code with Python: Lesson 1.3 - Variables
Learning to Code with Python: Lesson 1.3 - Variables
KidsCanCode
4 Learning to Code with Python: Lesson 1.4 - Loops (and more turtles!)
Learning to Code with Python: Lesson 1.4 - Loops (and more turtles!)
KidsCanCode
5 Learning to Code with Python: Lesson 1.5 - Saving and Running Programs
Learning to Code with Python: Lesson 1.5 - Saving and Running Programs
KidsCanCode
6 Learning to Code with Python: Lesson 1.6 - Functions
Learning to Code with Python: Lesson 1.6 - Functions
KidsCanCode
7 Learning to Code with Python: Lesson 1.7 - Input and Conditional Statements
Learning to Code with Python: Lesson 1.7 - Input and Conditional Statements
KidsCanCode
8 Learning to Code with Python: Lesson 1.8 - Number Guessing Game
Learning to Code with Python: Lesson 1.8 - Number Guessing Game
KidsCanCode
9 KidsCanCode - Patreon Intro Video
KidsCanCode - Patreon Intro Video
KidsCanCode
10 Learning to Code with Python: Lesson 1.9 - Rock Paper Scissors Game
Learning to Code with Python: Lesson 1.9 - Rock Paper Scissors Game
KidsCanCode
11 Learning to Code with Python: Lesson 1.10 - Secret Codes
Learning to Code with Python: Lesson 1.10 - Secret Codes
KidsCanCode
12 Learning to Code with Python: Lesson 2.1 Creating Computer Graphics
Learning to Code with Python: Lesson 2.1 Creating Computer Graphics
KidsCanCode
13 Learning to Code with Python: Lesson 2.2 Simple Animation
Learning to Code with Python: Lesson 2.2 Simple Animation
KidsCanCode
14 Learning to Code with Python: Lesson 2.3: Animating More Objects
Learning to Code with Python: Lesson 2.3: Animating More Objects
KidsCanCode
15 Learning to Code with Python: Lesson 2.4: More Fun with Animation
Learning to Code with Python: Lesson 2.4: More Fun with Animation
KidsCanCode
16 Extra: Setting up the Atom Editor for Python
Extra: Setting up the Atom Editor for Python
KidsCanCode
17 Game Development 1-1: Getting Started with Pygame
Game Development 1-1: Getting Started with Pygame
KidsCanCode
18 Game Development 1-2: Working with Sprites
Game Development 1-2: Working with Sprites
KidsCanCode
19 Game Development 1-3: More About Sprites
Game Development 1-3: More About Sprites
KidsCanCode
20 Pygame Shmup Part 1: Player Sprite and Controls
Pygame Shmup Part 1: Player Sprite and Controls
KidsCanCode
21 Pygame Shmup Part 2: Enemy Sprites
Pygame Shmup Part 2: Enemy Sprites
KidsCanCode
22 Pygame Shmup Part 3: Collisions (and Bullets!)
Pygame Shmup Part 3: Collisions (and Bullets!)
KidsCanCode
23 Pygame Shmup Part 4: Adding Graphics
Pygame Shmup Part 4: Adding Graphics
KidsCanCode
24 Pygame Shmup Part 5: Improved Collisions
Pygame Shmup Part 5: Improved Collisions
KidsCanCode
25 Pygame Shmup Part 6: Sprite Animation
Pygame Shmup Part 6: Sprite Animation
KidsCanCode
26 Pygame Shmup Part 7: Score (and Drawing Text)
Pygame Shmup Part 7: Score (and Drawing Text)
KidsCanCode
27 Pygame Shmup Part 8: Sound and Music
Pygame Shmup Part 8: Sound and Music
KidsCanCode
28 Pygame Shmup Part 9: Shields
Pygame Shmup Part 9: Shields
KidsCanCode
29 Pygame Shmup Part 10: Explosions
Pygame Shmup Part 10: Explosions
KidsCanCode
30 Pygame Shmup Part 11: Player Lives
Pygame Shmup Part 11: Player Lives
KidsCanCode
31 Pygame Shmup Part 12: Powerups
Pygame Shmup Part 12: Powerups
KidsCanCode
32 Pygame Shmup Part 13: Powerups (part 2)
Pygame Shmup Part 13: Powerups (part 2)
KidsCanCode
33 Pygame Shmup Part 14: Game Over Screen
Pygame Shmup Part 14: Game Over Screen
KidsCanCode
34 Pygame Platformer Part 1: Setting Up
Pygame Platformer Part 1: Setting Up
KidsCanCode
35 Pygame Platformer Part 2: Player Movement
Pygame Platformer Part 2: Player Movement
KidsCanCode
36 Pygame Platformer Part 3: Gravity and Platforms
Pygame Platformer Part 3: Gravity and Platforms
KidsCanCode
37 Pygame Platformer Part 4: Jumping
Pygame Platformer Part 4: Jumping
KidsCanCode
38 Pygame Platformer Part 5: Scrolling the Window
Pygame Platformer Part 5: Scrolling the Window
KidsCanCode
39 Pygame Platformer Part 6: Game Over
Pygame Platformer Part 6: Game Over
KidsCanCode
40 Pygame Platformer Part 7: Splash & End Screens
Pygame Platformer Part 7: Splash & End Screens
KidsCanCode
41 Pygame Platformer Part 8: Saving High Score
Pygame Platformer Part 8: Saving High Score
KidsCanCode
42 Pygame Platformer Part 9: Using Spritesheets
Pygame Platformer Part 9: Using Spritesheets
KidsCanCode
43 Pygame Platformer Part 10: Character Animation (part 1)
Pygame Platformer Part 10: Character Animation (part 1)
KidsCanCode
44 Pygame Platformer Part 11: Character Animation (part 2)
Pygame Platformer Part 11: Character Animation (part 2)
KidsCanCode
45 Pygame Platformer Part 12: Platform Graphics
Pygame Platformer Part 12: Platform Graphics
KidsCanCode
46 Pygame Platformer Part 13: Improved Jumping
Pygame Platformer Part 13: Improved Jumping
KidsCanCode
47 Pygame Platformer Part 14: Sound and Music
Pygame Platformer Part 14: Sound and Music
KidsCanCode
48 Pygame Platformer Part 15: Powerups
Pygame Platformer Part 15: Powerups
KidsCanCode
49 Pygame Platformer Part 16: Enemies
Pygame Platformer Part 16: Enemies
KidsCanCode
50 Pygame Platformer Part 17: Using Collision Masks
Pygame Platformer Part 17: Using Collision Masks
KidsCanCode
51 Pygame Platformer Part 18: Scrolling Background
Pygame Platformer Part 18: Scrolling Background
KidsCanCode
52 Pygame Platformer Part 19: Wrapping Up
Pygame Platformer Part 19: Wrapping Up
KidsCanCode
53 Gamedev In-depth Topics: 4-way vs. 8-way Movement
Gamedev In-depth Topics: 4-way vs. 8-way Movement
KidsCanCode
54 Gamedev In-depth Topics: Time-based vs. Frame-based Movement
Gamedev In-depth Topics: Time-based vs. Frame-based Movement
KidsCanCode
55 Gamedev In-depth Topics: Non-integer Movement
Gamedev In-depth Topics: Non-integer Movement
KidsCanCode
56 Tile-based game Part 1: Setting up
Tile-based game Part 1: Setting up
KidsCanCode
57 Tile-based game Part 2: Collisions and Tilemap
Tile-based game Part 2: Collisions and Tilemap
KidsCanCode
58 Tile-based game Part 3: Smooth Movement
Tile-based game Part 3: Smooth Movement
KidsCanCode
59 Tile-based game Part 4: Scrolling Map / Camera
Tile-based game Part 4: Scrolling Map / Camera
KidsCanCode
60 Tile-based game Part 5: Player Graphics
Tile-based game Part 5: Player Graphics
KidsCanCode

Related Reads

Up next
I Found FREE Versions of EVERY Paid AI Tool (only top 1% Know this)🔥
Damini Tripathi
Watch →