From 7fc15f650c1d7f90deccba0e62a544f8d355704b Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Tue, 4 Jun 2013 17:02:42 +0100 Subject: [PATCH] [Fix] Corrected small desciation on all sprites. --- src/opengl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/opengl.c b/src/opengl.c index a89d2e9..fafe87d 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -318,7 +318,16 @@ int gl_isTrans(const glTexture* t, const int x, const int y) { void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir) { int s, sx, sy; - s = (int)(dir / (2.0*M_PI / (t->sy*t->sx))); + double shard, rdir; + + // What each image represents in angle. + shard = 2.0*M_PI / (t->sy*t->sx); + + rdir = dir + shard/2.; + if(rdir < 0.) rdir = 0.; + + // Now calculate the sprite we need. + s = (int)(rdir / shard); sx = t->sx; sy = t->sy;