I have been re-writing my game engine and wanted to move away from the problem I'm having now.
I have a class that takes care of my animations per texture/tileSet
C# tile class snippet...
Code: Select all
/*
X = _x;
Y = _y;
_sizeX = size of tile in set width
_sizeY = size of tile in set height
_width = full tileSet width
_height = full tileSet Height
*/
public void e2Tile(float x, float y)
{
float tx = (x * _sizeX) / _width;
float ty = (y * _sizeY) / _height;
X = tx;
Y = ty;
Width = _sizeX / _width;
Height = _sizeY / _height;
_frames = new List<float[]>();
_frames.Add(new float[] { X, Y });
}
public void Update()
{
if (_frames.Count <= 1)
return;
FMR++;
if (FMR >= (1000 / FPS))
{
_frame++;
FMR = 0;
}
_frame = _frame % _frames.Count;
_x = _frames[_currentFrame][0];
_y = _frames[_currentFrame][1];
}
Code: Select all
GL.Enable(EnableCap.Texture2D);
GL.BindTexture(TextureTarget.Texture2D, textureID);
GL.Begin(BeginMode.Quads);
GL.TexCoord2(tile.X, tile.Y + tile.Height); GL.Vertex2(-1.0f, -1.0f);
GL.TexCoord2(tile.X + tile.Width, tile.Y + tile.Height); GL.Vertex2(1.0f, -1.0f);
GL.TexCoord2(tile.X + tile.Width, tile.Y); GL.Vertex2(1.0f, 1.0f);
GL.TexCoord2(tile.X, tile.Y); GL.Vertex2(-1.0f, 1.0f);
GL.End();
but I'm at the point of character animations (sprint,swim,run)
and would like to run them at a smooth 30-60fps
But when i run a 4 frame animation like this it skews when changing frames like motion blur on a projectors film strip.
My first guess was it being a float problem and trying to catch up with the data but really dunno how to confirm or compare that lol :1
Then i thought it was a problem with TK so i wrote a different animation system instead pretty much a standard for gl texture animations,
and instead of one texture its per texture so (CharAnim1.png, CharAnim2.png etc..)
Code: Select all
GL.Enable(EnableCap.Texture2D);
GL.BindTexture(TextureTarget.Texture2D, textures[tile._frame]);
GL.Begin(BeginMode.Quads);
GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-1.0f, -1.0f);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(1.0f, -1.0f);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(1.0f, 1.0f);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-1.0f, 1.0f);
GL.End();
but wouldn't THAT be way more data? i mean im loading 4000 textures here
i don't like this way at all it seams inefficient and tedious i would rather have just 1 tileSet and load frames by my old version.
i mean if i wrote a decent game with alot of item graphics i would have to split them all into seperate files
and then track them all in a jumble of code and i know this is how alot of older games do this, but :I is that really the only possible way? is there no in between?
thanks for reading :]