Game Programming - Episode 59 - Defining / Creating Spawn Level Tiles
Skills:
Systems Design Basics70%
Key Takeaways
Defining and creating spawn level tiles in a game using Java, including setting up tile classes and properties.
Full Transcript
Hey, what is up? My name is Ajona. Welcome to episode 59 of game programming. So, today is going to be one of those episodes that really probably isn't that interesting, but um it just needs to be done. And I actually asked you guys last episode if you wanted to see all the graphical aspects of um of the development of this game, and you guys said yeah, like literally everyone. I don't think there was a single no in there. So, um I guess I am going to have to show you guys every aspect of um this game's development. So, you know, we've got the same thing that we had last time, but what what we're basically going to do today, all we're going to we're going to do today is actually just finish the tiles. So, um we had all these tiles here and we actually made this new tile called the spawn grass tile, right? And if we go back into tile here, we can instantiate, we can basically define it by typing public static tile. And that was the spawn, what was it called? What get out spar tile? I don't think that even exists. spawn grass tile. So, we'll call it um spawn grass tile or something. I don't know. Um and we'll set it equal to new spawn grass tile. And the sprite that we'll use is this sprite dot. And I think I used a prefix spawn. Yes, I did. Spawn grass. And that's it. All right. Simple as that. And we basically need to do the whole the same thing for all the other tiles that we had. So if we actually go to the sprite class, um you can see that we also had a hedge, water, wall one, wall two, and floor. All right. So if I just tab it over. So there. So there's two windows. I'll try and make the camera show both, but um I don't think I will just because it just feels too zoomed out if I do it that way. But um I'm literally just going to copy and paste this stuff here. So we got grass. Now we need hedge. Um, and I guess we don't need tile to be honest, just because, um, well, it's obviously a tile, so no point in that, eh? Um, wall one, wall two, and floor as well. So, let me first of all, copy this and I'll grab the floor. All right, that's it. It's all I want to do with sprite. Um, and over here, all I'm going to do is hit up spawn. Um, that Yeah, that's going to be grass, obviously. It's going to be hedge, and it's going to be water. It's going to be wall one. It's going to be wall two, and that's going to be floor. And um, now now what we need to do is actually change the spawn grass cell into the appropriate one. So for hedge, we could have a spawn hedge tile. For water, we can have a spawn water water tile. For wall, we can have a sp for wall once, right? We can have a spawn wall file. But the thing is, guys, this is the other thing. Um, so some things are the same, right? So in other words, these like these walls that we've got going on here, these stone walls, like they technically, you know, they're the same, right? They look different. The sprites are different, but they're the same as in they have the same properties. Okay, in fact, a lot of these tiles have the same properties, but um you know, we still want to divide them just because you know, wood might react differently to how a hedge does. A hedge might be more upright and could be destroy. You know, a hedge could be breakable whereas, you know, a grass tile wouldn't be. And so, I like to just mix it up. I like to um I like to keep everything organized just in case because I really like my materials to be, you know, defined separately. But if it's something like a wall and it's literally just two wall textures and they they're only different for aesthetical purposes, then we can just go ahead and say spawn wall tile for both of them and simply use different sprites. All right? And obviously different um tile names, but otherwise it's the same, right? Okay. Okay. So, spawn spawn floor will be um our spawn floor tile. All right. Awesome. So, now we have to go ahead and create each of these classes. So, we'll hit this little thing and we'll go create class and it'll automatically fill up pretty much everything for us. We want to keep it in tile except we want to put it under spawn level which is the folder that we created. So, hit finish and there's an error that occurred. Assertion failed. Don't worry too much about that. Um, that is not really important. So, this is all good. Um, let's go back to tile. Um, and we'll actually have to just do the same for all the other ones. So, again, we'll put into spawn level spawn level. Uh, and then we'll, you know, add the constructor as we do. Um, let's get rid of this. Go back to tile. So, the spawn wall tile again, that's just one tile for both of those things. And we'll put it under spawn level. Add that constructor in. And that's pretty much it. We got one more to go. That's the floor tile. So, we'll create a class for that. Level um spawn. Sorry, it's spawn level spawn level. and we will in we'll add the constructor from our superass and that's it. Okay, awesome. So, let's save that and hopefully we won't get any errors. Awesome. No errors. Um, okay. So, what we need to do now, the other thing we need to actually do is if we just go to a normal grass tile, you see it's got a render method. So, let's grab that render method and we'll just quickly copy and paste it into every one of these. So, just like that. Make sure you save after it as well. Um, that's pretty much it, I think. Did we do all of them? Yep, we did. Awesome. So, I'm just going to right click, close all just cuz I like to be organized and it feels really cluttered right now. Uh, let's open tile back up. Okay, so now that we've got all these different things, we can also go through, I guess, another time and be like, all right, hedge. Do we want hedges to be, you know, possible? You know, do we want them to be solid? Um, so public boolean solid. Um, we can just return false if we don't want it to be solid, right? Because remember that overrides the original solid thing. So, so I return true for if it is solid. So, um, you know, hedges, we don't we don't want to pass through hedges. Maybe they'll be breakable. You know, walls won't be, but hedges you can like, I don't know, whip out your sword and cut them down or something. Um, so I'll I'll I'll make that, you know, it'll be it'll be solid. But that's like that's for example why I um, you know, we might even put like in the future like a public boolean called breakable and this one would, you know, return true. All right. So I'll just I'll leave this in here cuz it doesn't do any harm. But um, you know, a system like that might be in place in the future for those kind of tiles. So, that's like another reason, I guess, why I actually split up um all these tiles into different subasses instead of just having like a tile and being like, "All right, well, this this is going to be breakable tile and it's going to be unbreakable tile, and then I'll just have different names for them, but they'll still refer to the same class." No, I I don't like to do that. That's just not how I roll. Um, so again, what else is unbreakable? Wall tile. Let's copy and paste solid for wall tile cuz a wall is solid indeed. Um and well yeah that's about it. So that is how we organize each one of those tiles. Next time tomorrow we're going to take a look at actually creating levels based on this level. So in other words, we will create a spawn level next time and we'll see all these tiles in actions in actions. In action actions mult well there will be multiple actions for the level I'm sure. But um but yeah, that's what that's what we're going to do next time. We're going to take a look at actually creating the spawn level and seeing it in action. So, I'll see you guys next time. If you like the video, please hit that like button and I'll see you guys tomorrow. Later, guys.
Original Description
Lets go for 200 likes!
Welcome to Game Programming, a series in which we take an in depth look at how to make a game from scratch, in Java.
----------------------------------------------------------------------------------------------------------------
Website: http://www.thecherno.com
Twitter: http://www.twitter.com/thecherno
Facebook: http://www.facebook.com/thecherno
Subreddit: http://www.reddit.com/r/thecherno/
Steam Group: http://www.steamcommunity.com/groups/thecherno
----------------------------------------------------------------------------------------------------------------
Outro music is by Approaching Nirvana: http://www.youtube.com/approachingnirvana
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from The Cherno · The Cherno · 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
3D Game Programming - Episode 1 - Window
The Cherno
3D Game Programming - Episode 2 - Game Loop
The Cherno
3D Game Programming - Episode 3 - Arrays
The Cherno
3D Game Programming - Episode 4 - Drawing Pixels!
The Cherno
3D Game Programming - Episode 4.5 - How Rendering Works
The Cherno
3D Game Programming - Episode 5 - Playing with Pixels!
The Cherno
3D Game Programming - Episode 6 - Performance Boosting
The Cherno
3D Game Programming - Episode 7 - FPS Counter
The Cherno
3D Game Programming - Episode 8 - Alpha Support and More
The Cherno
3D Game Programming - Episode 9 - Beginning 3D
The Cherno
3D Game Programming - Episode 10 - Floors and Animation
The Cherno
3D Game Programming - Episode 11 - Rotation
The Cherno
3D Game Programming - Episode 12 - User Input
The Cherno
3D Game Programming - Episode 13 - Render Distance Limiter!
The Cherno
3D Game Programming - Episode 14 - Basic Mouse Movement
The Cherno
3D Game Programming - Episode 15 - Textures + More!
The Cherno
3D Game Programming - Episode 16 - Walking, Crouching, Sprinting + More
The Cherno
3D Game Programming - Episode 16.5 - Exporting Runnable Jars
The Cherno
3D Game Programming - Episode 17 - Small Adjustments + Birthday!
The Cherno
3D Game Programming - Episode 17.5 - Creating an Applet
The Cherno
3D Game Programming - Episode 18 - The Beginning of Walls
The Cherno
3D Game Programming - Episode 18.1 - A Few More Things
The Cherno
Episode 18.5 - Creating an EXE File in Java
The Cherno
3D Game Programming - Episode 19 - Rendering Walls
The Cherno
3D Game Programming - Episode 20 - Continuing Walls, Fixing Bugs, and Managing Crashes
The Cherno
3D Game Programming - Episode 21 - Texturing Walls, Fixing Clipping, and Fixing the Mouse
The Cherno
3D Game Programming - Episode 22 - Random Level Generator + Properly Fixing Clipping
The Cherno
3D Game Programming - Episode 23 - Graphical User Interface (GUI) Launcher
The Cherno
3D Game Programming - Episode 24 - Making Our Launcher Work
The Cherno
3D Game Programming - Episode 25 - Writing and Reading Files
The Cherno
3D Game Programming - Episode 26 - Custom Resolutions
The Cherno
3D Game Programming - Episode 27 - Decorating the Launcher
The Cherno
3D Game Programming - Episode 28 - Continuing our Custom Launcher!
The Cherno
3D Game Programming - Episode 29 - Launching The Game
The Cherno
3D Game Programming - Episode 30 - Colour Processing In-Depth
The Cherno
3D Game Programming - Episode 31 - Sprites!
The Cherno
3D Game Programming - Episode 32 - Sprite Mapping
The Cherno
3D Game Programming - Episode 33 - High Resolution Rendering
The Cherno
3D Game Programming - Episode 34 - Entities
The Cherno
Genesis - My Game for Ludum Dare 24
The Cherno
Vlog + Ludum Dare Results
The Cherno
Game Programming - Episode 1 - Resolution
The Cherno
Game Programming - Episode 2 - Threads
The Cherno
Game Programming - Episode 3 - Game Loop
The Cherno
Game Programming - Episode 4 - Window
The Cherno
Episode 5 - Buffer Strategy
The Cherno
Game Programming - Episode 6 - Graphics Initialized
The Cherno
Game Programming - Episode 7 - Buffered Image and Rasters
The Cherno
Game Programming - Episode 8 - The Screen Class
The Cherno
Game Programming - Episode 9 - Rendering Pixels
The Cherno
Game Programming - Episode 10 - Clearing the Screen
The Cherno
Game Programming - Episode 11 - "Out of Bounds, Baby!"
The Cherno
Game Programming - Episode 12 - Negative Bounds
The Cherno
Game Programming - Episode 13 - Timer
The Cherno
Game Programming - Episode 14 - FPS Counter
The Cherno
Episode 15 - Tiles
The Cherno
Game Programming - Episode 16 - The Map
The Cherno
The Walls 2 - Minecraft PvP Survival Map
The Cherno
Game Programming - Episode 17 - Key Input
The Cherno
Game Programming - Episode 18 - Controlling The Map
The Cherno
More on: Systems Design Basics
View skill →Related Reads
📰
📰
📰
📰
How Creative Characters Like Sprunki Inspire Kids to Learn Coding
Medium · Programming
Computer Applications for Primary School Children: A Fun + Safe Guide for Ages 6-12
Dev.to · Ogunkola Adeola
From 0 to 20 Chapters: My Story‑Driven Rust Book for Kids Now Has a Bilingual Interactive Demo
Dev.to · born1987-ir
How Kids Can Build Fighting Games Stickman in Scratch
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI