[Super-tux-commit] supertux/lib/special sprite.h,1.15,1.16 sprite.cpp,1.27,1.28
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-10-19 17:48:33
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6048/lib/special Modified Files: sprite.h sprite.cpp Log Message: Mirror actions now cache the horizontal flipped Surfaces, rather than flipping them during blitting. It wastes more memory, but the problem is that SDL fontend got considered slower, especially when a vertical flipping was done at the same time (ie. Bad Guy falling facing right). Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- sprite.cpp 18 Oct 2004 21:09:26 -0000 1.27 +++ sprite.cpp 19 Oct 2004 17:48:23 -0000 1.28 @@ -56,7 +56,6 @@ for(std::vector<Surface*>::iterator i_sur = i_act->second->surfaces.begin(); i_sur != i_act->second->surfaces.end(); ++i_sur) { - if(!i_act->second->mirror) delete *i_sur; } delete i_act->second; @@ -86,26 +85,30 @@ for(std::vector<Surface*>::iterator i = action->surfaces.begin(); i < action->surfaces.end(); i++) { - (*i)->apply_mask(Color(mask_color)); + (*i)->apply_filter(MASK_FILTER, Color(mask_color)); } } - action->mirror = false; std::string mirror_action; lispreader.read_string("mirror-action", mirror_action); if(!mirror_action.empty()) { - action->mirror = true; Action* act_tmp = get_action(mirror_action); if(act_tmp == NULL) std::cerr << "Warning: Could not mirror action. Action not found\n" "Mirror actions must be defined after the real one!\n"; else - action->surfaces = act_tmp->surfaces; + { + for(int i = 0; i < act_tmp->surfaces.size(); i++) + { + Surface* surface = new Surface(sdl_surface_from_sdl_surface( + act_tmp->surfaces[i]->impl->get_sdl_surface(), true), true); + surface->apply_filter(HORIZONTAL_FLIP_FILTER); + action->surfaces.push_back(surface); + } + } } - - // Load images - if(!action->mirror) + else // Load images { std::vector<std::string> images; if(!lispreader.read_string_vector("images", images)) @@ -270,8 +273,7 @@ << "/" << get_action_name() << std::endl; else context.draw_surface(action->surfaces[(int)frame], - pos - Vector(action->x_offset, action->y_offset), layer + action->z_order, - action->mirror ? drawing_effect | HORIZONTAL_FLIP : drawing_effect); + pos - Vector(action->x_offset, action->y_offset), layer + action->z_order, drawing_effect); } void @@ -286,8 +288,7 @@ << "/" << get_action_name() << std::endl; else context.draw_surface_part(action->surfaces[(int)frame], source, size, - pos - Vector(action->x_offset, action->y_offset), layer + action->z_order, - action->mirror ? drawing_effect | HORIZONTAL_FLIP : drawing_effect); + pos - Vector(action->x_offset, action->y_offset), layer + action->z_order, drawing_effect); } int Index: sprite.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- sprite.h 9 Sep 2004 10:00:00 -0000 1.15 +++ sprite.h 19 Oct 2004 17:48:22 -0000 1.16 @@ -50,7 +50,7 @@ /** Mirror is used to avoid duplicating left and right side sprites */ - bool mirror; +// bool mirror; std::vector<Surface*> surfaces; }; |