Skip to content
Snippets Groups Projects
Commit 53428f0a authored by dg's avatar dg
Browse files

Fixed random black screen bug

git-svn-id: http://svn.net-core.org/repos/t-engine4@4104 51575b47-30f0-44d4-a5cc-537603b46e54
parent 89f7ba80
No related branches found
No related tags found
No related merge requests found
......@@ -212,7 +212,8 @@ function _M:defineDisplayCallback()
for i = 1, #ps do
e = ps[i]
e:checkDisplay()
if e.ps:isAlive() then e.ps:toScreen(x + w / 2, y + h / 2, true, w / game.level.map.tile_w)
if e.ps:isAlive() then
e.ps:toScreen(x + w / 2, y + h / 2, true, w / game.level.map.tile_w)
else
end
end
......
......@@ -1014,6 +1014,7 @@ function _M:displayParticles(nb_keyframes)
local alive
local del = {}
local e = next(self.particles)
local dx, dy = self.display_x, self.display_y
while e do
if e.ps then
adx, ady = 0, 0
......@@ -1030,14 +1031,14 @@ function _M:displayParticles(nb_keyframes)
if nb_keyframes == 0 and e.x and e.y then
-- Just display it, not updating, no emitting
if e.x + e.radius >= self.mx and e.x - e.radius < self.mx + self.viewport.mwidth and e.y + e.radius >= self.my and e.y - e.radius < self.my + self.viewport.mheight then
e.ps:toScreen(self.display_x + (adx + e.x - self.mx + 0.5) * self.tile_w * self.zoom, self.display_y + (ady + e.y - self.my + 0.5) * self.tile_h * self.zoom, self.seens(e.x, e.y) or e.always_seen, e.zoom * self.zoom)
e.ps:toScreen(dx + (adx + e.x - self.mx + 0.5) * self.tile_w * self.zoom, dy + (ady + e.y - self.my + 0.5) * self.tile_h * self.zoom, self.seens(e.x, e.y) or e.always_seen, e.zoom * self.zoom)
end
elseif e.x and e.y then
alive = e.ps:isAlive()
-- Update more, if needed
if alive and e.x + e.radius >= self.mx and e.x - e.radius < self.mx + self.viewport.mwidth and e.y + e.radius >= self.my and e.y - e.radius < self.my + self.viewport.mheight then
e.ps:toScreen(self.display_x + (adx + e.x - self.mx + 0.5) * self.tile_w * self.zoom, self.display_y + (ady + e.y - self.my + 0.5) * self.tile_h * self.zoom, self.seens(e.x, e.y) or e.always_seen)
e.ps:toScreen(dx + (adx + e.x - self.mx + 0.5) * self.tile_w * self.zoom, dy + (ady + e.y - self.my + 0.5) * self.tile_h * self.zoom, self.seens(e.x, e.y) or e.always_seen)
end
if not alive then
......
......@@ -276,11 +276,13 @@ static int map_object_get_move_anim(lua_State *L)
if (!obj->move_max || obj->display_last == DL_NONE)
{
// printf("==== GET %f x %f\n", mapdx, mapdy);
lua_pushnumber(L, mapdx);
lua_pushnumber(L, mapdy);
}
else
{
// printf("==== GET %f x %f :: %f x %f\n", mapdx, mapdy,obj->animdx,obj->animdy);
lua_pushnumber(L, mapdx + obj->animdx);
lua_pushnumber(L, mapdy + obj->animdy);
}
......@@ -1195,6 +1197,7 @@ void display_map_quad(GLuint *cur_tex, int *vert_idx, int *col_idx, map_type *ma
// Final step
animdx = adx * m->move_step / (float)m->move_max - adx;
animdy = ady * m->move_step / (float)m->move_max - ady;
// printf("==computing %f x %f : %f x %f // %d/%d\n", animdx, animdy, adx, ady, m->move_step, m->move_max);
}
}
......
......@@ -162,15 +162,21 @@ static int particles_to_screen(lua_State *L)
GLfloat *colors = ps->colors;
GLshort *texcoords = ps->texcoords;
SDL_mutexP(ps->lock);
if (x < -10000) x = -10000;
if (x > 10000) x = 10000;
if (y < -10000) y = -10000;
if (y > 10000) y = 10000;
// No texture? abord
if (!ps->texture) return 0;
SDL_mutexP(ps->lock);
glBindTexture(GL_TEXTURE_2D, ps->texture);
glTexCoordPointer(2, GL_SHORT, 0, texcoords);
glColorPointer(4, GL_FLOAT, 0, colors);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTranslatef(x, y, 0);
glPushMatrix();
glScalef(ps->zoom * zoom, ps->zoom * zoom, ps->zoom * zoom);
......@@ -184,12 +190,12 @@ static int particles_to_screen(lua_State *L)
}
if (remaining) glDrawArrays(GL_QUADS, 0, remaining);
SDL_mutexV(ps->lock);
glRotatef(-ps->rotate, 0, 0, 1);
glPopMatrix();
glTranslatef(-x, -y, 0);
SDL_mutexV(ps->lock);
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment