Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32306/src
Modified Files:
player.cpp player.h
Log Message:
Added more animations.
Didn't manage to put idle one working.
Index: player.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- player.cpp 17 Aug 2004 21:54:21 -0000 1.152
+++ player.cpp 17 Aug 2004 23:06:27 -0000 1.153
@@ -43,6 +43,9 @@
// others stuff:
#define AUTOSCROLL_DEAD_INTERVAL 300
+// time before idle animation starts
+#define IDLE_TIME 2500
+
// growing animation
Surface* growingtux_left[GROWING_FRAMES];
Surface* growingtux_right[GROWING_FRAMES];
@@ -92,6 +95,15 @@
}
void
+TuxBodyParts::start_animation(int loops, std::string next_action)
+{
+head->start_animation(loops, next_action);
+body->start_animation(loops, next_action);
+arms->start_animation(loops, next_action);
+feet->start_animation(loops, next_action);
+}
+
+void
TuxBodyParts::draw(DrawingContext& context, const Vector& pos, int layer,
Uint32 drawing_effect)
{
@@ -148,6 +160,7 @@
kick_timer.init(true);
shooting_timer.init(true);
growing_timer.init(true);
+ idle_timer.init(true);
physic.reset();
}
@@ -155,6 +168,8 @@
int
Player::key_event(SDLKey key, int state)
{
+ idle_timer.start(IDLE_TIME);
+
if(key == keymap.right)
{
input.right = state;
@@ -220,6 +235,7 @@
safe_timer.init(true);
frame_timer.init(true);
growing_timer.init(true);
+ idle_timer.init(true);
physic.reset();
}
@@ -718,7 +734,7 @@
int layer = LAYER_OBJECTS - 1;
Vector pos = Vector(base.x, base.y);
- if ((!safe_timer.started() || growing_timer.started()) || (global_frame_counter % 2) == 0)
+ if ((!safe_timer.started() || growing_timer.started()) && (global_frame_counter % 2))
{
if (dying == DYING_SQUISHED)
{
@@ -771,6 +787,13 @@
else
tux_body->set_action("kick-left");
}
+ else if (butt_jump)
+ {
+ if (dir == RIGHT)
+ tux_body->set_action("buttjump-right");
+ else
+ tux_body->set_action("buttjump-left");
+ }
else if (physic.get_velocity_y() != 0)
{
if (dir == RIGHT)
@@ -797,7 +820,22 @@
}
}
}
-
+/*
+ if(idle_timer.get_left() < 0)
+ {
+ if (dir == RIGHT)
+ {
+ tux_body->set_action("idle-right");
+ tux_body->start_animation(1, "stand-right");
+ }
+ else
+ {
+ tux_body->set_action("idle-left");
+ tux_body->start_animation(1, "stand-left");
+ }
+ idle_timer.start(IDLE_TIME);
+ }
+*/
// Tux is holding something
if ((holding_something && physic.get_velocity_y() == 0) ||
shooting_timer.check() && !duck)
Index: player.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/player.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- player.h 17 Aug 2004 21:54:22 -0000 1.81
+++ player.h 17 Aug 2004 23:06:27 -0000 1.82
@@ -110,6 +110,7 @@
~TuxBodyParts() { };
void set_action(std::string action);
+ void start_animation(int loops, std::string next_action = "");
void draw(DrawingContext& context, const Vector& pos, int layer,
Uint32 drawing_effect = NONE_EFFECT);
@@ -160,6 +161,7 @@
Timer shooting_timer; // used to show the arm when Tux is shooting
Timer dying_timer;
Timer growing_timer;
+ Timer idle_timer;
Physic physic;
public:
|