3D Game Programming - Episode 1 - Window
Skills:
AI Pair Programming90%
Key Takeaways
Creates a window for a 3D game using Java from scratch
Full Transcript
what is up guys my name is the Cho or Yan you know cuz the Cho is not really on my birth certificate but whatever you can call me Yan if you want um and welcome to something completely different welcome to uh the first video of a series of videos in which I am going to attempt or we are going to attempt to create a a 3D game in Java from scratch using no game engines using no open GL interfaces like lwjgl lightweight Java game Library um nothing except the inbuilt libraries into Java 1.6 okay so from scratch from zero from this from not even a project um and yeah so at this rate probably like a first-person shooter or something like that you know we'll see we'll see how this goes um now I assume that you guys have a bit of knowledge have a you know a bit of knowledge of java you know you've done a bit of java maybe um I don't expect you guys to be able to write your own programs but um I just want you guys to understand the syntax if you don't or if you've done no Java but you really want to or whatever um there'll be a link in the description of this video um that will link you to the new Boston's Java tutorials because they are really good they're the best tutorials on YouTube in my opinion um on on Java um and that's not how I learned unfortunately but um I do I do tell everyone to to go look at them if they're interested in learning um so yeah uh okay let's start this is Eclipse by the way um eclipse is in my opinion the best IDE for Java um an IDE is sort of like a program which really like helps you helps you write code because it it um it compiles it for you you know lets you debug the code um it shows you all the errors in your code there's a nice little outline over here um you know and it it's basically it's you need to have one of these um I've used other ones like Java beans and intell idea I actually used L for a while but eclipse is in my opinion the best and also you know Notch uses it it's going to be a major selling point um Minecraft was made on it so there we go it's good um yeah so first thing we're going to do is create a new project so oh by the way if you want to download a Clips there'll be a um there'll be a link in the description of this video where you can download it um for Windows for Mac for Linux anything you want um Java works everywhere unlik you know C++ um so yeah want to create a new Java project file new Java project um we'll be using 1.7 I think that's still in beta I'm not sure but um anyway we're going to be using 1.6 so make sure it's on 1.6 um I'm going to call this project MF front because mine front is actually a game that I'm working on and I can't think of any other name at the moment so M front it is um and yeah just type a project name you can type whatever you want and hit finish it's going to create a new project over here as you can see um yeah so the first thing we need to do is create a new class now our class um is basically like a group of code um it's because what what what what we need um in the beginning is like a class to basically tell the program okay what we want to do is create a new window we want to put you know our content in the window you know all of that stuff we need we need we need a group of code which tells us to sort of initialize the program and later on initialize the main game Loop which will update you know however many times per second frames per second all that stuff we'll get to that soon um I'm just going to call this um display because this code will sort of be all all of our display um stuff right in here and we want to put into a package now it's I've I've thought about how to describe this and in my opinion I think the best way to describe this is probably to um to say that you don't want to leave your source code out in the front garden you sort of want to put it into the house and into the kitchen um or the bedroom you know it's not necessarily a woman uh so yeah you could put into the bedroom instead of the kitchen um but yeah and the way that we do this is we sort of dots are like backslashes or for slashes or whatever but in Java they're dots they indicate folders so inside com there'll be a folder called m and then there'll be folder there called mine front so I'm just putting into a series of folders this is just good practice in Java it's what everyone does um I would create this um but I'm going to type it by hand um I'm going to type it you know just in front of you guys so that you can see exactly what I'm doing um yeah so once you've filled out a package and once you've filled out a name for the class hit finish and first thing I which bugs me is that we don't have line numbers so just going to go ahead and whop where are we editors text editors show line numbers okay so it's in general editors and then text editors show line numbers and now we got we know how many lines of code we've typed um or how many exists anyway so yeah that's the first useful thing okay so basically what I want to do today is I want to um just create a window that's that's our that's our goal for this video basically cuz I really want to explain this in as much detail as possible um which is going to be hard if I type a lot of code and I've thought about this a lot and this is actually my third time trying to record this because it ends up being like half an hour long I'm not even joking so all we want to do here is create a window so the way we do this is we want to create two integers int stands for integer it's a keyword in Java um we need to give that a name so we'll call it withth and then we want to set it equal to an integer so to a number without decimal points 800 okay that's how wide we want to have it for now we can change that later um we also need to create an ing for the height oh and by the way I'm doing this like I'm doing this completely off the top of my head like all this game programming stuff this will pretty much be um you know live I guess on the fly so I don't know what I'm creating yet we'll we'll work we'll work on it together um so yeah so I'll I'll probably go back and fix some things and explain why I'm doing that and so on and so forth um the other thing we want to do is we want to create a main method so public static void Main cred ni array of strings um okay and basically what this this is like this method is like a group of code inside the group of code um and the reason we have to create this one is when our program starts it looks for the main method um and the thing is that it'll it'll do it'll execute whatever code is inside here like it'll obviously execute everything but it will it will sort of start over here and this basically okay this really hard to explain basically you need this to run a program you need this method um if you don't know what a method is again Link in the description to the New Boston tutorials they're excellent view them they're really good and they'll really help you follow along with this um okay so the first thing we need to do is we need to create an object of this display actually first of all let's just extend canvas canvas is an is an inbuilt thing into Java of Java or awt um and this will help us this will this is pretty much required in order to um create a window um display game equals new display okay so what what I'm doing here is I'm creating an object um Java is an object oriented programming language so first thing we need to do is we need to create an object of this class called display we've named the object game so and yeah so basically we've got now now now we can work with something and and whenever we want to sort of call this display we use the keyword game cuz that's what we've wrote you could call this the churner you could call this you could call this whatever you want okay it doesn't matter we're just going to call a game just so that it's easy for us to know um next thing we want to do is we want to create a jframe now a jframe is um it's like a frame it's like a window but in Java it's called a jframe um and we need to import it as well it did it automatically I don't know I don't even know how that works sometimes it Imports stuff automatically sometimes it doesn't whatever okay so now we've got a frame um first thing we need to do in order to create the frame is let's go frame dot actually no frame do add game so we're adding this into our game um this isn't actually needed for now but we'll we'll work on that later um frame dot set resizable to false we don't want to be able to resize it um notice I'm using the word frame that's cuz we we've set frame over here if I again call this The Cho then I'd have to you know change all this into the Cho and that would still work of course but I'm just going to leave it as frame frame dot what else do we want set visible we want it to be visible true um we want to set a size to it that's for sure and the size will be width height okay what are you erroring me oh yeah um public static final int um public is like the the the view thing so it it's sort of it's It's specifying who's going to be able to view that number view that integer static means it's a constant you it's it's not going to change final means that it can't be changed either um because we don't want our size to change at any point at least for now um and yeah that that should be let's just hit okay you want to hit this debug button up the top and that will debug your code that will show your code okay awesome wonderful we've got a frame uh at only 10 minutes while I'm running overtime it doesn't matter we'll keep going um so we've got a nice frame here um yeah okay we need to add some code right now called frame dot set default close operation to jframe do exit on close uh this is really this is really important because basically um what's going to happen is I'll show you guys if we try and change the width and height by the way it's just going to I okay it's not going to do it in this case but um it's not going to let just debug this it's still running as you can see it's hasn't been terminated yet so you need to manually terminate it in that case um which is not good because basically what what we want to do is every time we hit that close button we want it to terminate itself and the best way to check this is if we just simply print system dot print line system do out. print line um what are you doing print line and we can print you running then um if we hit debug then you'll say that it says running and when we close this it's not it's not going to be terminated we'll have to manually terminate it but if we add this code in that's a comment by the way double for slash if you guys don't get anything just really don't hesitate to to leave a comment or ask me um what's up but seriously look look look at the look at the New Boston tutorials if you don't understand this it's they're very good um yeah so we'll yeah and now you'll see that if we hit the exit button it's going to terminate for us which is wonderful other thing that bugs me at the moment um is the location relative to null that'll actually make it in the center of our screen okay sometimes you got to put the oh one more thing we have to do is pack the frame okay don't worry about this it's supposed to be in the middle sometimes you got to put it under something I don't know it's soy there we go um one more thing we'll do before we finish this video is we'll create a title um and we'll so create a default serial version ID don't worry about that that's a Java thing um so let's go public static final string this time so string is a a bunch of characters it's like a sentence or a word whatever and we'll call this uh title we'll call this we we'll call the string title and we'll call it I don't know mine front pre pre-alpha 0.01 whatever just make it sound cool um and of course we need to go frame do set title and title and there we go if we hit debug you'll see that we have MFR pre-alpha 0.01 on the screen um okay and yeah that's pretty much it um uh yeah so that's been the first tutorial um if you guys don't understand anything let me know in the comments and if you if you want more like the video um add it to your favorites do whatever do whatever you want um and yeah so next time we're going to we're going to look at the at the main game Loop and basically we're going to just move on and continue making this game from scratch so I'll see you guys later bye [Music]
Original Description
Road to 3D Game? :D
Welcome to the first video of a series where we will create a 3D game (probably a first person shooter) from scratch, using just the included libraries in Java 1.6. If you have any questions or problems, leave a comment or send me a message, or tweet at me.
Tell me if you want more!
BEST laptop for programming! ► http://geni.us/pakTES
My FAVOURITE keyboard for programming! ► http://geni.us/zNhB
FAVOURITE monitors for programming! ► http://geni.us/Ig6KBq
FAVOURITE programming book! ► http://geni.us/z4Yx
Twitter: http://twitter.com/#!/thecherno
Livestream: http://www.twitch.tv/thecherno
Links:
thenewboston Java Programming Tutorials playlist: http://www.youtube.com/playlist?list=PLFE2CE09D83EE3E28
Eclipse: http://www.eclipse.org/downloads/ (Java IDE for Java Developers).
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from The Cherno · The Cherno · 1 of 60
← Previous
Next →
▶
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: AI Pair Programming
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
How to prepare TIC teacher exams in Spain with AI (oposiciones 2026)
Dev.to AI
Why I built a simple AI provider wrapper (and you might too)
Dev.to · zhongqiyue
This ChatGPT Prompt Replaced 3 Hours of PowerPoint Work
Medium · AI
This ChatGPT Prompt Replaced 3 Hours of PowerPoint Work
Medium · ChatGPT
🎓
Tutor Explanation
DeepCamp AI