How to make a Video Game in Java (2D Basics)
Learn Code By Gaming Learn Code By Gaming
28.4K subscribers
26,240 views
0

 Published On Feb 4, 2021

This project will get you making your first game in Java! Take my starter code (I explain how it works) and build your own game! Whether your a beginner or intermediate programmer, I layout some ideas for you on what to build next to progress your skills. This is a great project for all Java students, and might even look good on that portfolio for your resume. Have fun developing your first video game!

🚀🚀🚀 Download the project code from GitHub 🚀🚀🚀: https://github.com/learncodebygaming/...

Need help getting set up for Java development?    • How To Get Started with Java Developm...  
Missed the Joy of Coding 2D Graphics project?    • The Joy of Coding  

1:50 Starter code overview
12:04 Game demonstration
12:50 Beginner project ideas
13:52 Intermediate project ideas
16:02 Advanced project ideas
19:08 Expert level ideas and what to do next

Full written tutorial: https://learncodebygaming.com/blog/ho...

What's up guys? Today I wanna show you how to make a video game in Java. If you're in that beginner-to-intermediate range of learning how to program, and you're looking for a project that isn't super boring, you're in the right place. Or even if you need a project to add to your resume: this is something that's really visual, that can be really impressive looking.

This is an active tutorial. I've designed this project specifically for you to write your own code, and to make a video game that's all your own.

We'll be making a 2D game, using the Java Swing library, and this project builds off of the work we did in the Bob Ross "Joy of Coding" video. So if you get really confused as I start to go through this, or if you need some more practice with 2D graphics, then you should go back and do that project first. And that should give you everything you need to be ready for this one.

My idea for this project was: there's certain things in developing a game that are just kinda difficult, but they're unavoidable. And I don't want to overwhelm you with things you might not be ready for yet, that maybe are acting as a barrier to you having fun with code. So I thought I'd start you off with like a template project. Just a real simple game that gets you passed some of those initial hurdles, so you can get to the fun parts.

Now I'm not going to do a full code-along this time, but I want to get you familiar with the codebase you'll be working with. So what I think we'll do is: in the first half of this video I want to show you how I built up this code, So that you can feel comfortable with it even if you don't understand what every line does.

Then in the second half I want to give you a bunch of ideas and direction for different ways you can build out your game. Sort of like little homework projects that can all add up to a game that's uniquely yours. And I'm going to be breaking down those ideas from easiest to hardest, so you can properly progress your skills as you work on your game.

So if you're ready, the first thing you'll want to do is: download this project off of Github, run it once to make sure it's working, and then come back here and we'll talk through the code. You can either clone it, if you're familiar with Git, or you can just download the .ZIP file.

Now let's talk about some of the things you can do with this starter code, to build out your own game. You're not meant to do all of these. Just pick and choose things you like or want to try. And if you have any ideas that aren't on these lists, definitely just go for it.

BEGINNER
Change the colors that are being used.
Change the image files that are being used.
Change how many points you get per coin.
Make instance or class variables to control hardcoded values like the ones just mentioned.
Use WASD instead of arrows for movement.
Change the dimensions of the game board.
Make a new coin appear whenever the player picks one up.
Change the tile size. Remember to update your image files, or scale the images.

INTERMEDIATE
Make coins disappear after some time. By ticks, or using a separate timer, or after the player has moved so many squares.
Make more coins appear at random intervals.
Replace the checkered background with an image.
Player and Coin share a lot of commonalities. Create a parent class that both of these classes extend from to reduce code duplication.
Make a special coin that looks different and is worth more points.
End or restart the game when all coins are collected, or when a certain score is reached.
Decide what winning means, then redraw the whole canvas with a celebration graphic when you win the game.
Add a game clock.
Keep track of high scores. In a single play session, or across all sessions by reading/writing to a file.
Allow the player to wrap around the edges of the board.

Continue with the written guide here: https://learncodebygaming.com/blog/ho...

#programming #java 💎🙌

show more

Share/Embed