Re: [Super-tux-commit] supertux/src door.cpp,1.2,1.3 door.h,1.2,1.3
Brought to you by:
wkendrick
From: Ricardo C. <ri...@ae...> - 2004-06-10 18:24:13
|
That's because Sprite doesn't honor frame order. We can either implement it the same way as Tux grows, or implement frames order in Sprite. Ricardo Cruz Em Quinta, 10 de Junho de 2004 17:03, o Marek Moeckel escreveu: > Update of /cvsroot/super-tux/supertux/src > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4835/src > > Modified Files: > door.cpp door.h > Log Message: > Door animation implemented - doors now open when activated > It still has bugs and it's coded rather dirty. Someone please have a look > at it - see door.cpp for details. > > > Index: door.cpp > =================================================================== > RCS file: /cvsroot/super-tux/supertux/src/door.cpp,v > retrieving revision 1.2 > retrieving revision 1.3 > diff -u -d -r1.2 -r1.3 > --- door.cpp 9 Jun 2004 05:23:19 -0000 1.2 > +++ door.cpp 10 Jun 2004 16:03:17 -0000 1.3 > @@ -37,6 +37,8 @@ > reader.read_string("spawnpoint", target_spawnpoint); > > sprite = sprite_manager->load("door"); > + animation_timer.init(true); > + door_activated = false; > } > > void > @@ -68,13 +70,27 @@ > Door::draw(DrawingContext& context) > { > sprite->draw(context, Vector(area.x, area.y), LAYER_TILES); > + > + //Check if door animation is complete > + //TODO: Move this out of the "draw" method as this is extremely dirty :) > + if ((!animation_timer.check()) && (door_activated)) { > + door_activated = false; > + sprite = sprite_manager->load("door"); > + GameSession::current()->respawn(target_sector, target_spawnpoint); > + } > } > > void > Door::interaction(InteractionType type) > { > + //Animate the door on activation > + //TODO: Resetting the animation doesn't work correctly > + // Tux and badguys should stop moving while the door is opening > if(type == INTERACTION_ACTIVATE) { > - GameSession::current()->respawn(target_sector, target_spawnpoint); > + sprite = sprite_manager->load("openingdoor"); > + sprite->reset(); > + animation_timer.start(ANIM_TIME); > + door_activated = true; > } > } > > > Index: door.h > =================================================================== > RCS file: /cvsroot/super-tux/supertux/src/door.h,v > retrieving revision 1.2 > retrieving revision 1.3 > diff -u -d -r1.2 -r1.3 > --- door.h 9 Jun 2004 05:23:20 -0000 1.2 > +++ door.h 10 Jun 2004 16:03:17 -0000 1.3 > @@ -24,6 +24,9 @@ > > #include "interactive_object.h" > #include "serializable.h" > +#include "timer.h" > + > +#define ANIM_TIME 1500 > > class Sprite; > > @@ -45,6 +48,8 @@ > Sprite* sprite; > std::string target_sector; > std::string target_spawnpoint; > + Timer animation_timer; //Used for door animation > + bool door_activated; > }; > > #endif /*SUPERTUX_DOOR_H*/ > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the new InstallShield X. > From Windows to Linux, servers to mobile, InstallShield X is the > one installation-authoring solution that does it all. Learn more and > evaluate today! http://www.installshield.com/Dev2Dev/0504 > _______________________________________________ > Super-tux-commit mailing list > Sup...@li... > https://lists.sourceforge.net/lists/listinfo/super-tux-commit -- Life exists for no known purpose. |