r73 - in trunk/src: . objects

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Oct 5 13:30:34 EDT 2004


Author: jonas
Date: 2004-10-05 13:30:34 -0400 (Tue, 05 Oct 2004)
New Revision: 73

Added:
   trunk/src/objects/erik.cpp
   trunk/src/objects/erik.h
Removed:
   trunk/src/objects/eric.cpp
   trunk/src/objects/eric.h
Modified:
   trunk/src/objectpools.cpp
   trunk/src/objects/Makefile
   trunk/src/objects/baleog.cpp
   trunk/src/objects/fang.cpp
   trunk/src/objects/olaf.cpp
   trunk/src/objects/olaf.h
   trunk/src/objects/scorch.cpp
   trunk/src/players_common.cpp
   trunk/src/players_common.h
Log:
added run animations, renamed Eric to Erik ;)

Modified: trunk/src/objectpools.cpp
===================================================================
--- trunk/src/objectpools.cpp	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objectpools.cpp	2004-10-05 17:30:34 UTC (rev 73)
@@ -21,7 +21,7 @@
 #include "objects/triggered_bomb.h"
 #include "objects/plant.h"
 #include "objects/baleog.h"
-#include "objects/eric.h"
+#include "objects/erik.h"
 #include "objects/olaf.h"
 #include "objects/scorch.h"
 #include "objects/fang.h"
@@ -70,7 +70,7 @@
     else if (obj=="TriggeredBomb") return (addCharacter(new TriggeredBomb(image,x,y,atoi(arg1.c_str()),name)));
 
     //Players
-    else if (obj=="Eric")    return (addPlayer(new Eric(image,x,y,name)));
+    else if (obj=="Erik")    return (addPlayer(new Erik(image,x,y,name)));
     else if (obj=="Olaf")    return (addPlayer(new Olaf(image,x,y,name)));
     else if (obj=="Baleog")  return (addPlayer(new Baleog(image,x,y,name)));
     else if (obj=="Fang")    return (addPlayer(new Fang(image,x,y,name)));  

Modified: trunk/src/objects/Makefile
===================================================================
--- trunk/src/objects/Makefile	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/Makefile	2004-10-05 17:30:34 UTC (rev 73)
@@ -7,7 +7,7 @@
 SDL_LINK = `sdl-config --libs` -lSDL_mixer -lSDL_image -ldl -rdynamic
 AR = ar
 
-OBJS  = baleog.o bomb.o door.o eric.o exit.o fang.o geyser.o heart.o\
+OBJS  = baleog.o bomb.o door.o erik.o exit.o fang.o geyser.o heart.o\
         key.o olaf.o scorch.o teleport.o trigger.o triggered_bomb.o\
         wall.o water.o wind.o zombie.o plant.o spike.o
 PLUGS = ../objects.a

Modified: trunk/src/objects/baleog.cpp
===================================================================
--- trunk/src/objects/baleog.cpp	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/baleog.cpp	2004-10-05 17:30:34 UTC (rev 73)
@@ -11,6 +11,8 @@
   Player(imagename,xcord,ycord,pname) {
     im_left=new Animation(imgcache->loadImage("baleog_right.bmp"));
     im_right=im_left;
+    im_run_right=new Animation(imgcache->loadImage("baleog-run.png"),8,1000);
+    im_run_left=im_left;
     im_fall_left=im_left;
     im_fall_right=im_left;
     im_krit_left=im_left;
@@ -25,6 +27,7 @@
 
 Baleog::~Baleog() {
     delete im_left;
+    delete im_run_right;
     delete im_land_left;
     delete im_sword_left;
 }

Deleted: trunk/src/objects/eric.cpp
===================================================================
--- trunk/src/objects/eric.cpp	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/eric.cpp	2004-10-05 17:30:34 UTC (rev 73)
@@ -1,111 +0,0 @@
-#include "common.h"
-#include "events.h"
-#include "anim.h"
-#include "input.h"
-#include "map.h"
-#include "weapons.h"
-#include "imgcache.h"
-#include "sndcache.h"
-#include "sfxeng.h"
-#include "eric.h"
-
-
-Eric::Eric(string imagename, Sint16 xcord, Sint16 ycord, string pname):
-  Player(imagename,xcord,ycord,pname),
-  jump(V_JUMP),
-  jump2(V_JUMP2) {
-    weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE);
-    im_left=new Animation(imgcache->loadImage("eric_left.bmp"));
-    im_right=new Animation(60,imgcache->loadImage("kuru.bmp"),12,1000);
-    im_fall_left=im_left;
-    im_fall_right=im_right;
-    im_krit_left=im_left;
-    im_krit_right=im_right;
-    im_land_left=new Animation(imgcache->loadImage("olaf_land.bmp"),1,T_IRR,true);
-    im_land_right=im_land_left;
-    au_jump=sndcache->loadWAV("rboots.wav");
-    au_hit=sndcache->loadWAV("erikhit.wav");
-    au_run=NULL;
-}
-Eric::~Eric() {
-    delete im_left;
-    delete im_right;
-    delete im_land_left;
-}
-
-void Eric::in_sp1(Sint16 dt) {
-    //TODO: check STATE_WATER
-    if (dt < 0) return;
-    input->unsetState(INPUT_SP1);
-
-    if (state&STATE_FALL) setState(STATE_ACT_1);
-
-    if (state&STATE_ACT_2) {
-    } else if (state&STATE_ACT_1) {
-        setState(STATE_ACT_2);
-        setEvent(new ESpeed(this,DE_JUMP,jump2,0,0,0,au_jump));
-    } else {
-        setState(STATE_ACT_1);
-        setEvent(new ESpeed(this,DE_JUMP,jump));
-    }
-}
-
-void Eric::in_sp2(Sint16 dt) {
-    //TODO: check STATE_WATER
-    if (dt < 0) {
-        input->unsetState(INPUT_SP2);
-        dense_types&=~OTYPE_MONSTER;
-        if (state&STATE_RUN) cancelEvent();
-        return;
-    }
-    dense_types|=OTYPE_MONSTER;
-    if (state&STATE_RUN) {
-        if (state&STATE_FALL) cancelEvent();
-    } else if (state&STATE_MLEFT) {
-        sfxeng->playWAV(au_run);
-        setEvent(new ERun(this,10000,Sint16(-1/2*maxspeedx),-maxspeedx,500,ESTATE_ABORT,au_run));
-    } else if (state&STATE_MRIGHT) {
-        sfxeng->playWAV(au_run);
-        setEvent(new ERun(this,10000,Sint16(1/2*maxspeedx),maxspeedx,500,ESTATE_ABORT,au_run));
-    }
-}
-
-void Eric::in_left(Sint16 dt) {
-    if (dt < 0) {
-        //TODO: play decelerate animation (setEvent instead)
-        if (state&STATE_RUN) cancelEvent();
-    } else if (state&STATE_RUN) {
-        if (state&STATE_LEFT) event->reset();
-        //changed directions, TODO: play decelerate animation
-        else cancelEvent();
-    }
-    Player::in_left(dt);
-}
-
-void Eric::in_right(Sint16 dt) {
-    if (dt < 0) {
-        //TODO: play decelerate animation (setEvent instead)
-        if (state&STATE_RUN) cancelEvent();
-    } else if (state&STATE_RUN) {
-        if (!(state&STATE_LEFT)) event->reset();
-        //changed directions, TODO: play decelerate animation
-        else cancelEvent();
-    }
-    Player::in_right(dt);
-}
-
-void Eric::crash(Uint16 dir) {
-    if ((state&(STATE_PRESS_LR|STATE_ACT_2)) && (!(dir&DIR_DOWN))) {
-        std::set<Character *> targets=curmap->getCharactersIn(OTYPE_MONSTER,getCenter(),true,pos.w+1,dir);
-        ///\bug This might get the wrong target
-        if (!targets.empty()) (*targets.begin())->hit(dir,weapon);
-    }
-    Player::crash(dir);
-}
-
-Uint16 Eric::hit(Uint16 dir, Weapon& weap) {
-    if (weap.getType()==W_WATER) {
-        cancelEvent();
-        return health;
-    } else return Player::hit(dir,weap);
-}

Deleted: trunk/src/objects/eric.h
===================================================================
--- trunk/src/objects/eric.h	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/eric.h	2004-10-05 17:30:34 UTC (rev 73)
@@ -1,30 +0,0 @@
-#include "players_common.h"
-
-#define V_JUMP        -400
-#define V_JUMP2       -500
-#define DE_JUMP        200
-
-/** \brief Eric (Viking)
-
-    Act1: first jump\n
-    Act2: second jump
-    \todo Implement water (STATE_WATER)
-    \todo Add jump and run attacks
-*/
-class Eric : public Player {
-    public:
-        Eric(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Eric");
-        virtual ~Eric();
-        /// \brief Eric jumps
-        virtual void in_sp1(Sint16);
-        // \brief Eric runs
-        virtual void in_sp2(Sint16);
-        virtual void in_left(Sint16);
-        virtual void in_right(Sint16);
-        virtual void crash(Uint16 dir);
-        virtual Uint16 hit(Uint16 direction,Weapon& weap);
-    private:
-        Mix_Chunk* au_jump;
-        Mix_Chunk* au_run;
-        Sint16 jump,jump2;
-};

Copied: trunk/src/objects/erik.cpp (from rev 72, trunk/src/objects/eric.cpp)
===================================================================
--- trunk/src/objects/eric.cpp	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/erik.cpp	2004-10-05 17:30:34 UTC (rev 73)
@@ -0,0 +1,113 @@
+#include "common.h"
+#include "events.h"
+#include "anim.h"
+#include "input.h"
+#include "map.h"
+#include "weapons.h"
+#include "imgcache.h"
+#include "sndcache.h"
+#include "sfxeng.h"
+#include "erik.h"
+
+
+Erik::Erik(string imagename, Sint16 xcord, Sint16 ycord, string pname):
+  Player(imagename,xcord,ycord,pname),
+  jump(V_JUMP),
+  jump2(V_JUMP2) {
+    weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE);
+    im_left=new Animation(imgcache->loadImage("erik_left.bmp"));
+    im_right=new Animation(60,imgcache->loadImage("kuru.bmp"),12,1000);
+    im_run_right=im_right;
+    im_run_left=im_left;
+    im_fall_left=im_left;
+    im_fall_right=im_right;
+    im_krit_left=im_left;
+    im_krit_right=im_right;
+    im_land_left=new Animation(imgcache->loadImage("olaf_land.bmp"),1,T_IRR,true);
+    im_land_right=im_land_left;
+    au_jump=sndcache->loadWAV("rboots.wav");
+    au_hit=sndcache->loadWAV("erikhit.wav");
+    au_run=NULL;
+}
+Erik::~Erik() {
+    delete im_left;
+    delete im_right;
+    delete im_land_left;
+}
+
+void Erik::in_sp1(Sint16 dt) {
+    //TODO: check STATE_WATER
+    if (dt < 0) return;
+    input->unsetState(INPUT_SP1);
+
+    if (state&STATE_FALL) setState(STATE_ACT_1);
+
+    if (state&STATE_ACT_2) {
+    } else if (state&STATE_ACT_1) {
+        setState(STATE_ACT_2);
+        setEvent(new ESpeed(this,DE_JUMP,jump2,0,0,0,au_jump));
+    } else {
+        setState(STATE_ACT_1);
+        setEvent(new ESpeed(this,DE_JUMP,jump));
+    }
+}
+
+void Erik::in_sp2(Sint16 dt) {
+    //TODO: check STATE_WATER
+    if (dt < 0) {
+        input->unsetState(INPUT_SP2);
+        dense_types&=~OTYPE_MONSTER;
+        if (state&STATE_RUN) cancelEvent();
+        return;
+    }
+    dense_types|=OTYPE_MONSTER;
+    if (state&STATE_RUN) {
+        if (state&STATE_FALL) cancelEvent();
+    } else if (state&STATE_MLEFT) {
+        sfxeng->playWAV(au_run);
+        setEvent(new ERun(this,10000,Sint16(-1/2*maxspeedx),-maxspeedx,500,ESTATE_ABORT,au_run));
+    } else if (state&STATE_MRIGHT) {
+        sfxeng->playWAV(au_run);
+        setEvent(new ERun(this,10000,Sint16(1/2*maxspeedx),maxspeedx,500,ESTATE_ABORT,au_run));
+    }
+}
+
+void Erik::in_left(Sint16 dt) {
+    if (dt < 0) {
+        //TODO: play decelerate animation (setEvent instead)
+        if (state&STATE_RUN) cancelEvent();
+    } else if (state&STATE_RUN) {
+        if (state&STATE_LEFT) event->reset();
+        //changed directions, TODO: play decelerate animation
+        else cancelEvent();
+    }
+    Player::in_left(dt);
+}
+
+void Erik::in_right(Sint16 dt) {
+    if (dt < 0) {
+        //TODO: play decelerate animation (setEvent instead)
+        if (state&STATE_RUN) cancelEvent();
+    } else if (state&STATE_RUN) {
+        if (!(state&STATE_LEFT)) event->reset();
+        //changed directions, TODO: play decelerate animation
+        else cancelEvent();
+    }
+    Player::in_right(dt);
+}
+
+void Erik::crash(Uint16 dir) {
+    if ((state&(STATE_PRESS_LR|STATE_ACT_2)) && (!(dir&DIR_DOWN))) {
+        std::set<Character *> targets=curmap->getCharactersIn(OTYPE_MONSTER,getCenter(),true,pos.w+1,dir);
+        ///\bug This might get the wrong target
+        if (!targets.empty()) (*targets.begin())->hit(dir,weapon);
+    }
+    Player::crash(dir);
+}
+
+Uint16 Erik::hit(Uint16 dir, Weapon& weap) {
+    if (weap.getType()==W_WATER) {
+        cancelEvent();
+        return health;
+    } else return Player::hit(dir,weap);
+}

Copied: trunk/src/objects/erik.h (from rev 72, trunk/src/objects/eric.h)
===================================================================
--- trunk/src/objects/eric.h	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/erik.h	2004-10-05 17:30:34 UTC (rev 73)
@@ -0,0 +1,30 @@
+#include "players_common.h"
+
+#define V_JUMP        -400
+#define V_JUMP2       -500
+#define DE_JUMP        200
+
+/** \brief Erik (Viking)
+
+    Act1: first jump\n
+    Act2: second jump
+    \todo Implement water (STATE_WATER)
+    \todo Add jump and run attacks
+*/
+class Erik : public Player {
+    public:
+        Erik(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Erik");
+        virtual ~Erik();
+        /// \brief Erik jumps
+        virtual void in_sp1(Sint16);
+        // \brief Erik runs
+        virtual void in_sp2(Sint16);
+        virtual void in_left(Sint16);
+        virtual void in_right(Sint16);
+        virtual void crash(Uint16 dir);
+        virtual Uint16 hit(Uint16 direction,Weapon& weap);
+    private:
+        Mix_Chunk* au_jump;
+        Mix_Chunk* au_run;
+        Sint16 jump,jump2;
+};

Modified: trunk/src/objects/fang.cpp
===================================================================
--- trunk/src/objects/fang.cpp	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/fang.cpp	2004-10-05 17:30:34 UTC (rev 73)
@@ -13,6 +13,8 @@
     weapon=Weapon(-1,W_STRIKE);
     im_left=new Animation(imgcache->loadImage("olaf_left.bmp"));
     im_right=new Animation(imgcache->loadImage("olaf_right.bmp"));
+    im_run_right=im_right;
+    im_run_left=im_left;
     im_fall_left=im_left;
     im_fall_right=im_right;
     im_krit_left=im_left;

Modified: trunk/src/objects/olaf.cpp
===================================================================
--- trunk/src/objects/olaf.cpp	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/olaf.cpp	2004-10-05 17:30:34 UTC (rev 73)
@@ -13,6 +13,8 @@
   fart(V_FART) {
     im_left=new Animation(imgcache->loadImage("olaf_left.bmp"));
     im_right=new Animation(imgcache->loadImage("olaf_right.bmp"));
+    im_run_right=new Animation(imgcache->loadImage("olaf-run.png"),8,1000);
+    im_run_left=im_left;
     im_fall_left=im_left;
     im_fall_right=im_right;
     im_krit_left=im_left;
@@ -22,8 +24,12 @@
 
     im_small_left=new Animation(imgcache->loadImage("gun.bmp"),9,1000);
     im_small_right=im_small_left;
+    im_run_small_left=im_small_left;
+    im_run_small_right=im_small_right;
     im_shield_right=new Animation(imgcache->loadImage("olaf_fall_shield_right.bmp"));
     im_shield_left=new Animation(imgcache->loadImage("olaf_fall_shield_left.bmp"));
+    im_run_shield_right=im_shield_right;
+    im_run_shield_left=im_shield_left;
     im_fall_shield_left=im_shield_left;
     im_fall_shield_right=im_shield_right;
     im_die=new Animation(60,imgcache->loadImage("kuru.bmp"),12,2000,true);
@@ -35,6 +41,7 @@
 Olaf::~Olaf() {
     delete im_left;
     delete im_right;
+    delete im_run_right;
     delete im_land_left;
     delete im_small_left;
     delete im_shield_right;
@@ -44,21 +51,28 @@
 void Olaf::updateAnimState(bool change) {
     if (!change) {
     } else if (state&STATE_SMALL) {
-        if (state&STATE_LEFT) animation=im_small_left;
-        else animation=im_small_right;
+        if (state&STATE_LEFT) {
+            if (state&STATE_MLEFT) animation=im_run_small_left;
+            else animation=im_small_left;
+        } else {
+            if (state&STATE_MRIGHT) animation=im_run_small_right;
+            else animation=im_small_right;
+        }
     } else if (state&STATE_SHIELD) {
         otype|=OTYPE_DENSE_D;
         if (state&STATE_LEFT) {
             if (state&STATE_FALL) {
                 animation=im_fall_shield_left;
             } else {
-                animation=im_shield_left;
+                if (state&STATE_MLEFT) animation=im_run_shield_left;
+                else animation=im_shield_left;
             }
         } else {
             if (state&STATE_FALL) {
                 animation=im_fall_shield_right;
             } else {
-                animation=im_shield_right;
+                if (state&STATE_MRIGHT) animation=im_run_shield_right;
+                else animation=im_shield_right;
             }
         }
     } else {

Modified: trunk/src/objects/olaf.h
===================================================================
--- trunk/src/objects/olaf.h	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/olaf.h	2004-10-05 17:30:34 UTC (rev 73)
@@ -43,8 +43,12 @@
         //@{
         Animation* im_small_left;
         Animation* im_small_right;
+        Animation* im_run_small_left;
+        Animation* im_run_small_right;
         Animation* im_shield_left;
         Animation* im_shield_right;
+        Animation* im_run_shield_left;
+        Animation* im_run_shield_right;
         Animation* im_fall_shield_left;
         Animation* im_fall_shield_right;
         //@}

Modified: trunk/src/objects/scorch.cpp
===================================================================
--- trunk/src/objects/scorch.cpp	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/objects/scorch.cpp	2004-10-05 17:30:34 UTC (rev 73)
@@ -13,6 +13,8 @@
   wing(V_FLY) {
     im_left=new Animation(imgcache->loadImage("baleog_right.bmp"));
     im_right=im_left;
+    im_run_left=im_left;
+    im_run_right=im_right;
     im_fall_left=im_left;
     im_fall_right=im_left;
     im_krit_left=im_left;

Modified: trunk/src/players_common.cpp
===================================================================
--- trunk/src/players_common.cpp	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/players_common.cpp	2004-10-05 17:30:34 UTC (rev 73)
@@ -25,6 +25,8 @@
     enemy_types|=OTYPE_MONSTER;
     im_left=animation;
     im_right=animation;
+    im_run_left=animation;
+    im_run_right=animation;
     im_fall_left=animation;
     im_fall_right=animation;
     im_krit_left=animation;
@@ -146,6 +148,8 @@
             } else {
                 animation=im_fall_left;
             }
+        } else if (state&STATE_MLEFT) {
+            animation=im_run_left;
         } else {
             animation=im_left;
         }
@@ -156,6 +160,8 @@
             } else {
                 animation=im_fall_right;
             }
+        } else if (state&STATE_MRIGHT) {
+            animation=im_run_right;
         } else {
             animation=im_right;
         }

Modified: trunk/src/players_common.h
===================================================================
--- trunk/src/players_common.h	2004-10-05 12:20:13 UTC (rev 72)
+++ trunk/src/players_common.h	2004-10-05 17:30:34 UTC (rev 73)
@@ -112,6 +112,8 @@
         //@{
         Animation* im_left;
         Animation* im_right;
+        Animation* im_run_left;
+        Animation* im_run_right;
         Animation* im_fall_left;
         Animation* im_fall_right;
         Animation* im_krit_left;




More information about the lostpenguins-commits mailing list