Code a 2D Game Engine using Java - Full Course for Beginners
Вставка
- Опубліковано 14 жов 2024
- Learn how to program a 2D game engine from scratch using the Java Programming Language. You will use the game engine to create a Super Mario Clone but the engine can be used to create other games as well.
💻 Code: github.com/cod...
✏️ Course created by GamesWithGabe. Check out his channel: / @gameswithgabe
🎥 Part 2 (final hour of this course): • Code a 2D Game Engine ...
⭐️ Course Contents ⭐️
⌨️ (00:00:06) Introduction
⌨️ (00:07:54) Setting up the Window with LWJGL
⌨️ (00:25:20) Adding Event Listeners with GLFW
⌨️ (00:51:42) Creating a Scene Manager & Delta Time Variable
⌨️ (01:11:26) How OpenGL Graphics Programming Works
⌨️ (01:32:53) Drawing the First Square
⌨️ (02:02:56) Regexes and Shader Abstraction
⌨️ (02:24:25) Game Camera OpenGL
⌨️ (02:47:47) GLSL Shaders
⌨️ (03:08:45) Texture Loading in LWJGL3
⌨️ (03:36:02) Entity Component System
⌨️ (04:06:25) Batch Rendering in LWJGL3
⌨️ (04:50:00) Resource Management in LWJGL3
⌨️ (05:05:30) Texture Batching
⌨️ (05:38:48) Spritesheets
⌨️ (06:01:12) Dirty Flags in Rendering
⌨️ (06:23:17) Alpha Blending and Z-Indexing
⌨️ (06:38:56) Integrating ImGui
⌨️ (07:01:56) ImGui Fonts and Scene Integration
⌨️ (07:19:43) Serialization with Gson
⌨️ (07:42:48) Deserialization with Gson
⌨️ (08:06:03) Exposing Variables to the Level Editor
⌨️ (08:25:29) Converting Screen Coords to World Coords
⌨️ (08:49:27) Drag 'N Drop Level Editor
⌨️ (09:15:25) Debug Drawing Functions
⌨️ (09:47:35) Snap To Grid Tool
⌨️ (10:10:25) Debug Drawing Boxes and Circles
⌨️ (10:28:58) Framebuffers in OpenGL
⌨️ (10:52:56) ImGui Docking in Java LWJGL
⌨️ (11:11:55) Adding a Game Viewport
⌨️ (11:34:51) Mouse Screen Coordinates to Game Viewport Coordinates
⌨️ (11:50:01) Pixel PERFECT Mouse Picking
⌨️ (12:23:39) Enabling Mouse Picking and Code Maintenance
⌨️ (12:35:16) Editor Camera Controls with Lerp
⌨️ (13:01:48) Coding Gizmos
⌨️ (13:31:03) Translate and Scale Gizmo
⌨️ (14:04:29) Properties Panel
⌨️ (14:33:53) Integrating JBox2D in our Engine
⌨️ (14:54:53) Event System and Box2D Physics
⌨️ (15:19:09) Adding an Engine Runtime (Play/Stop Buttons)
⌨️ (16:10:10) Refactoring and Physics
⌨️ (16:40:28) Font Rendering
⌨️ (16:43:34) Beginning Scene Hierarchy & ImGui Upgrade
⌨️ (17:00:38) Scene Panel Drag & Drop (ImGui)
⌨️ (17:18:31) Even More Bug Fixing
⌨️ (17:44:51) 2D Animations
⌨️ (18:18:29) Sounds with OpenAL
⌨️ (18:44:27) Improving the Editor
⌨️ (19:21:24) How to Use Box2D Physics
⌨️ (20:06:12) Pillbox Colliders and Player Controllers
⌨️ (20:45:32) Variable Length Jumps
⌨️ (21:25:28) Powerups
⌨️ (21:51:52) Goomba AI
⌨️ (22:29:59) Mario Pipes & Editor Improvements
⌨️ (23:01:59) Game Camera & Grid Lines
⌨️ (23:28:28) Mario Turtle AI
⌨️ ( • Code a 2D Game Engine ... ) Adding Flag Poles to Mario
⌨️ ( • Code a 2D Game Engine ... ) Fireballs and Bug Fixes
⌨️ ( • Code a 2D Game Engine ... ) The LAST Episode and Distributing your Game
🎉 Thanks to our Champion and Sponsor supporters:
👾 Raymond Odero
👾 Agustín Kussrow
👾 aldo ferretti
👾 Otis Morgan
👾 DeezMaster
--
Learn to code for free and get a developer job: www.freecodeca...
Read hundreds of articles on programming: freecodecamp.o...
Thank you so much for hosting my videos on your channel Beau! And not only hosting them, but taking the time to put them all into a giant video! I hope anyone who watches this is able to find some use out of the series, and if you want to go more in depth about game engine development, I can't recommend "Game Engine Architecture (3rd Edition)" by Jason Gregory highly enough (it's a big blue book :).
I'm also working on a new series that goes in depth on how to code a Minecraft clone. It only has two episodes out right now, but if this is something that interests you, feel free to drop by the channel. Once again, thanks for all the work you put into combining these videos together Beau!
Thank you!
God bless you
yes, minecraft clone 100%
He got the recognition he deserved 👏
It’s an awesome video and an awesome channel
Incredible. As a mid-30s year old guy who is self-learning I find this type of content to be invaluable.
so have you got it around? i've started to practiced how to set the window and error handling and the buffer objects.
@@graphitic5578are you focused on game dev? Been learning to code java for over 6months now doing oop stuff.
How you doing so far bro?
@@EyBossPusi i feel angry. Not directed at gamedev, i try to compartmentalize it from my personal life as much as I can. I have no room i can retreat to, anywhere else is being seen and watched.
23 hrs of learning content! wow 🔥
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
actually 23:50 so almost 24h
Technically it's 23:50 means 24 hours😰😰
23:50:34*
There is a part 2 actually
For anyone trying to follow along on MacOS, if your glfw window creation gets hung up navigate to Run > Edit Configurations... > Modify Options > Check "Add VM Options" > and then add -XstartOnFirstThread into the field that pops up.
THANK YOU!!!!!! Ugh that was frustrating. Your clear comment saved us!
Yeah thank you so much I was so confused and this worked!
OMG THX SOOOOOO MUCH!!! I spent over an hour trying to figure out the error, and your comment fixed it in 30 seconds!
I spent hours trying to solve the problem, thanks god I thought about checking the comments. Thank you very much mate.
you guys posted a WHOLE 24 HOUR course just like this???? Love each one of you!
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
For my access
1.) 25:21 event handlings (mouse and key listeners)
2.) 51:46 scene manager
3.) 1:11:28 how to program the GPU
4.) 1:32:55 The first square
5.) 2:02:58 Regexes and shaders.
that's insane. i'm not going to practice this but this is a good job
😂
🤣🤣
😂
😂😂 That's really hilarious
Yaa exactly
Insane! That these content are free. I wish companies can look at job candidates differently these days because degrees are not needed to do a job well.
I wish the same. Degrees are outdated.
The future is looking bright because here in Toronto Canada, major companies (like big banks and other large tech companies) have removed their degree requirement and only require programming skills and knowledge. Hopefully this will become a reality everywhere else.
@@jrbaprz that’s good news! I’m a Vancouverite and I’m def seeing the same! Having said that, alumni network still plays a big effect so without it requires candidate to network a bit more to get the job. I also see that Google has done the same!
What’s pushing for this is a big gap in STEM especially tech talents. Very good changes!
They're not needed to do a job well, but having a degree tells the employer "this employee can do some number of skills in this field already based on what the standard curriculum is". There's no standard for the quality of a youtube tutorial, no matter how well made.
@@RegiRuler that's what people don't understand, a person without a degree can obviously be better than someone who owns one, but it just takes triple the effort, if not more. The thing is, some companies just don't want to take the risk.
This is insane...23 hrs content !!!!! Huge respect for free code camp and the content creator.....🔥
For people with a different version of inteliJ at about 2:10:00 when he's mentioning about modifying VM options (if you're not seeing VM options available for modifying, you will just need to click Modify options and check Add VM options)
thanks, I knew checking the comment section in this type of video will help a lot regarding changes in the ide and stuffs
Thank you!
Currently I am trying to develop a bouncing ball game by using design patterns in java. So, I can't imagine how much background needed for such a mario game in 24 hours. This is not a lecture this is a show.
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
Bruh, that game was fun and those good old days of nokia keypad mobiles.
This seems extremely informative, the only problem I have is I am unsure which files I should be downloading without having to search and hope I am getting the right stuff to properly follow along with this course
In any case I appreciate such a thorough (I think) walk through of what needs to be done with the tech available to us now to achieve similar results. Thank you!
Which files are you having trouble finding?
Imagine someone watches this video in one day. Jokes aside, this is incredible. You're very talented!
that guy would hit world record, as that would be impossible (in normal video speed)
Wow! Wow! And Wow! I enjoy Java and have been teaching it for 10+ years! This is incredibly generous! Thank you! Did I already say WOW?!
Dude, in your videos you're a 10yo kid... Or isnt it you?
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
Can Someone tell me wich ide is it used in the video?
@@karasu6182 Intelli-J.
@@oliveryt7168 so what if he's 10? i learnt scratch when i was 9 and learnt Unity C# when i was 12
I personally started programming with learning to build game engine with java and I'm still working with java.
This video will be very helpful to start java I believe.
Great job. Thanks.
Hey there , Actually I am preety much confused that in which field should I enter web , app , game , blockchain development can you call out a domain which is in scope today ? And one more question is development really needed can't I just get job with good competitive skills
@@nishantdalvi9470 by competitive skills you mean skills in competitive programming ? And just get into something that you like, if you didn't study for a diploma it will be hard to get a job honestly, maybe web is the easiest, and less regarding of your diplomas. In the end you will need experience in your domain so just pick one and learn (sry english is not my native language)
@@giltham2934 Yes I mean by competitive coding can I get a good job out of it without doing any development . I am pursuing bca degree
@@nishantdalvi9470 it's your knowledge in a specific domain that will help you get a good job. Being good at competitive programming will maybe help you during a technical interview, but if you apply for a job in desktop developpement, and you don't have a lot of experience with the technology used or the domain in general, don't expect to be recruited. BTW, competitive programming is great if you take your time to implement robust solutions, but if you do it for speed it will just train you to implement bad solutions to problems you know by heart. Conclusion : programming competitions are great on the side, but they are not training you at all for practically any domain.
@@nishantdalvi9470 You COULD get a job with competitive programming, but it's generally for the top competitors that are VERY GOOD at it and are doing this on a daily basis for months/years
Millions of humans are missing this channel . This channel is more precious than my college degree !!!
Really helpful , need more like this...
Giving thanks from every cell of my body...
Really great job...
Feedback- if u first show a roadmap for all the things you used and a short or tutorial type on those concepts then that would be even more better..
But still thanks man..
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
Feel like 👍
If anyone is attempting this on Apple ARM silicone, for your OpenGL to compile correctly you need to add the following code within Windows init() with all other configurations.
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
WHAT THE, SO I HAVE BEEN LOOKING FOR THIS TH WHOLE TIME (SEARCHED FOR 300+ VIDEOS) FINALLY. thanks
Wow... my heart pulse is raising when saw the title of the video.
Let's try to find some free time, then start follow the video :)
guys you are the best ever !!! 24 hours of game engine basics just like that! That's why you are the best!!! Insanely cool!
ScanKey codes are GREAT if you code like I personally like to (using a lot of arrays and array manipulation). You basically store each key-state in a numbered array and that scan-key-code indexes to whichever key in the array. Works great to handle multiple-key-presses and custom-binding operations.
only an 1 hour and 10 minutes in and I have learned a lot about object oriented programming thank you!
I didn't even know UA-cam videos could get this long.
I always thought it capped at 12 hours.
Great Video! I like how you are using existing classes and libraries for this tutorial. As one of my favorite C++ programming instructors would also say " in programming never re-invent the wheel".
Wow! That means we will be stuck with same software, libraries and frameworks forever ? Lol, Reinventing the wheel can be beneficial in certain situations and can lead to new software, libraries, and frameworks that make things easier to work with. It’s important to note that it depends on the situation as well as the need of a particular thing. If you’re working for some company and tied with the limitations and deadlines, then probably the wise choice will be to use whatever other programmers have created. But if you’re learning and doing your side project, then reinventing the wheel can help you learn new things and set you apart from anyone else. This way you’ll learn a lot that no one else will have exposure to and which in return will make you eligible for companies people only dream about. It’s not “never reinvent,” instead it should be “Don’t reinvent the wheel when you don’t want to explore or learn something new instead want to get the work done anyhow”. A lot of people will say that if we reinvent the wheel then we are just wasting time on things that don’t matter and we can give that time to other things like beautiful graphics and all. If you think you want to give time to graphics and reinventing the wheel will just slow you down then I think you should reconsider your decision about what you really want to do: Game programming or Game designing because both fields are totally different having knowledge about both is good and beneficial but if you think doing things from scratch is going to waste time then I think Game engines are better choice in that case because why make engine at all? It also comes under reinventing the wheel in one way
If you are using a mac. And need to get it to work properly, you will go through his process. But, in the edit configuration settings, you won't see VM options by default. You have to click 'edit configurations' and then from that drop down select, 'Add VM options' to make sure it checked. After that, the option to paste '-XStartOnFirstThread' will be there. paste it in. click apply. click ok. then run the program.
also, mac dosent like the glsl files in java, c++ works better as far as translation. You will have to rework the default.glsl file.
You guys are amazing, thank you so much for sharing knowledge for free on UA-cam! 🔥 ❤️
Me watching: this is so cool I want to learn how to do it too.
1 hour later: learning for loops
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
This is honestly one of the best things I have seen online. You rank up there with the Ben Eater videos. You taught me something I can take, and make something of my own with. Most people seem to want something you, or lead you to dead ends due to non functioning code. Or not understanding what they are doing and talking in circles. I can listen to you, like a podcast and literally come back to my computer and know what to do.
You're like the breakfast club of 2d gaming. I woulda said JOe Rogan, but I think he's canceled; smh..
Your code works. For mac, takes a little tweaking. Especially for drawing to the graphics card. Keep creating. Even if you think it is redundant, Series like this need to exist.
Advise for mac users on intelleJ. On the step where you create a String to hold your GLSL file, do a struct instead. Separate the lines exactly as your default glsl. If not, you will have to physically count the spaces after you copy and past the info into the string. Then go into the Shader class, and adjust the length of the Array that is holding the fragment and vertex shader info. .
Keep it up dude..
I think yours is the best video in the series so far.
Did you watch the whole video
Damn this video is a whole day long o-o
Props to you for making that tutorial !
24 hours, absolute unit.
It is good to have this, but the catch is , consider many developers are in developing countries, now they might not have this much internet access to follow up a 24 hour long video, moreover it will be beneficial to post it in some blog, (readable format) so that if people want to refer to some specific part , it would be beneficial to them. Nice job. !!
Almost 50 minutes in and following along and holy smokes such a vast amount of information. Will come back after i'm done
You either didn’t finish or never came back.
@@TheOriginalDuckley did u finish? how was ur experience . would u recommend it?
@@Shubham-fn3pjI think it’s useful to learn Java, and the necessary concepts for all game engines really.
That being said, since I want to get serious with game engines, I have pivoted to learning C++.
I made it to the point in this video where he started to integrate IMGui before I stopped. So no I did not finish it fully.
I believe it’s worth it still even if I didn’t finish it. I learned A LOT. And it motivated me greatly to keep going.
@@TheOriginalDuckley thanks. All the best man . Where are u from ? (Just curious)
@@Shubham-fn3pj I am American, I know… eww 😷 😂
Impressive. Thanks for your time and sharing your experience!
An entire day of Java, this is insane.
And glsl bruh
23 hrs of learning content! wow
Wow this is incredible. I’ve wanted to learn how game engines work but didn’t know where to start. Plus I already know Java, so that’s a plus.
Hey, since you know Java, do you have any link to a game engine written in pure java without lwjgl and so on?
Finally gave me an excuse to learn Java. Can we do this using C++ too?
Of course CPP is the most powerful language for high performance apps
C# is so much better than Java. Java is just unnecessarily complex.
If you go to Gabe's channel (the guy who made this course) he's currently making a series in c++ focused on the development of a Minecraft clone (with it's own unique features).
It's not exactly the same as this one, specially since It's focused on the game rather than a game engine, but a lot of the same concepts will be there. It currently only has a couple of episodes though
@@fieryscorpion
C# is a good language, but java is a good language as well.
You think it is unnecessarily complex because you don't know it, like you know C#.
I am not very good at java, I work as a programmer and write primarily C#.
Java looks much like C#.
Sure some keywords differs, but you get a hang of it quick.
@@fieryscorpion agree
this turtorial video took 23 hour, wow! Im not going to pracite because is too long but briliant!
And with this video, I now have roughly 50 hours of Java videos to watch
I think this si the biggest video yet? Funny, I was learning Love2D, now this comes.
If using Mac, you must add the following windowHints before your shaders will compile successfully:
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
Took me a few hours to find out I had to do this. Also don't be stupid like me and use gl_position instead of gl_Position😅
Props to whoever finishes this tutorial
SO grateful for the great free content.
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
I'm going to try and run though this over the break. If I can get 30 min done a day it should only take me a few months, and should be helpful for school
I'm very excited to build this!!!
But still couldn't find time to do it :(
Will you record a tutorial using C++?
OMG. The amount of effort you are wasting to make this vid is so insane. we cant thank you enough
wasting isnt the word youre looking for, buddy
@@danisob3633 spending it is.
This channel is better than my university
To anyone wanting to actually learn from this course: this course is NOT beginner friendly, you first have to get intermediate in java programming in order to fully understand what's going on here.
This is the best and most insane tutorial I have ever seen, although I am not very good is java, it will still be a great try this one.
C# is so much better than Java. Java is just unnecessarily complex.
@@fieryscorpion I know C# because I use Unity to make games. But I would be cool to make your own game engine.
@@fieryscorpion bruh.
Great video thanks for share your knowlegde. the key question here is, why did you use LWJGL instead of LibGDX? Thank you man.
Wow, 23 hours. That's great, I'm going for it.
Ok, i'll try to make it using c++
1st step: I chose to use SDL2 library to display windows on my computer. I'm coding on Clion usign CMake. SDL2 configuration can be pretty messy for newbies (like me).
2nd step: find a deisgn a pattern for the singleton in cpp. I personally chosed to use a thread-safe design pattern.
Thank you this is what I wanted for so long
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
Hattss off u guys just wow 🙏🙏🙏🙏🙏 appreciate u ........ Wil try best to promote u
Starting my attempt to follow this tutorial today!
Just insane.
You deserve to get rich.
how did this channel get to upload one day of footage!?
Mindblowing
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
Awesome! Definitely going to try this one!
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
That is simply amazing, thank you so much!
For those getting some weird numbers or infinity on your delta time/fps counter and your code is fine, it's propably because you have a intel CPU, try updating the drivers and that might fix it.
I spent 3 hours trying to find a mistake that i didn't make :)
I hope to activate the translation icon in all languages so that everyone can benefit from this valuable content. Happy New Year
@@danielmbcn shut up
Don't you think if he forces you to learn English first, you not only learn a bit about 2D engines with java but also is ready for world wide market once English is the basic language for such?
@@danielmbcn it’s spelt amoeba. If you’re going to tell people to learn English, learn to use it yourself first lmao, very embarrassed for you !!
You’re legend!! Thank you for everything!!
thats a 23 hour video
Yep it is
Great observation
True.
JAVAAAAA!!! i love javaaaa!
wish you have certification course in java as well like c# and Javascript.
48:50 bookmark🔖
Holy ...... :O 23 hours :O
New purpose for 2022: finish this course.
Almost 24 hours of content. How tho? UA-cam was limiting video Length max 10 hours. Or not anymore?😲
Great job. Thanks for sharing. Learning always should be for free.
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
Goodness gracious. A 24 hour long video!
Alomst an entire day just of an video
Straight for one day. That's unbelievable 😳
Given the length of the video it would be very useful (maybe even necessary) to split the parts and adress them so the viewers can jump between them
Would be useful anyway sonce no one will do the video in one go
Awesome I don’t think feedbacks needed
boss,
seriously, next level content!!
Thank you so much for this video..
i was just thinking about mario when I saw this video! I am so excited! Oh my God!!
Thank you 🤗 Thank you 🤗
Please put subtitles on it for those of us who are not English speakers.😅
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ Thank you for the info !
23 hours👀🤪
I think this lesson will be very useful
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
Now, this is how you start the new year Ladies and Gentleman!
Me: Sleeps
Him: Continues talking
i didn't sleep for 24 hours watching this course, i only ate for 1 hour
I always wanted to make my own game engine, even though I won't be starting right now as my routine don't have any time, neverthless leaving this comment and saving video, one day hopefully I will come back and make my own game engine
Did you ever end up making your own game engine? If so, how did it go? If not, what went wrong? :(
Hello freeCodeCamp , could you please add the subtitles option for people who have some struggles in english like me ?it is something you usually do with your other playlists , thank you !
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
in his channel (GamesWithGabe), it has subtitles, you can watch it from there too.
I have watched 1/3 of this video concurrently with his playlist in his channel, and both sources are basically the same
This channel is insaneeeeeeeee
Thanks for the vid, mic quality can be a bit better tho !
You guys are just Amazing.
Thank you so much
yeah its nice (want second part pls)
It's a 24 hrs course 🤯🤯🤯
I had better get started on this.
I'm super grateful that we're given the source code for this. I can't wait to look through it and play around with it!
Where is the code
Very useful and insightful. I would like to see more of such videos as I am currently developing a game in Android.
kudos to instructor/fcc for creating ~24 hours of content
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
my brain exploded after 4 minutes
Not going to be following this tutorial, just here to say that this is crazy nice job :)
6:01:08 I like how this "chapter" being abruptly ended
Thanks!
coincidentally enough i was following his lwjgl tutorial a few days ago
amazing work thank you
Wow, this is AWESOME....
@WhatsApp➕➊➌⓿➊➌➏➌➏➋➒➌ shut up bot
jeez 24 hours hello world