LWJGL and OpenGL for 2D sprite based games

Started by Warlax, April 03, 2007, 17:50:15

Previous topic - Next topic

Warlax

Hi everyone.

I need some guidance about what would be the easiest way of implementing an Avatar class...

I am looking into building a small convenient engine for developing 2D sprite/tile based games.
I want to use OpenGL to maybe encapsulate an "Avatar" class.

*Please excuse my ignorance of OpenGL mechanics in my explanation below, as I am only a beginner looking to start using OpenGL

- Each Entity in the world, will have an Avatar bound to it.
- The avatar is purely a graphical expression of the Entity, meaning: all mechanical data (location, state, health and so on...) is encapsulated in the Entity class, while only the graphical representation is held in the Avatar.
- Avatar should include a texture (loaded from file) and what I believe you guys call a Quad...


What would be the best way to load and display simple textures from a spritesheet file?
The way my graphics are stored on file is that for every Entity type, there is one bitmap that includes all the gfx, it is divided into equal cells in height and width and I would like to just display a certain "cell" in the spritesheet for each frame of animation... I have already implemented this using Swing... I load the sheet, split it into a bunch of smaller BufferedImage-s each holding only one "frame" and then I load a script file that describes in what order should each frame be displayed in order to create animations. This works perfectly, all i need to do next is assign my avatar with the correct animation and voila!

Probs:
1. How to load "frame cells" from a spritesheet and turn them to textures for openGL to use???
2. How is a texture encapsulated in openGL anyways?
3. Once having a texture at hand... what is the fastest way to have it displayed?
4. Could I display that texture in any angle? (e.g. rotated)
* this is 2D not 3D

Thank you so much.

bobjob


if you wanna be able to do it yourself and understand the programming, i recommened using the Nehe tutorials, you will only need to do lessons 1 - 6
http://nehe.gamedev.net/
at the bottom of every lesson page there is a link labelled lwjgl for the java source files

even though it is basic its alot of information to explain over a forum. so if you have any trouble with the tutorials i'd be more than happy to help