I would like to create a 2d game in Java, but tutorials online for game libraries such as LWJGL are usually filled with errors once I compile the project. Most people do not explain very well, and just go on very quickly. Can someone please provide me a couple examples with source code, and somewhere to have a starting point? I used to have trouble with making a GUI and you guys helped me through, hopefully you can do the same again!
|
closed as off topic by Byte56, Noctrine♦ Jul 18 '12 at 22:43
Questions on Game Development Stack Exchange are expected to relate to game development within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.
|
A very simple and effective method to write small software rendered games is to use the methods and tools swing offers. Begin a new Swing project and add a single component to the window. That is the component everything is being rendered into. It might look like this:
What it does is rendering a single How about an example how to render a simple Sprite to the screen? First of all create a Sprite class:
The
Throw in a game loop that has a fixed timestep and there you go: a basic game in no time! |
|||
|
|
|
I would suggest using Slick 2d (Slick is built on top of the lwjgl, so you have a great community you can turn to with problems). I just did a little game with it and it worked just fine. It's really easy to grasp and provides all the groundwork, e. g., you don't have to worry about buffers and such. Just define your graphics (images) and draw them. Furthermore, Slick provides states so you can really easy develop the single parts of your game indepent from one another (main menu, options, gameplay and so on). The states themselves provide you with two alternating methods, update() and render(), so you can divide your code effectively:
Slick also handles all input, it even has support for controllers. On the page, there are several good tutorials for beginners, explaining how a simple game could look. |
||||
|
|
|
I think starting with an existing simple game, then adding to it or changing it is a good route to take. So, find a 2D opensource game to start with as a base. Perhaps you can find one that suits you on one of the game jam sites like ludum dare? I know they usually post their code for people to look at when they're done. This also makes sure that everything is included so you don't have issues with all those compile errors you were talking about. |
|||||
|
