Starting with LWJGL

Started by ViNi, December 06, 2005, 04:46:13

Previous topic - Next topic

ViNi

Where can I find a tutorial to start programming with LWJGL? I'm new to Java game programming, my past experiencies was only the code in "Killer Game Programming in Java" and "Developing Games in Java" books.

I wanna start coding simple 2D platform games, like Super Mario Bros and Megaman, or shooters like Space Invaders and others.

:)

Matzon

there is a space invaders tutorial:
http://www.cokeandcode.com/info/tut2d.html

though it does java2d, jogl and lwjgl

gimbal

I've been hacking around with LWJGL ( = OpenGL ) + 2d for quite some time now. There aren't any good indepth resources available (that space invaders thing is a nice start and there is an example program in the source distribution of LWJGL). What you'll be looking at and you need to search for using google:

- how to code OpenGL. Do NOT start with LWJGL when you don't know basic OpenGL yet, it'll give you more head aches then when running through the nehe tutorials with a C++ compiler.

- creating spritemaps as textures (so multiple sprites can share the same texture). You'll need to calculate the correct texture coordinates based on the  X,Y position within the texture, remembering that the LOWER left corner is the origin, not the top left. I could not find any proper resources on how to do this, I did it all on my own (and damned proud of it).

- orthographic projection mode

- creating quads the size of your sprite using glDrawArrays() with an IntBuffer (or glVertex2i(), if you don't know buffers yet)

- alpha testing to make your sprites transparent

- animation frame timing (how fast to display each new frame of your sprite)

- movement speed timing (how to update the movement of your sprites so that they move at the same speed on all systems)

If you can manage all that, you are well on your way to creating 2d games with LWJGL. It's not easy, but it's doable and ultimately much easier than creating 3d games.