Where to start to make a 2d game?
Hello Guys,
I want to develop a simple 2d action/exploration game in Java. I am thinking the theme will be mining. Where to start? What API should I learn? How much much work must really go into this, is it something that can I can do being a beginner/intermediate"ish" programmer? Please help, It will be much appreciated. :D
Re: Where to start to make a 2d game?
How familiar with Java are you already? Your first step is to familiarize yourself with the basics- program flow, methods, Objects, classes, instantiation, etc. Work through the basic tutorials, carefully, until you can write a game played on the command line.
From there, learn about Swing and painting in Java2D. Draw a simple scene on a JFrame- some rectangles and some circles.
Then worry about animation- make the rectangles and circles move around. Start working on things like collision detection and basic physics.
Then figure out user input, through the mouse or keyboard.
If you get stuck on any of these steps, create an SSCCE that demonstrates exactly what's going on, and we'll go from there. Much luck.
Re: Where to start to make a 2d game?
There is this little framework that can be used to play around and have fun. The overhead is some the simplest in any game framework I have seen.
JGame: a Java/Flash game engine for 2D games
This is a shortcut, and will as such not be nearly as educational as above mentioned, but will make you put stuff together fast. Coding should also be fun, even while we are beginners
Re: Where to start to make a 2d game?
I can agree that coding should be fun, but you should know the basics of what's going on before you devote yourself to any one framework. There are tons of different frameworks out there, and you have to know the basics before you can really choose between them. It's like learning how to drive before picking out a sports car.
Re: Where to start to make a 2d game?
Thanks so much! :)That is SO helpful. Especially the checklist. I know most of the basics, I will learn the things you mentioned I am not familiar with. As for Swing, I am already pretty sufficient in it, being able to make Frames, Panels, Buttons, Labels, TextBoxes etc. Ill also try to learn Java 2d, It looks pretty simple. Ill look into sprites, and collision detection/physics etc. I already understand some basic mouse Listeners, but my game will probably be mostly keyboard controlled, so I definitely will learn Keyboard input. And if I cant get these things to work together, :eek:l'll create an SSCCE.:)
Thanks you SOOOO much, a checklist like what you provided was exactly what I needed.
-Duster
Re: Where to start to make a 2d game?
No problem. And for what it's worth, I pretty much follow that guideline every time I create a new game from scratch. My workflow goes something like this:
1- Get a JFrame / JApplet running (I actually use a JPanel and put it in both).
2- Use Java2D to paint a single circle in the middle of that JPanel. How do I want to display things? Using a grid? By set coordinates?
3- Add a KeyListener and logic to get the circle moving based on input.
4- Add collision detection- what happens when the circle hits the edge of a screen? What happens when I add a square to it?
5- Add a Timer to handle the game loop. For more advanced stuff, some threading might be required, but a Timer should work for most simple games.
Once you have those things implemented, it's a pretty natural progression to add things to your game. I wouldn't worry too much about art until you have a functional game that contains dummy art.
Re: Where to start to make a 2d game?
Thanks for all the help :)
I am working on a text based game like you said.
I have a few questions though:
How do I set a boolean to true if something happens but have the default be false?
How Do I add 1 to an int everytime an if statement is activated? (ie. If it occurs set it to 1, if twice set it to 2 etc)
Thanks for all your help,
-Duster
Edit: Figured out both questions by myself.