r144 - in trunk: src src/objects tools

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Sep 4 17:21:34 EDT 2005


Author: jonas
Date: 2005-09-04 17:21:33 -0400 (Sun, 04 Sep 2005)
New Revision: 144

Modified:
   trunk/src/animation.cpp
   trunk/src/animation.h
   trunk/src/characters_common.cpp
   trunk/src/characters_common.h
   trunk/src/common.cpp
   trunk/src/common.h
   trunk/src/events.cpp
   trunk/src/imgcache.cpp
   trunk/src/lost_penguins.cpp
   trunk/src/monsters_common.cpp
   trunk/src/monsters_common.h
   trunk/src/objectpools.cpp
   trunk/src/objects/baleog.cpp
   trunk/src/objects/baleog.h
   trunk/src/objects/erik.cpp
   trunk/src/objects/fang.cpp
   trunk/src/objects/fang.h
   trunk/src/objects/olaf.cpp
   trunk/src/objects/olaf.h
   trunk/src/objects/scorch.cpp
   trunk/src/objects/zombie.cpp
   trunk/src/objects_common.cpp
   trunk/src/objects_common.h
   trunk/src/players_common.cpp
   trunk/src/players_common.h
   trunk/src/scenario.cpp
   trunk/tools/lvl2magick.c
Log:
 o Forgot this in an old commit:
     lvl2magick now creates an animation file, basically based on the LVLDATA
     file. The animation files can be joined together as one single file.
 o Animation takes fps instead of duration as a parameter. Theoretically it
   seems to be the more logical choice but in reality it animations always
   seem to be of the same duration. To get FPS from duration, use
   calcFPS(frames,duration). To supply the duration specify it as a negative
   fps value in ms. Default 0 will set duration to DATA_LVLDUR=1000;
 o instead of applying animation directly this is now done using setAnim()
   which returns true if the argument is valid. Otherwise the original
   animation is set. To also initialize the animation supply true as a second
   argument (default: false). Animations are valid if they are not NULL.
 o Renamed animations from im_* to anim_*
 o players_common.* now handles all its animation, by default all animations
   are NULL. As players_common also deletes all its animation, each pointer has
   to point to a different location or we get a double free. :(
   players_common now also supports basic (bad) fallbacks to more basic
   animations like anim_left. So one doesn't has to specify them in the
   corresponding objects.
 o Fixed the object naming scheme in Objectspool.
 o Added (practically) all basic animations to Erik (now we only have to
   support them ;).


Modified: trunk/src/animation.cpp
===================================================================
--- trunk/src/animation.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/animation.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -2,18 +2,18 @@
 #include "animation.h"
 
 Animation::Animation(const Image& abase_image,
-          Uint32 aduration,
           Uint16 aframes,
           Uint16 aanimation_type,
+          double afps,
           Uint16 astart_pos,
           BasePointType abp_type,
           AllignType aallign_type,
           Sint16 ashift_x,
           Sint16 ashift_y):
   base_image(abase_image),
-  duration(aduration),
   frames(aframes),
   animation_type(aanimation_type),
+  fps(afps),
   start_pos(astart_pos),
   bp_type(abp_type),
   allign_type(aallign_type),
@@ -21,6 +21,12 @@
   shift_y(ashift_y),
   end_pos(start_pos+frames),
   base_pos(NULL) {
+    if (fps==0) {
+        fps=calcFPS(frames,DATA_LVLDUR);
+    } else if (fps<0) {
+        fps=calcFPS(frames,(Uint32)(-fps));
+    }
+    duration=(Uint32)(frames*1000.0/fps+0.5);
     checkAnim();
 }
 Animation::~Animation() { }

Modified: trunk/src/animation.h
===================================================================
--- trunk/src/animation.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/animation.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -8,8 +8,8 @@
     public:
         /// \brief Initialize the animation
         /// \param abase_image Base image used for the animation
-        /// \param aduration Duration of the animation
         /// \param aframes Number of frames
+        /// \param afps FPS of the animation, if (afps < 0) it is considered to be the duration in ms, if (afps==0) a default duration DATA_LVLDUR is taken
         /// \param aanimation_type Animation type
         /// \param astart_pos Start position from the frame array of the base_image
         /// \param abp_type Base point type
@@ -19,9 +19,9 @@
         ///
         /// To load one still image simply use: Animation(imgcache->loadImage(1,"image_name.png"))
         Animation(const Image& abase_image,
-                  Uint32 aduration=0,
                   Uint16 aframes=1,
                   Uint16 aanimation_type=ATYPE_LOOP,
+                  double afps=0,
                   Uint16 astart_pos=0,
                   BasePointType abp_type=BP_MD,
                   AllignType aallign_type=AT_MD,
@@ -75,8 +75,6 @@
     private:
         /// Base image for the animation (big)
         Image base_image;
-        /// Duration of the animation in ms
-        Uint32 duration;
         /// Number of frames
         Uint16 frames;
         /// Animation type: ATYPE_ONCE (play once), ATYPE_ONCE_END (play once and stop at end),
@@ -84,6 +82,8 @@
         /// reverse direction when finnished). The appended _REV means that the animation is
         /// started at the end and played backwards.
         Uint16 animation_type;
+        /// FPS of the animation
+        double fps;
         /// Start position from the frame array of the base_image
         Uint16 start_pos;
         ///\brief The base point of the animation
@@ -111,6 +111,8 @@
         //@}
         
         /* calculated or given values/functions */
+        /// Duration of the animation in ms
+        Uint32 duration;
         /// End position from the frame array of the base_image
         Uint16 end_pos;
         /// True if the animation consist of one still image (frames=1,still=true)

Modified: trunk/src/characters_common.cpp
===================================================================
--- trunk/src/characters_common.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/characters_common.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -17,8 +17,6 @@
   speed(0),
   gravity(900),
   Dgrav(0),
-  im_die_left(NULL),
-  im_die_right(NULL),
   dense_types(NOTHING),
   enemy_types(NOTHING),
   weapon(Weapon(0)) {
@@ -66,7 +64,7 @@
 }
 
 void Character::updateAnimState() {
-    animation=im_orig;
+    setAnim(anim_orig);
 }
 
 void Character::idle(Uint16) {

Modified: trunk/src/characters_common.h
===================================================================
--- trunk/src/characters_common.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/characters_common.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -173,9 +173,6 @@
         Sint16 gravity;
         //temporary attributes
         Sint16 Dgrav;
-        //Die animation
-        Animation* im_die_left;
-        Animation* im_die_right;
         //Entered objects
         std::set<Object *> enter;
         //Touched objects

Modified: trunk/src/common.cpp
===================================================================
--- trunk/src/common.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/common.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -37,6 +37,10 @@
     else return a=min(0,a-b);
 }
 
+double calcFPS(Uint16 frames, Uint32 duration) { 
+    return frames*1000.0/duration;
+}
+
 void setGameMode(Uint8 newmode) {
     game_mode=newmode;
     if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) {

Modified: trunk/src/common.h
===================================================================
--- trunk/src/common.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/common.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -48,6 +48,10 @@
 typedef std::set<Player *>::iterator player_iterator;
 typedef std::set<Monster *>::iterator monster_iterator;
 
+//Data
+#define DATA_LVLFPS 6
+#define DATA_LVLDUR 1000
+
 //General definitions
 #define NOTHING                 0x00000000
 #define ALL                     0xFFFFFFFF
@@ -203,6 +207,8 @@
 string itos(int);
 /// Helper function boost that increases/decreases the absolute value
 int boost(int,int);
+/// Calculate the fps as frames*1000/duration_in_ms
+double calcFPS(Uint16 frames, Uint32 duration);
 
 /// Set game mode
 void setGameMode(Uint8);
@@ -216,6 +222,7 @@
 Menu* closeMenu();
 /// Close all menus (menu=NULL)
 void closeMenus();
+
 //@}
 
 //global variables

Modified: trunk/src/events.cpp
===================================================================
--- trunk/src/events.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/events.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -69,7 +69,7 @@
 }
 void AnimEvent::start() {
     sfxeng->playWAV(sound);
-    if (anim) owner->setAnim(anim);
+    if (anim) owner->setAnim(anim,true);
     Event::start();
 }
 void AnimEvent::end() {
@@ -108,7 +108,7 @@
 }
 void CAnimEvent::start() {
     sfxeng->playWAV(sound);
-    if (anim) charowner->setAnim(anim);
+    if (anim) charowner->setAnim(anim,true);
     CEvent::start();
 }
 void CAnimEvent::end() {

Modified: trunk/src/imgcache.cpp
===================================================================
--- trunk/src/imgcache.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/imgcache.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -15,11 +15,15 @@
     }
 }
 
+/*
+   We add +0.5 to cleanly round the values
+   Alternative: We trunc the w,h values and ceil the x,y values to make the rectangle as small as possible
+*/
 SDL_Rect& ImageCache::scaleRectangle(SDL_Rect& base_rect, double scale_factor) {
-    base_rect.x=(Sint16)(base_rect.x*sqrt(scale_factor));
-    base_rect.y=(Sint16)(base_rect.y*sqrt(scale_factor));
-    base_rect.w=(Uint16)(base_rect.w*sqrt(scale_factor));
-    base_rect.h=(Uint16)(base_rect.h*sqrt(scale_factor));
+    base_rect.x=(Sint16)(base_rect.x*sqrt(scale_factor)+0.5);
+    base_rect.y=(Sint16)(base_rect.y*sqrt(scale_factor)+0.5);
+    base_rect.w=(Uint16)(base_rect.w*sqrt(scale_factor)+0.5);
+    base_rect.h=(Uint16)(base_rect.h*sqrt(scale_factor)+0.5);
     return base_rect;
 }
 
@@ -114,7 +118,9 @@
         // Nice return statement, isn't it ;-)))
         return (*(imgcache.insert(make_pair(make_pair(imagename,scale_factor),return_image))).first).second;
     // Return the existing Image in cache...
-    } else return (*imgit).second;
+    } else {
+        return (*imgit).second;
+    }
 }
 
 Image& ImageCache::loadImage(string imagename, double scale_factor, string image_desc_file) {
@@ -133,8 +139,6 @@
     if (!file) {
         cout << "Failed to open the image description file: " << loadfile << " not found!" << endl;
     } else {
-        cout << "Loading image description: " << loadfile << endl;
-
         string arg1,arg2,arg3,arg4,arg5,arg6;
         Uint16 description_type=DESC_NONE;
 

Modified: trunk/src/lost_penguins.cpp
===================================================================
--- trunk/src/lost_penguins.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/lost_penguins.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -100,7 +100,7 @@
     config.datadir="data/";
     config.anim_file="animation_data.anim";
     config.map="map1.cfg";
-    config.lvlscale=4;
+    config.lvlscale=2;
 
     //key bindings
     config.keybind[KEY_LEFT]    = SDLK_LEFT;

Modified: trunk/src/monsters_common.cpp
===================================================================
--- trunk/src/monsters_common.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/monsters_common.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -21,8 +21,8 @@
     otype|=OTYPE_MONSTER;
     enemy_types|=OTYPE_PLAYER;
     dense_types|=OTYPE_PLAYER;
-    im_left=animation;
-    im_right=animation;
+    anim_left=animation;
+    anim_right=animation;
     au_hit=scenario->sndcache->loadWAV("monhit.wav");
 }
 
@@ -75,9 +75,9 @@
 
 void Monster::updateAnimState() {
     if (state&STATE_LEFT) {
-        animation=im_left;   
+        setAnim(anim_left);   
     } else {   
-        animation=im_right;
+        setAnim(anim_right);
     }
 }
 

Modified: trunk/src/monsters_common.h
===================================================================
--- trunk/src/monsters_common.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/monsters_common.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -36,8 +36,8 @@
         std::set<Player *> targets;
         virtual Hit move(Uint16 dt, bool check=false);
         //common animations
-        Animation* im_left;
-        Animation* im_right;
+        Animation* anim_left;
+        Animation* anim_right;
         Mix_Chunk* au_hit;
         Sint16 Dai,Dattack;
 };

Modified: trunk/src/objectpools.cpp
===================================================================
--- trunk/src/objectpools.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objectpools.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -45,21 +45,22 @@
 
 Object* ObjectsPool::addObjectbyName(const string& obj, const string& image, Sint16 x, Sint16 y, string& arg1, string& arg2, const string& arg3) {
     //Set names...
-    if (arg1.empty()) arg1="0";
-    if (arg2.empty()) arg2="0";
     string name=getNextObjectName(obj);
-    if (arg1!="0") {
+    if (!arg1.empty()) {
         //one additional parameter
-        if (name=="Trigger" || name=="Door" || name=="Bomb" || name=="TriggeredBomb" || name=="Plant" || name=="Geyser" || name=="Wind" || name=="Spike") {
-            if (arg2!="0") name=arg2;
+        if (obj=="Trigger" || obj=="Door" || obj=="Bomb" || obj=="TriggeredBomb" || obj=="Plant" || obj=="Geyser" || obj=="Wind" || obj=="Spike") {
+            if (!arg2.empty()) name=arg2;
         //two additional parameter
-        } else if (name=="Teleporter") {
+        } else if (obj=="Teleporter") {
             if (!arg3.empty()) name=arg3;
         //no additional parameters
         } else {
             name=arg1;
         }
     }
+    if (arg1.empty()) arg1="0";
+    if (arg2.empty()) arg2="0";
+
     //normal objects
     if (obj=="Wall")         return (addObject(new Wall(image,x,y,name)));
     else if (obj=="Exit")    return (addObject(new Exit(image,x,y,name)));

Modified: trunk/src/objects/baleog.cpp
===================================================================
--- trunk/src/objects/baleog.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/baleog.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -10,34 +10,24 @@
 
 Baleog::Baleog(string imagename, Sint16 xcord, Sint16 ycord, string pname):
   Player(imagename,xcord,ycord,pname) {
-    im_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp"));
-    im_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp"));
-    im_run_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),1000,8);
-    im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),1000,8);
-    im_fall_left=im_left;
-    im_fall_right=im_right;
-    im_krit_left=im_left;
-    im_krit_right=im_right;
-    im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END);
-    im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END);
+    anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp"));
+    anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp"));
+    anim_walk_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),8);
+    anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8);
+    anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
     weapon=Weapon(-1,W_STRIKE);
-    im_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),1000,8,ATYPE_ONCE_END);
-    im_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),1000,8,ATYPE_ONCE_END);
+    anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,ATYPE_ONCE_END);
+    anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,ATYPE_ONCE_END);
     au_sword=scenario->sndcache->loadWAV("swrdsw2.wav");
 }
 
 Baleog::~Baleog() {
-    delete im_left;
-    delete im_right;
-    delete im_run_left;
-    delete im_run_right;
-    delete im_land_left;
-    delete im_land_right;
-    delete im_sword_left;
-    delete im_sword_right;
+    delete anim_sword_left;
+    delete anim_sword_right;
 }
 
 //Baleog1: Sword attack
 void Baleog::in_sp1() {
-    setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? im_sword_left : im_sword_right));
+    setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? anim_sword_left : anim_sword_right));
 }

Modified: trunk/src/objects/baleog.h
===================================================================
--- trunk/src/objects/baleog.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/baleog.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -11,6 +11,6 @@
         virtual void in_sp1();
     private:
         Mix_Chunk* au_sword;
-        Animation* im_sword_left;
-        Animation* im_sword_right;
+        Animation* anim_sword_left;
+        Animation* anim_sword_right;
 };

Modified: trunk/src/objects/erik.cpp
===================================================================
--- trunk/src/objects/erik.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/erik.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -16,38 +16,52 @@
   jump2(V_JUMP2) {
     weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE);
 /*
-    im_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp"));
-    im_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_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;
-    im_krit_right=im_right;
-    im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END);
-    im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END);
+    anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp"));
+    anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp"));
+    anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
 */
-    im_left=loadAnimation("eric_idle_left",config.lvlscale,1000);
-    im_right=loadAnimation("eric_idle_right",config.lvlscale,1000);
-    im_run_left=loadAnimation("eric_run_left",config.lvlscale,1000);
-    im_run_right=loadAnimation("eric_run_right",config.lvlscale,1000);
-    im_fall_left=loadAnimation("eric_fall_left",config.lvlscale,1000);
-    im_fall_right=loadAnimation("eric_fall_right",config.lvlscale,1000);
-    im_krit_left=loadAnimation("eric_fall_fast_left",config.lvlscale,1000);
-    im_krit_right=loadAnimation("eric_fall_fast_right",config.lvlscale,1000);
-    im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END);
-    im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END);
-    im_die_left=loadAnimation("eric_idle_left",config.lvlscale,1000);
-    im_die_right=loadAnimation("eric_idle_left",config.lvlscale,1000);
+    anim_left=loadAnimation("erik_idle_left",config.lvlscale);
+    anim_right=loadAnimation("erik_idle_right",config.lvlscale);
+    anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale);
+    anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale);
+    anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale);
+    anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale);
+    anim_push_left=loadAnimation("erik_push_left",config.lvlscale);
+    anim_push_right=loadAnimation("erik_push_right",config.lvlscale);
+    anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale);
+    anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale);
+    anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale);
+    anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale);
+    anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale);
+    anim_land_left=loadAnimation("erik_land_left",config.lvlscale,ATYPE_ONCE_END);
+    anim_land_right=loadAnimation("erik_land_right",config.lvlscale,ATYPE_ONCE_END);
+    anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale);
+    anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale);
+    anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,ATYPE_ONCE_END);
+    anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,ATYPE_ONCE_END);
+    anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,ATYPE_ONCE_END);
+    anim_bar=loadAnimation("bar_erik",config.lvlscale,ATYPE_ONCE);
+
+    /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */
     au_jump=scenario->sndcache->loadWAV("rboots.wav");
     au_hit=scenario->sndcache->loadWAV("erikhit.wav");
     au_run=NULL;
 }
 Erik::~Erik() {
-    delete im_left;
-    delete im_right;
-    delete im_land_left;
-    delete im_land_right;
 }
 
 void Erik::idle(Uint16 dt) {

Modified: trunk/src/objects/fang.cpp
===================================================================
--- trunk/src/objects/fang.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/fang.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -12,31 +12,21 @@
   Player(imagename,xcord,ycord,pname),
   jump(V_JUMP) {
     weapon=Weapon(-1,W_STRIKE);
-    im_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),1000,4);
-    im_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),1000,4);
-    im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),1000,8);
-    im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),1000,8);
-    im_fall_left=im_left;
-    im_fall_right=im_right;
-    im_krit_left=im_left;
-    im_krit_right=im_right;
-    im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END);
-    im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END);
-    im_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),1000,8,ATYPE_ONCE_END);
-    im_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),1000,8,ATYPE_ONCE_END);
+    anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4);
+    anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4);
+    anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8);
+    anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8);
+    anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8);
+    anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8);
     au_hit=scenario->sndcache->loadWAV("wolfhit.wav");
     au_claw=scenario->sndcache->loadWAV("wolfjmp1.wav");
     au_jump=scenario->sndcache->loadWAV("fangjump.wav");
 }
 Fang::~Fang() {
-    delete im_left;
-    delete im_right;
-    delete im_run_left;
-    delete im_run_right;
-    delete im_land_left;
-    delete im_land_right;
-    delete im_claw_left;
-    delete im_claw_right;
+    delete anim_claw_left;
+    delete anim_claw_right;
 }
 
 void Fang::in_left(Uint16 dt) {
@@ -94,7 +84,7 @@
 }
 
 void Fang::in_sp2() {
-    setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_claw,(state&STATE_LEFT) ? im_claw_left : im_claw_right));
+    setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_claw,(state&STATE_LEFT) ? anim_claw_left : anim_claw_right));
 }
 
 void Fang::crash(Uint16 dir) {

Modified: trunk/src/objects/fang.h
===================================================================
--- trunk/src/objects/fang.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/fang.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -34,8 +34,8 @@
         virtual void clearStates(bool reset=false);
     private:
         virtual void crash(Uint16 dir=DIR_DOWN);
-        Animation* im_claw_left;
-        Animation* im_claw_right;
+        Animation* anim_claw_left;
+        Animation* anim_claw_right;
         Mix_Chunk* au_jump;
         Mix_Chunk* au_claw;
         Sint16 jump;

Modified: trunk/src/objects/olaf.cpp
===================================================================
--- trunk/src/objects/olaf.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/olaf.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -12,73 +12,98 @@
 Olaf::Olaf(string imagename, Sint16 xcord, Sint16 ycord, string pname):
   Player(imagename,xcord,ycord,pname),
   fart(V_FART) {
-    im_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp"));
-    im_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp"));
-    im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),1000,8);
-    im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),1000,8);
-    im_fall_left=im_left;
-    im_fall_right=im_right;
-    im_krit_left=im_left;
-    im_krit_right=im_right;
-    im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END);
-    im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END);
+    anim_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp"));
+    anim_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp"));
+    anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),8);
+    anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),8);
+    anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,ATYPE_ONCE_END,25);
 
-    im_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),0,1);
-    im_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),0,1);
-    im_run_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),500,7);
-    im_run_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),500,7);
-    im_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp"));
-    im_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_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_left=loadAnimation(scenario->imgcache->loadImage(60,"kuru.bmp"),2000,12,0,ATYPE_ONCE_END);
-    im_die_right=im_die_left;
+    anim_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),1);
+    anim_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),1);
+    anim_walk_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),7,ATYPE_LOOP,3.5);
+    anim_walk_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),7,ATYPE_LOOP,3.5);
+    anim_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp"));
+    anim_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp"));
+    anim_walk_shield_left=NULL;
+    anim_walk_shield_right=NULL;
+    anim_fall_shield_left=NULL;
+    anim_fall_shield_right=NULL;
     au_small=scenario->sndcache->loadWAV("blob.wav");
     au_big=scenario->sndcache->loadWAV("unblob.wav");
     au_fart=scenario->sndcache->loadWAV("fart1.wav");
     au_hit=scenario->sndcache->loadWAV("fathit.wav");
 }
 Olaf::~Olaf() {
-    delete im_left;
-    delete im_right;
-    delete im_run_left;
-    delete im_run_right;
-    delete im_land_left;
-    delete im_land_right;
-    delete im_small_left;
-    delete im_small_right;
-    delete im_run_small_left;
-    delete im_run_small_right;
-    delete im_shield_right;
-    delete im_shield_left;
+    delete anim_small_left;
+    delete anim_small_right;
+    delete anim_walk_small_left;
+    delete anim_walk_small_right;
+    delete anim_walk_shield_left;
+    delete anim_walk_shield_right;
+    delete anim_shield_left;
+    delete anim_shield_right;
+    delete anim_fall_shield_left;
+    delete anim_fall_shield_right;
 }
 
 void Olaf::updateAnimState() {
     if (state&STATE_SMALL) {
         if (state&STATE_LEFT) {
-            if (state&STATE_MLEFT) animation=im_run_small_left;
-            else animation=im_small_left;
+            if (!setAnim(anim_walk_small_left)) {
+                if (!setAnim(anim_small_left)) setAnim(anim_left);
+            }
         } else {
-            if (state&STATE_MRIGHT) animation=im_run_small_right;
-            else animation=im_small_right;
+            if (!setAnim(anim_walk_small_right)) {
+                if (!setAnim(anim_small_right)) setAnim(anim_right);
+            }
         }
     } else if (state&STATE_SHIELD) {
         otype|=OTYPE_DENSE_D;
         if (state&STATE_LEFT) {
             if (state&STATE_FALL) {
-                animation=im_fall_shield_left;
+                if (state&STATE_MLEFT) {
+                    if (!setAnim(anim_fall_shield_left)) {
+                        if (!setAnim(anim_shield_left)) {
+                            if (!setAnim(anim_fall_left)) setAnim(anim_left);
+                        }
+                    }
+                } else if (!setAnim(anim_fall_shield_left)) {
+                    if (!setAnim(anim_fall_left)) setAnim(anim_left);
+                }
             } else {
-                if (state&STATE_MLEFT) animation=im_run_shield_left;
-                else animation=im_shield_left;
+                if (state&STATE_MLEFT) {
+                    if (!setAnim(anim_walk_shield_left)) {
+                        if (!setAnim(anim_shield_left)) {
+                            if (!setAnim(anim_walk_left)) setAnim(anim_left);
+                        }
+                    }
+                } else {
+                    if (!setAnim(anim_shield_left)) setAnim(anim_left);
+                }
             }
         } else {
             if (state&STATE_FALL) {
-                animation=im_fall_shield_right;
+                if (state&STATE_MRIGHT) {
+                    if (!setAnim(anim_fall_shield_right)) {
+                        if (!setAnim(anim_shield_right)) {
+                            if (!setAnim(anim_fall_right)) setAnim(anim_right);
+                        }
+                    }
+                } else if (!setAnim(anim_fall_shield_right)) {
+                    if (!setAnim(anim_fall_right)) setAnim(anim_right);
+                }
             } else {
-                if (state&STATE_MRIGHT) animation=im_run_shield_right;
-                else animation=im_shield_right;
+                if (state&STATE_MRIGHT) {
+                    if (!setAnim(anim_walk_shield_right)) {
+                        if (!setAnim(anim_shield_right)) {
+                            if (!setAnim(anim_walk_right)) setAnim(anim_right);
+                        }
+                    }
+                } else {
+                    if (!setAnim(anim_shield_right)) setAnim(anim_right);
+                }
             }
         }
     } else {
@@ -106,9 +131,9 @@
 
     Animation* tmpanim;
     SDL_Rect tmppos=pos;
-    if (small) tmpanim=im_small_left;
+    if (small) tmpanim=anim_small_left;
     //Assume both images have the same dimension
-    else tmpanim=im_orig;
+    else tmpanim=anim_orig;
     //IDEA: left/right edge instead of bottom?
     tmppos.x+=(Sint16)((tmppos.w-tmpanim->getFrameDim().w)/2);
     tmppos.y+=tmppos.h-tmpanim->getFrameDim().h;

Modified: trunk/src/objects/olaf.h
===================================================================
--- trunk/src/objects/olaf.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/olaf.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -41,16 +41,16 @@
         /// \return True if successfull
         inline bool trySmall(bool small);
         //@{
-        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;
+        Animation* anim_small_left;
+        Animation* anim_small_right;
+        Animation* anim_walk_small_left;
+        Animation* anim_walk_small_right;
+        Animation* anim_shield_left;
+        Animation* anim_shield_right;
+        Animation* anim_walk_shield_left;
+        Animation* anim_walk_shield_right;
+        Animation* anim_fall_shield_left;
+        Animation* anim_fall_shield_right;
         //@}
         //@{
         Mix_Chunk* au_small;

Modified: trunk/src/objects/scorch.cpp
===================================================================
--- trunk/src/objects/scorch.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/scorch.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -12,27 +12,17 @@
   Player(imagename,xcord,ycord,pname),
   left_wings(SCORCH_MAX_WINGS),
   wing(V_FLY) {
-    im_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp"));
-    im_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp"));
-    im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),1000,8);
-    im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),1000,8);
-    im_fall_left=im_left;
-    im_fall_right=im_right;
-    im_krit_left=im_left;
-    im_krit_right=im_right;
-    im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END);
-    im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END);
+    anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp"));
+    anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp"));
+    anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8);
+    anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8);
+    anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR));
     au_swing=scenario->sndcache->loadWAV("flapwngs.wav");
     au_tired=scenario->sndcache->loadWAV("flwings.wav");
     au_hit=scenario->sndcache->loadWAV("draghit.wav");
 }
 Scorch::~Scorch() {
-    delete im_left;
-    delete im_right;
-    delete im_run_left;
-    delete im_run_right;
-    delete im_land_left;
-    delete im_land_right;
 }
 
 void Scorch::idle(Uint16 dt) {

Modified: trunk/src/objects/zombie.cpp
===================================================================
--- trunk/src/objects/zombie.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects/zombie.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -15,14 +15,12 @@
   au_attack(scenario->sndcache->loadWAV("clang.wav")),
   T_Attack_Bite(1500) {
     maxspeedx=80;
-    im_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),1000,2);
-    im_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),1000,2);
+    anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,ATYPE_LOOP,2);
+    anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,ATYPE_LOOP,2);
     weapon=Weapon(-1,W_STRIKE);
 }
 
 Zombie::~Zombie() {
-    delete im_left;
-    delete im_right;
 }
 
 void Zombie::idle(Uint16 dt) {

Modified: trunk/src/objects_common.cpp
===================================================================
--- trunk/src/objects_common.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects_common.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -10,11 +10,11 @@
 Object::Object(string imagename, Sint16 xcord, Sint16 ycord, string oname):
   state(NOTHING),
   event(NULL),
-  im_orig(loadAnimation(scenario->imgcache->loadImage(1,imagename))),
   otype(NOTHING),
   name(oname),
   delete_flag(false) {
-    animation=im_orig;
+    anim_orig=loadAnimation(scenario->imgcache->loadImage(1,imagename));
+    animation=anim_orig;
     pos=animation->getFrameDim();
     pos.x=xcord;
     pos.y=ycord;
@@ -61,8 +61,8 @@
 
 Animation* Object::loadAnimation(string anim_name,
                          double scale_factor,
-                         Uint32 aduration,
                          Uint16 aanimation_type,
+                         double afps,
                          BasePointType abp_type,
                          AllignType aallign_type,
                          Sint16 ashift_x,
@@ -110,7 +110,7 @@
                     aframes=(Uint16)atoi(arg4.c_str());
 
                     if (anim_name==tmp_anim_name) {
-                        return loadAnimation(imgcache->loadImage(imagename,scale_factor),aduration,aframes,aanimation_type,astart_pos,abp_type,aallign_type,ashift_x,ashift_y);
+                        return loadAnimation(imgcache->loadImage(imagename,scale_factor),aframes,aanimation_type,afps,astart_pos,abp_type,aallign_type,ashift_x,ashift_y);
                     }
                 }
             }
@@ -120,15 +120,15 @@
 }
 
 Animation* Object::loadAnimation(const Image& abase_image,
-                         Uint32 aduration,
                          Uint16 aframes,
                          Uint16 aanimation_type,
+                         double afps,
                          Uint16 astart_pos,
                          BasePointType abp_type, 
                          AllignType aallign_type,
                          Sint16 ashift_x, 
                          Sint16 ashift_y) {
-    Animation* anim=new Animation(abase_image,aduration,aframes,aanimation_type,astart_pos,abp_type,aallign_type,ashift_x,ashift_y);
+    Animation* anim=new Animation(abase_image,aframes,aanimation_type,afps,astart_pos,abp_type,aallign_type,ashift_x,ashift_y);
     anim->setBasePos(&pos);
     return anim;
 }
@@ -142,13 +142,21 @@
 bool Object::updateAnim(Uint16 dt) {
     return (animation->updateAnim(dt));
 }
-void Object::setAnim(Animation* anim) {
-    animation=anim;
-    animation->setBasePos(&pos);
-    animation->runAnim();
+bool Object::setAnim(Animation* anim, bool start) {
+    if (anim) {
+        animation=anim;
+        if (start) {
+            animation->setBasePos(&pos);
+            animation->runAnim();
+        }
+        return true;
+    } else {
+        animation=anim_orig;
+        return false;
+    }
 }
 void Object::resetAnimState() {
-    animation=im_orig;
+    setAnim(anim_orig);
     animation->setBasePos(&pos);
     animation->runAnim();
 }

Modified: trunk/src/objects_common.h
===================================================================
--- trunk/src/objects_common.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/objects_common.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -88,7 +88,7 @@
         /// and starts it right away. Should not be used with updateAnimState,
         /// set ESTATE_ANIM to deactivate an updateAnimState. This is usually
         /// controlled by an AnimationEvent
-        void setAnim(Animation* anim);
+        bool setAnim(Animation* anim, bool start=false);
         /// Sets the animation back to the default one.
         virtual void resetAnimState();
         bool isRunning() const;
@@ -108,17 +108,17 @@
         /// Load an animation bound onto this object from an animation data file
         Animation* loadAnimation(string anim_name,
                                  double scale_factor=1,
-                                 Uint32 aduration=0,
                                  Uint16 aanimation_type=ATYPE_LOOP,
+                                 double afps=DATA_LVLFPS,
                                  BasePointType abp_type=BP_MD,
                                  AllignType aallign_type=AT_MD,
                                  Sint16 ashift_x=0,
                                  Sint16 ashift_y=0);
         /// Load an animation bound onto this object
         Animation* loadAnimation(const Image& abase_image,
-                                 Uint32 aduration=0,
                                  Uint16 aframes=1,
                                  Uint16 aanimation_type=ATYPE_LOOP,
+                                 double afps=DATA_LVLFPS,
                                  Uint16 astart_pos=0,
                                  BasePointType abp_type=BP_MD,
                                  AllignType aallign_type=AT_MD,
@@ -183,7 +183,7 @@
     protected:
         Uint32 state;
         Event* event;
-        Animation* im_orig;
+        Animation* anim_orig;
         Animation* animation;
         ///\todo Document this!
         /// Upper left logical position of the object (used for decisions)

Modified: trunk/src/players_common.cpp
===================================================================
--- trunk/src/players_common.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/players_common.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -26,16 +26,25 @@
     state=STATE_FALL;
     otype|=OTYPE_PLAYER;
     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;
-    im_krit_right=animation;
-    im_land_left=animation;
-    im_land_right=animation;
+    anim_left=anim_right=NULL;
+    anim_rock_left=anim_rock_right=NULL;
+    anim_walk_left=anim_walk_right=NULL;
+    anim_push_left=anim_push_right=NULL;
+    anim_fall_left=anim_fall_right=NULL;
+    anim_fall_fast_left=anim_fall_fast_right=NULL;
+    anim_land_left=anim_land_right=NULL;
+    anim_crash_left=anim_crash_right=NULL;
+    anim_rope_left=anim_rope_right=NULL;
+    anim_teleport_left=anim_teleport_right=NULL;
+    anim_die_crash_left=anim_die_crash_right=NULL;
+    anim_die_burn_left=anim_die_burn_right=NULL;
+    anim_die_bones_left=anim_die_bones_right=NULL;
+    anim_die_elec_left=anim_die_elec_right=NULL;
+    anim_die_spike_left=anim_die_spike_right=NULL;
+    anim_die_water_left=anim_die_water_right=NULL;
+    anim_fall_middle=NULL;
+    anim_climb=NULL;
+    anim_bar=NULL;
     au_land=scenario->sndcache->loadWAV("dizzy.wav");
     au_act=scenario->sndcache->loadWAV("button.wav");
     au_useerror=scenario->sndcache->loadWAV("useerror.wav");
@@ -49,6 +58,41 @@
 }
 
 Player::~Player() {
+    delete anim_left;
+    delete anim_right;
+    delete anim_rock_left;
+    delete anim_rock_right;
+    delete anim_walk_left;
+    delete anim_walk_right;
+    delete anim_push_left;
+    delete anim_push_right;
+    delete anim_fall_left;
+    delete anim_fall_right;
+    delete anim_fall_fast_left;
+    delete anim_fall_fast_right;
+    delete anim_land_left;
+    delete anim_land_right;
+    delete anim_crash_left;
+    delete anim_crash_right;
+    delete anim_rope_left;
+    delete anim_rope_right;
+    delete anim_teleport_left;
+    delete anim_teleport_right;
+    delete anim_die_crash_left;
+    delete anim_die_crash_right;
+    delete anim_die_burn_left;
+    delete anim_die_burn_right;
+    delete anim_die_bones_left;
+    delete anim_die_bones_right;
+    delete anim_die_elec_left;
+    delete anim_die_elec_right;
+    delete anim_die_spike_left;
+    delete anim_die_spike_right;
+    delete anim_die_water_left;
+    delete anim_die_water_right;
+    delete anim_fall_middle;
+    delete anim_climb;
+    delete anim_bar;
     for (Uint8 i=0; i<MAX_ITEMS; i++) {
         if (items[i]) {
             removeItem(i);
@@ -57,7 +101,9 @@
 }
 
 Frame Player::getIcon() const {
-    return (im_right->getBaseFrame());
+    if (anim_bar) return (anim_bar->getBaseFrame());
+    else if (anim_right) return (anim_right->getBaseFrame());
+    else return (anim_orig->getBaseFrame());
 }
 
 void Player::addEnter(std::set<Object *>& aset) {
@@ -150,26 +196,38 @@
     if (state&STATE_LEFT) {
         if (state&STATE_FALL) {
             if (speed>V_KRIT) {
-                animation=im_krit_left;
+                if (!setAnim(anim_fall_fast_left)) {
+                    if (!setAnim(anim_fall_left)) setAnim(anim_left);
+                }
+            } else if (state&STATE_MLEFT || speed < 0) {
+                if (!setAnim(anim_fall_left)) setAnim(anim_left);
             } else {
-                animation=im_fall_left;
+                if (!setAnim(anim_fall_middle)) {
+                    if (!setAnim(anim_fall_left)) setAnim(anim_left);
+                }
             }
         } else if (state&STATE_MLEFT) {
-            animation=im_run_left;
+            if (!setAnim(anim_walk_left)) setAnim(anim_left);
         } else {
-            animation=im_left;
+            setAnim(anim_left);
         }
     } else {
         if (state&STATE_FALL) {
             if (speed>V_KRIT) {
-                animation=im_krit_right;
+                if (!setAnim(anim_fall_fast_right)) {
+                    if (!setAnim(anim_fall_right)) setAnim(anim_right);
+                }
+            } else if (state&STATE_MRIGHT || speed < 0) {
+                if (!setAnim(anim_fall_right)) setAnim(anim_right);
             } else {
-                animation=im_fall_right;
+                if (!setAnim(anim_fall_middle)) {
+                    if (!setAnim(anim_fall_right)) setAnim(anim_right);
+                }
             }
         } else if (state&STATE_MRIGHT) {
-            animation=im_run_right;
+            if (!setAnim(anim_walk_right)) setAnim(anim_right);
         } else {
-            animation=im_right;
+            setAnim(anim_right);
         }
     }
 }
@@ -279,27 +337,24 @@
         Character* deadplr=scenario->pool->addCharacter(new DeadPlayer("dead_player.bmp",pos.x,pos.y));
         switch(weap.getSubType()) {
             case WS_FIRE: {
-                if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_fire,(state&STATE_LEFT) ? im_die_left : im_die_right));
+                if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_fire,(state&STATE_LEFT) ? anim_die_burn_left : anim_die_burn_right));
                 else sfxeng->playWAV(au_fire);
                 break;
             }
             case WS_WATER: {
-                if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_drown,(state&STATE_LEFT) ? im_die_left : im_die_right));
+                if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_drown,(state&STATE_LEFT) ? anim_die_water_left : anim_die_water_right));
                 else sfxeng->playWAV(au_drown);
                 break;
             }
             //WS_NORMAL, WS_ELECTRIC, WS_FIRE, WS_PRESSURE
             default: {
-                if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_die,(state&STATE_LEFT) ? im_die_left : im_die_right));
+                if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_die,(state&STATE_LEFT) ? anim_die_bones_left : anim_die_bones_right));
                 else sfxeng->playWAV(au_die);
             }
         }
     //damaged or healed...
     } else {
         Mix_Chunk* aud_hit;
-        Animation* anim_hit;
-        if (state&STATE_LEFT) anim_hit=im_land_left;
-        else anim_hit=im_land_right;
         //TODO add more Animations
         switch(weap.getSubType()) {
             case WS_HEAL: {
@@ -328,7 +383,7 @@
                 break;
             }
             case W_PRESSURE: {
-                setEvent(new CAnimEvent(this,T_IRR,0,ESTATE_BUSY,aud_hit,anim_hit));
+                setEvent(new CAnimEvent(this,T_IRR,0,ESTATE_BUSY,aud_hit,(state & STATE_LEFT) ? anim_crash_left : anim_crash_right));
                 break;
             }
             case W_TOUCH: {

Modified: trunk/src/players_common.h
===================================================================
--- trunk/src/players_common.h	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/players_common.h	2005-09-04 21:21:33 UTC (rev 144)
@@ -114,16 +114,41 @@
         virtual void die();
         virtual Hit move(Uint16 dt, bool check=false);
         //@{
-        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;
-        Animation* im_krit_right;
-        Animation* im_land_left;
-        Animation* im_land_right;
+        Animation* anim_left;
+        Animation* anim_right;
+        Animation* anim_rock_left;
+        Animation* anim_rock_right;
+        Animation* anim_walk_left;
+        Animation* anim_walk_right;
+        Animation* anim_push_left;
+        Animation* anim_push_right;
+        Animation* anim_fall_left;
+        Animation* anim_fall_right;
+        Animation* anim_fall_fast_left;
+        Animation* anim_fall_fast_right;
+        Animation* anim_land_left;
+        Animation* anim_land_right;
+        Animation* anim_crash_left;
+        Animation* anim_crash_right;
+        Animation* anim_rope_left;
+        Animation* anim_rope_right;
+        Animation* anim_teleport_left;
+        Animation* anim_teleport_right;
+        Animation* anim_die_crash_left;
+        Animation* anim_die_crash_right;
+        Animation* anim_die_burn_left;
+        Animation* anim_die_burn_right;
+        Animation* anim_die_bones_left;
+        Animation* anim_die_bones_right;
+        Animation* anim_die_elec_left;
+        Animation* anim_die_elec_right;
+        Animation* anim_die_spike_left;
+        Animation* anim_die_spike_right;
+        Animation* anim_die_water_left;
+        Animation* anim_die_water_right;
+        Animation* anim_fall_middle;
+        Animation* anim_climb;
+        Animation* anim_bar;
         //@}
         //@{
         Mix_Chunk*  au_hit;

Modified: trunk/src/scenario.cpp
===================================================================
--- trunk/src/scenario.cpp	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/src/scenario.cpp	2005-09-04 21:21:33 UTC (rev 144)
@@ -109,8 +109,7 @@
         image.erase();
         x=0;
         y=0;
-        arg1=arg2="0";
-        arg3="";
+        arg1=arg2=arg3="";
         std::istringstream tmpstream(mapbuf[linenum]);
         tmpstream >> cname >> image >> x >> y >> arg1 >> arg2 >> arg3;
 

Modified: trunk/tools/lvl2magick.c
===================================================================
--- trunk/tools/lvl2magick.c	2005-09-04 00:13:18 UTC (rev 143)
+++ trunk/tools/lvl2magick.c	2005-09-04 21:21:33 UTC (rev 144)
@@ -61,6 +61,8 @@
     char data_file[20];
     /* output geometry file */
     char geom_file[20];
+    /* output animation description file */
+    char anim_file[20];
     /* base name (used for output directory and output file names) */
     char basename[20];
     /* image format */
@@ -154,7 +156,7 @@
     printf("  -h, --help             Print this help message\n\n");
     printf("  -debug                 Create additional debug files (default: off)\n\n");
     printf("  -start_index <n>       Start index of the frame image names (default: 0)\n\n");
-    printf("  -write <0-7>           n=0: Just create the geometry data (no images)\n");
+    printf("  -write <0-7>           n=0: Just create the geometry and animation data (no images)\n");
     printf("                         n=1: Create one big image with all animations in it\n");
     printf("                         n=2: Create one image for each animation\n");
     printf("                         n=4: Create one image for each frame\n");
@@ -278,7 +280,8 @@
     if (strcmp(config.data_file,"")==0) {
         snprintf(config.data_file,16,"%s.dat",config.basename);
     }
-    snprintf(config.geom_file,16,"%s.dsc",config.basename);
+    snprintf(config.geom_file,16,"%s.%s.dsc",config.basename,config.format);
+    snprintf(config.anim_file,16,"%s.%s.anim",config.basename,config.format);
 
     /* set colorkey in palette */
     lvl_palette[0][red]   = (unsigned char)(config.colorkey.red*255/MaxRGB);
@@ -319,7 +322,7 @@
  *
  */
 unsigned int parseDataFile(char* data_file_name, LVLAnim** lvlanims) {
-    const char data_id[]="ANIMATION LVLANIM";
+    const char data_id[]="LVLDATA";
     unsigned int start_num, size, data_size=0;
     char name[50], line[80];
     int match=0;
@@ -333,7 +336,7 @@
         return 0;
     }
 
-    if (!fgets(line,80,data_file) || strncmp(line,data_id,17)) {
+    if (!fgets(line,80,data_file) || strncmp(line,data_id,7)) {
         printf("Data file %s is invalid!!\n",data_file_name);
         fclose(data_file);
         return 0;
@@ -430,7 +433,7 @@
 
     const char entry_id[]="TRPS";
     unsigned int data_size=0, tot_entries=0, num_entries=0, unknown=0;
-    FILE *lvl_file=NULL, *unknown_file=NULL, *geom_file=NULL;
+    FILE *lvl_file=NULL, *unknown_file=NULL, *geom_file=NULL, *anim_file=NULL;
     LVLAnim* lvlanims=NULL;
     unsigned int lvlanim_size=0;
 
@@ -559,13 +562,11 @@
         GetExceptionInfo(&exception);
         d_exception=1;
         GetMontageInfo(image_info,&montage_info);
-        montage_info.tile="1x3000";
         montage_info.geometry="+0+0";
         montage_info.background_color=config.bg;
         montage_info.matte_color=config.colorkey;
         montage_info.gravity=NorthWestGravity;
         GetMontageInfo(image_info,&montage_anim_info);
-        montage_anim_info.tile="3000x1";
         montage_anim_info.geometry="+0+0";
         montage_anim_info.background_color=config.bg;
         montage_anim_info.matte_color=config.colorkey;
@@ -655,28 +656,47 @@
         big_image=NULL;
     }
 
-    /* Create the geometry file */
-    snprintf(buf,16,"%s.dsc",config.basename);
-    geom_file = fopen(buf,"w");
-    geom_file = freopen(buf,"a",geom_file);
+    /* Create the animation data file */
+    anim_file = fopen(config.anim_file,"w");
+    anim_file = freopen(config.anim_file,"a",anim_file);
 
-    fprintf(geom_file,"DESCRIPTION LVLANIM\n");
+    /* j is the current start frame number */
+    j=0;
+    fprintf(anim_file,"ANIMATION LVLANIM\n\n");
+    for (i=0; i<lvlanim_size; i++) {
+        fprintf(anim_file,"%s %s.%s %u %u\n",lvlanims[i].name,config.basename,config.format,j,lvlanims[i].size);
+        j+=lvlanims[i].size;
+    }
+
+    geom_file = fopen(config.geom_file,"w");
+    geom_file = freopen(config.geom_file,"a",geom_file);
+
+    fprintf(geom_file,"DESCRIPTION LVLANIM\n\n");
+/*
     fprintf(geom_file,"Size %u %u\n\n",lvlanim_size,num_entries);
+*/
     for (i=0; i<lvlanim_size; i++) {
+/*
         fprintf(geom_file,"%s %u {\n",lvlanims[i].name,lvlanims[i].size);
         for (j=0; j<lvlanims[i].size; j++) {
             fprintf(geom_file,"  %5u %5u %5u %5u\n",lvlanims[i].geometry[j].x,lvlanims[i].geometry[j].y,lvlanims[i].geometry[j].w,lvlanims[i].geometry[j].h);
         }
         fprintf(geom_file,"}\n\n");
+*/
+        for (j=0; j<lvlanims[i].size; j++) {
+            fprintf(geom_file,"%5u %5u %5u %5u\n",lvlanims[i].geometry[j].x,lvlanims[i].geometry[j].y,lvlanims[i].geometry[j].w,lvlanims[i].geometry[j].h);
+        }
     }
 
     /* Summary */
     printf("%s/ Contains: ",config.basename);
-    if (config.write&1) printf("1 big animation composition image, ");
-    if (config.write&2) printf("%u extracted animation images, ", lvlanim_size);
-    if (config.write&4) printf("%u extracted frame images, ", num_entries);
-    if (config.debug)   printf("unknown chunk files, ");
-    printf("1 geometry files\n");
+    if (config.write&1)  printf("1 big animation composition image, ");
+    if (config.write&2)  printf("%u extracted animation images, ", lvlanim_size);
+    if (config.write&4)  printf("%u extracted frame images, ", num_entries);
+    if (config.debug)    printf("unknown chunk files, ");
+    if (geom_file!=NULL) printf("1 geometry file, ");
+    if (anim_file!=NULL) printf("1 animation data file ");
+    printf("\n");
     printf("Total images: %u, Extracted images: %u, Unknown content: %u bytes\n",tot_entries,num_entries,unknown);
 
     end:
@@ -697,6 +717,7 @@
     if (lvlanims && lvlanim_size)        freeLVLAnimList(lvlanims,lvlanim_size);
     if (lvl_file!=NULL)  fclose(lvl_file);
     if (geom_file!=NULL) fclose(geom_file);
+    if (anim_file!=NULL) fclose(anim_file);
 
     return errno;
 }




More information about the lostpenguins-commits mailing list