Game Programming - Episode 59 - Defining / Creating Spawn Level Tiles

The Cherno · Intermediate ·🧒 Coding for Kids ·13y ago

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 3D Game Programming - Episode 1 - Window
3D Game Programming - Episode 1 - Window
The Cherno
2 3D Game Programming - Episode 2 - Game Loop
3D Game Programming - Episode 2 - Game Loop
The Cherno
3 3D Game Programming - Episode 3 - Arrays
3D Game Programming - Episode 3 - Arrays
The Cherno
4 3D Game Programming - Episode 4 - Drawing Pixels!
3D Game Programming - Episode 4 - Drawing Pixels!
The Cherno
5 3D Game Programming - Episode 4.5 - How Rendering Works
3D Game Programming - Episode 4.5 - How Rendering Works
The Cherno
6 3D Game Programming - Episode 5 - Playing with Pixels!
3D Game Programming - Episode 5 - Playing with Pixels!
The Cherno
7 3D Game Programming - Episode 6 - Performance Boosting
3D Game Programming - Episode 6 - Performance Boosting
The Cherno
8 3D Game Programming - Episode 7 - FPS Counter
3D Game Programming - Episode 7 - FPS Counter
The Cherno
9 3D Game Programming - Episode 8 - Alpha Support and More
3D Game Programming - Episode 8 - Alpha Support and More
The Cherno
10 3D Game Programming - Episode 9 - Beginning 3D
3D Game Programming - Episode 9 - Beginning 3D
The Cherno
11 3D Game Programming - Episode 10 - Floors and Animation
3D Game Programming - Episode 10 - Floors and Animation
The Cherno
12 3D Game Programming - Episode 11 - Rotation
3D Game Programming - Episode 11 - Rotation
The Cherno
13 3D Game Programming - Episode 12 - User Input
3D Game Programming - Episode 12 - User Input
The Cherno
14 3D Game Programming - Episode 13 - Render Distance Limiter!
3D Game Programming - Episode 13 - Render Distance Limiter!
The Cherno
15 3D Game Programming - Episode 14 - Basic Mouse Movement
3D Game Programming - Episode 14 - Basic Mouse Movement
The Cherno
16 3D Game Programming - Episode 15 - Textures + More!
3D Game Programming - Episode 15 - Textures + More!
The Cherno
17 3D Game Programming - Episode 16 - Walking, Crouching, Sprinting + More
3D Game Programming - Episode 16 - Walking, Crouching, Sprinting + More
The Cherno
18 3D Game Programming - Episode 16.5 - Exporting Runnable Jars
3D Game Programming - Episode 16.5 - Exporting Runnable Jars
The Cherno
19 3D Game Programming - Episode 17 - Small Adjustments + Birthday!
3D Game Programming - Episode 17 - Small Adjustments + Birthday!
The Cherno
20 3D Game Programming - Episode 17.5 - Creating an Applet
3D Game Programming - Episode 17.5 - Creating an Applet
The Cherno
21 3D Game Programming - Episode 18 - The Beginning of Walls
3D Game Programming - Episode 18 - The Beginning of Walls
The Cherno
22 3D Game Programming - Episode 18.1 - A Few More Things
3D Game Programming - Episode 18.1 - A Few More Things
The Cherno
23 Episode 18.5 - Creating an EXE File in Java
Episode 18.5 - Creating an EXE File in Java
The Cherno
24 3D Game Programming - Episode 19 - Rendering Walls
3D Game Programming - Episode 19 - Rendering Walls
The Cherno
25 3D Game Programming - Episode 20 - Continuing Walls, Fixing Bugs, and Managing Crashes
3D Game Programming - Episode 20 - Continuing Walls, Fixing Bugs, and Managing Crashes
The Cherno
26 3D Game Programming - Episode 21 - Texturing Walls, Fixing Clipping, and Fixing the Mouse
3D Game Programming - Episode 21 - Texturing Walls, Fixing Clipping, and Fixing the Mouse
The Cherno
27 3D Game Programming - Episode 22 - Random Level Generator + Properly Fixing Clipping
3D Game Programming - Episode 22 - Random Level Generator + Properly Fixing Clipping
The Cherno
28 3D Game Programming - Episode 23 - Graphical User Interface (GUI) Launcher
3D Game Programming - Episode 23 - Graphical User Interface (GUI) Launcher
The Cherno
29 3D Game Programming - Episode 24 - Making Our Launcher Work
3D Game Programming - Episode 24 - Making Our Launcher Work
The Cherno
30 3D Game Programming - Episode 25 - Writing and Reading Files
3D Game Programming - Episode 25 - Writing and Reading Files
The Cherno
31 3D Game Programming - Episode 26 - Custom Resolutions
3D Game Programming - Episode 26 - Custom Resolutions
The Cherno
32 3D Game Programming - Episode 27 - Decorating the Launcher
3D Game Programming - Episode 27 - Decorating the Launcher
The Cherno
33 3D Game Programming - Episode 28 - Continuing our Custom Launcher!
3D Game Programming - Episode 28 - Continuing our Custom Launcher!
The Cherno
34 3D Game Programming - Episode 29 - Launching The Game
3D Game Programming - Episode 29 - Launching The Game
The Cherno
35 3D Game Programming - Episode 30 - Colour Processing In-Depth
3D Game Programming - Episode 30 - Colour Processing In-Depth
The Cherno
36 3D Game Programming - Episode 31 - Sprites!
3D Game Programming - Episode 31 - Sprites!
The Cherno
37 3D Game Programming - Episode 32 - Sprite Mapping
3D Game Programming - Episode 32 - Sprite Mapping
The Cherno
38 3D Game Programming - Episode 33 - High Resolution Rendering
3D Game Programming - Episode 33 - High Resolution Rendering
The Cherno
39 3D Game Programming - Episode 34 - Entities
3D Game Programming - Episode 34 - Entities
The Cherno
40 Genesis - My Game for Ludum Dare 24
Genesis - My Game for Ludum Dare 24
The Cherno
41 Vlog + Ludum Dare Results
Vlog + Ludum Dare Results
The Cherno
42 Game Programming - Episode 1 - Resolution
Game Programming - Episode 1 - Resolution
The Cherno
43 Game Programming - Episode 2 - Threads
Game Programming - Episode 2 - Threads
The Cherno
44 Game Programming - Episode 3 - Game Loop
Game Programming - Episode 3 - Game Loop
The Cherno
45 Game Programming - Episode 4 - Window
Game Programming - Episode 4 - Window
The Cherno
46 Episode 5 - Buffer Strategy
Episode 5 - Buffer Strategy
The Cherno
47 Game Programming - Episode 6 - Graphics Initialized
Game Programming - Episode 6 - Graphics Initialized
The Cherno
48 Game Programming - Episode 7 - Buffered Image and Rasters
Game Programming - Episode 7 - Buffered Image and Rasters
The Cherno
49 Game Programming - Episode 8 - The Screen Class
Game Programming - Episode 8 - The Screen Class
The Cherno
50 Game Programming - Episode 9 - Rendering Pixels
Game Programming - Episode 9 - Rendering Pixels
The Cherno
51 Game Programming - Episode 10 - Clearing the Screen
Game Programming - Episode 10 - Clearing the Screen
The Cherno
52 Game Programming - Episode 11 - "Out of Bounds, Baby!"
Game Programming - Episode 11 - "Out of Bounds, Baby!"
The Cherno
53 Game Programming - Episode 12 - Negative Bounds
Game Programming - Episode 12 - Negative Bounds
The Cherno
54 Game Programming - Episode 13 - Timer
Game Programming - Episode 13 - Timer
The Cherno
55 Game Programming - Episode 14 - FPS Counter
Game Programming - Episode 14 - FPS Counter
The Cherno
56 Episode 15 - Tiles
Episode 15 - Tiles
The Cherno
57 Game Programming - Episode 16 - The Map
Game Programming - Episode 16 - The Map
The Cherno
58 The Walls 2 - Minecraft PvP Survival Map
The Walls 2 - Minecraft PvP Survival Map
The Cherno
59 Game Programming - Episode 17 - Key Input
Game Programming - Episode 17 - Key Input
The Cherno
60 Game Programming - Episode 18 - Controlling The Map
Game Programming - Episode 18 - Controlling The Map
The Cherno

This video covers the process of defining and creating spawn level tiles in a game using Java, including setting up tile classes and properties. The instructor explains how to organize and structure the code to make it efficient and easy to maintain.

Key Takeaways
  1. Create a new tile class for each type of tile
  2. Set up the properties for each tile class
  3. Use inheritance and polymorphism to organize the code
  4. Implement the render method for each tile class
  5. Add properties such as solidity and breakability to the tile classes
💡 Organizing and structuring the code is crucial for efficient and maintainable game development

Related Reads

📰
How Creative Characters Like Sprunki Inspire Kids to Learn Coding
Learn how creative characters like Sprunki inspire kids to learn coding through interactive games and animations
Medium · Programming
📰
Computer Applications for Primary School Children: A Fun + Safe Guide for Ages 6-12
Learn how to introduce primary school children to computer applications in a fun and safe way, teaching them essential skills for the future.
Dev.to · Ogunkola Adeola
📰
From 0 to 20 Chapters: My Story‑Driven Rust Book for Kids Now Has a Bilingual Interactive Demo
Create an interactive coding book for kids using Rust, with a focus on storytelling and bilingual support, to teach programming concepts in an engaging way
Dev.to · born1987-ir
📰
How Kids Can Build Fighting Games Stickman in Scratch
Kids can learn coding by building a stickman fighting game in Scratch, developing skills like movement control and collision detection.
Medium · Programming
Up next
Man Builds a Backyard Tiny House and Turns It into a Home Office | Start to Finish by @Elseweyr
AKLA GELEN
Watch →