[Super-tux-commit] supertux/lib/special sprite.cpp,1.19,1.20 sprite.h,1.13,1.14
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-08-27 11:20:36
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9072/lib/special Modified Files: sprite.cpp sprite.h Log Message: Added z order support and draw_part(). Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- sprite.cpp 21 Aug 2004 13:09:52 -0000 1.19 +++ sprite.cpp 27 Aug 2004 11:20:27 -0000 1.20 @@ -72,6 +72,7 @@ Termination::abort("Error: If there are more than one action, they need names!", ""); lispreader.read_int("x-offset", action->x_offset); lispreader.read_int("y-offset", action->y_offset); + lispreader.read_int("z-order", action->z_order); lispreader.read_float("fps", action->fps); std::vector<std::string> images; @@ -92,6 +93,7 @@ { act->x_offset = 0; act->y_offset = 0; + act->z_order = 0; act->fps = 10; start_animation(-1); @@ -215,20 +217,25 @@ << "/" << get_action_name() << std::endl; else context.draw_surface(action->surfaces[(int)frame], - pos - Vector(action->x_offset, action->y_offset), layer, drawing_effect); + pos - Vector(action->x_offset, action->y_offset), layer + action->z_order, + drawing_effect); } -#if 0 void -Sprite::draw_part(float sx, float sy, float x, float y, float w, float h) +Sprite::draw_part(DrawingContext& context, const Vector& source, const Vector& size, + const Vector& pos, int layer, Uint32 drawing_effect) { - time = SDL_GetTicks(); - unsigned int frame = get_current_frame(); + update(); - if (frame < surfaces.size()) - surfaces[frame]->draw_part(sx, sy, x - x_offset, y - y_offset, w, h); + if((int)frame >= get_frames() || (int)frame < 0) + std::cerr << "Warning: frame out of range: " << (int)frame + << "/" << get_frames() << " at sprite: " << get_name() + << "/" << 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, + drawing_effect); } -#endif int Sprite::get_width() Index: sprite.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- sprite.h 21 Aug 2004 13:09:52 -0000 1.13 +++ sprite.h 27 Aug 2004 11:20:27 -0000 1.14 @@ -39,8 +39,11 @@ { std::string name; + /** Position correction */ int x_offset; int y_offset; + /** Drawing priority in queue */ + int z_order; /** Frames per second */ float fps; @@ -58,6 +61,10 @@ void draw(DrawingContext& context, const Vector& pos, int layer, Uint32 drawing_effect = NONE_EFFECT); + void draw_part(DrawingContext& context, const Vector& source, + const Vector& size, const Vector& pos, int layer, + Uint32 drawing_effect = NONE_EFFECT); + /** Set action (or state) */ void set_action(std::string act); |