Game Programming - Episode 40 - Mob Framework
Key Takeaways
The video covers the implementation of a Mob Framework in Java for game development, focusing on the differences between entities and mobs, and creating a Mob class that extends the Entity class.
Full Transcript
hey what's up guys my name is aeno and let's talk about mobs so last episode we talked about entities and how they sort of interact with our game and what they are basically and today we're actually going to take a look at mobs so what are mobs mobs are basically like well mobs like the word mobs like mob literally means like a group of something um but you know in in games I guess uh what a mob is it's basically like a like a player or it's essentially it's like a a creature that moves um um or a creature even you could just call it like that um if you guys play Minecraft for example that's probably a a game where um they've actually you know been called mobs like the whole the time not only in development but actually in the actual game um but yeah so yeah a mob think of a mob as like I don't know anything from like a cat to like a player that's a mob um so basically today we're just going to take a look at what they are and really the difference between an entity and a mob so in other words you know a mob is still going to be an entity obviously because an entity is pretty much any object on our actual screen except for like the map so like tiles um so yeah mob is still an entity but you know we're going to talk about really um what what like what other features a mob brings to the table so in other words the additional um the additional characteristics of a mob so first of all over here at um in our package Explorer or sorry our navigator on our entity folder we're just going to right click and create a new class and we're actually going to put it into its own uh package called mob and it's literally going to be mob that's just going to be our our mob class so you can see now we've got a nice hierarchy going on here in the Navigator and over here in our mob class first thing we need to do is make sure that it actually extends entity all right because it is an entity and we sort of wanted to um you you know to inherit all of these all these variables that we've um created um we'll also make it abstract and that's about it so again abstract means it can't be you know instantiated because we don't need it to be instantiated because in no case will we actually be creating a new mob class because um again we're using mob as a template for all of our actual mobs that we create so um how does a mob you know differ from an entity now I was talking about this yesterday and not yesterday the day before talking about this the day before and um and I mentioned that entities don't necessarily have Sprites now mobs do have Sprites all right so the first thing we need to do basically is say that you know it's got a Sprite object we need to have a we we need to have a Sprite object and I'll just make it protected for now again um with visibilities you know you can change them obviously so if I change this down the line you know just don't don't worry about it but it's not that important if I make everything public the game will still run exactly the same as it would it's just for pro it's good programming proes to actually restrict some variables because that sort of reduces the margin for error if you accidentally access the wrong variable or in other words you know we should be we like in other words um in this case it'll help us out having it projected because um basically that that tells us that that this Sprite variable can only be used you know within the mob um class and all of its um all of its sub classes so it can't be used outside of the mob class basically you can't be used outside of the mob out of the mob's um out out of mobs okay so only mobs can actually access the Sprite all the different mobs that we create in the future because only only subclasses can actually access this Sprite variable so the other thing is um mobs also tend to have a Direction so protected in uh di stands for direction will probably uh have it at zero for now um zero is usually North you know one is East two is south and three is West that's sort of the way that it usually works um or at least that's how I've always been doing it um the other things I'm not going to get too complicated into here right now but um the other thing is probably protected bullying um walking or moving um so that equals to false and the reason is that mobs usually have an animation when they're moving moving um so you know we want to be able to manage that here as well now as for methods um there is going to be a move method I I will literally just create that right now to public uh void move in fact no no I might actually keep it as public not projected um to explain why and the reason uh when we actually get to it um I'm not actually going to put in any paramet to it just yet I will modify that move method in the future but I'm just you know sort of doing an outline for you guys uh the other thing is public void update obviously because mobs need to be able to be updated so in other words their location their position all that stuff needs to get updated um and you know we have other things like Collision which um we could deal we're not going to deal with it right now um but so I'll just simply put it as private bullying Collision so in other words if there's a collision it'll return true if there's no Collision it'll return false and obviously you know for now just to get rid of this error we'll just return false but yeah that's basically the way that a mob works now one thing I haven't factored into here that probably will be in the final game um well no that's there's obviously a lot of things but I mean out of the technical aspects probably lighting we're not actually managing Lighting in here at all but you know we'll probably move on to that when um when the time comes so yeah that is basic overview of the m class it's pretty much all we need to get a mob working again this move method will actually we actually have to fill it in with something update method will stay um pretty much empty as it is now um and all these variables will give us the everything we need to know for our mob so yeah um I hope you enjoyed this episode of game programming if you did guys please hit the like button and I will see you guys next episode so yeah later guys
Original Description
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
🎓
Tutor Explanation
DeepCamp AI