r153 - in trunk/src: . objects
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Sep 6 08:12:40 EDT 2005
Author: jonas
Date: 2005-09-06 08:12:40 -0400 (Tue, 06 Sep 2005)
New Revision: 153
Modified:
trunk/src/animation.cpp
trunk/src/animation.h
trunk/src/common.h
trunk/src/objects/baleog.cpp
trunk/src/objects/erik.cpp
trunk/src/objects/fang.cpp
trunk/src/objects/olaf.cpp
trunk/src/objects/scorch.cpp
Log:
removed ATYPE_ONCE_END and added a new additional type for ATYPE_ALL_ONCE: ATYPE_ST_SWITCH, it will play the animation and then switch the direction
Modified: trunk/src/animation.cpp
===================================================================
--- trunk/src/animation.cpp 2005-09-06 11:37:46 UTC (rev 152)
+++ trunk/src/animation.cpp 2005-09-06 12:12:40 UTC (rev 153)
@@ -75,7 +75,7 @@
duration=(Uint32)(frames*1000.0/fps+0.5);
checkAnim();
}
-Animation::~Animation() { is_valid=false; }
+Animation::~Animation() { }
void Animation::runAnim() {
if (!isValid()) {
cout << "Starting an invalid animation!" << endl;
@@ -95,12 +95,26 @@
if (!isValid()) {
cout << "Stopping an invalid animation!" << endl;
return is_running=false;
- } else if (animation_type&ATYPE_ALL_ONCE) {
+ } else if (animation_type&ATYPE_ONCE) {
is_running=false;
cur_time=0;
- if (animation_type&ATYPE_ALL_LSTART) {
+ if (animation_type&ATYPE_ST_SWITCH) {
+ animation_type&=~ATYPE_ONCE;
+ animation_type|=ATYPE_ONCE_REV;
+ checkAnim();
+ } else {
+ forward=true;
cur_frame_num=0;
+ }
+ } else if (animation_type&ATYPE_ONCE_REV) {
+ is_running=false;
+ cur_time=0;
+ if (animation_type&ATYPE_ST_SWITCH) {
+ animation_type&=~ATYPE_ONCE_REV;
+ animation_type|=ATYPE_ONCE;
+ checkAnim();
} else {
+ forward=false;
cur_frame_num=frames-1;
}
}
@@ -116,7 +130,7 @@
cur_time+=dt;
Uint32 durationh=(Uint32)duration/2;
- if (animation_type&ATYPE_ONCE || animation_type&ATYPE_ONCE_END) {
+ if (animation_type&ATYPE_ONCE) {
if (cur_time>=duration) {
return stopAnim();
} else {
@@ -127,7 +141,7 @@
while(cur_time>=duration) cur_time-=duration;
}
cur_frame_num=(Uint16)(cur_time*frames/duration);
- } else if (animation_type&ATYPE_ONCE_REV || animation_type&ATYPE_ONCE_END_REV) {
+ } else if (animation_type&ATYPE_ONCE_REV) {
if (cur_time>=duration) {
return stopAnim();
} else {
@@ -383,11 +397,13 @@
if (animation_type&ATYPE_ALL_NORMAL) {
forward=true;
cur_frame_num=0;
+ base_frame_pos=start_pos;
} else {
forward=false;
cur_frame_num=frames-1;
+ base_frame_pos=end_pos;
}
- base_frame=Frame(base_image.surface,base_image.description[(animation_type&ATYPE_ALL_NORMAL) ? start_pos : end_pos]);
+ base_frame=Frame(base_image.surface,base_image.description[base_frame_pos]);
setShift();
}
return is_valid;
Modified: trunk/src/animation.h
===================================================================
--- trunk/src/animation.h 2005-09-06 11:37:46 UTC (rev 152)
+++ trunk/src/animation.h 2005-09-06 12:12:40 UTC (rev 153)
@@ -109,10 +109,10 @@
/// Example: BP_MU means the BP is the upper middle point of each frame.
/// Default: BP_MD
BasePointType bp_type;
- /// Animation type: ATYPE_ONCE (play once), ATYPE_ONCE_END (play once and stop at end),
- /// ATYPE_LOOP (always play, jump back to the beginning), ATYPE_SWING (always play,
- /// reverse direction when finnished). The appended _REV means that the animation is
- /// started at the end and played backwards.
+ /// Animation type: ATYPE_ONCE (play once), ATYPE_LOOP (always play, jump back to
+ /// the beginning), ATYPE_SWING (always play, reverse direction when finnished),
+ /// ATYPE_ST_SWITCH (parameter for ATYPE_ALL_ONCE: switch state 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;
@@ -137,6 +137,8 @@
Sint16 shift_y;
/// Duration of the animation in ms
Uint32 duration;
+ /// Position of the base frame
+ Uint16 base_frame_pos;
/// 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/common.h
===================================================================
--- trunk/src/common.h 2005-09-06 11:37:46 UTC (rev 152)
+++ trunk/src/common.h 2005-09-06 12:12:40 UTC (rev 153)
@@ -79,20 +79,21 @@
//Animation types
#define ATYPE_ONCE 0x00000001
-#define ATYPE_ONCE_END 0x00000002
-#define ATYPE_LOOP 0x00000004
-#define ATYPE_SWING 0x00000008
+#define ATYPE_LOOP 0x00000002
+#define ATYPE_SWING 0x00000004
+#define ATYPE_STEP 0x00000008
#define ATYPE_ONCE_REV 0x00000010
-#define ATYPE_ONCE_END_REV 0x00000020
-#define ATYPE_LOOP_REV 0x00000040
-#define ATYPE_SWING_REV 0x00000080
-#define ATYPE_ALL_ONCE 0x00000033
-#define ATYPE_ALL_LSTART 0x00000021
-#define ATYPE_ALL_LEND 0x00000012
-#define ATYPE_ALL_LOOP 0x00000044
-#define ATYPE_ALL_SWING 0x00000088
+#define ATYPE_LOOP_REV 0x00000020
+#define ATYPE_SWING_REV 0x00000040
+#define ATYPE_STEP_REV 0x00000080
+#define ATYPE_ALL_ONCE 0x00000011
+#define ATYPE_ALL_LOOP 0x00000022
+#define ATYPE_ALL_SWING 0x00000044
#define ATYPE_ALL_NORMAL 0x0000000F
#define ATYPE_ALL_REV 0x000000F0
+#define ATYPE_ST_SWITCH 0x00000100
+#define ATYPE_ONCE_S 0x00000101
+#define ATYPE_ONCE_S_REV 0x00000110
//Description formats
#define DESC_NONE 0x00000000
Modified: trunk/src/objects/baleog.cpp
===================================================================
--- trunk/src/objects/baleog.cpp 2005-09-06 11:37:46 UTC (rev 152)
+++ trunk/src/objects/baleog.cpp 2005-09-06 12:12:40 UTC (rev 153)
@@ -14,11 +14,11 @@
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,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
- anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+ anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR));
+ anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR));
weapon=Weapon(-1,W_STRIKE);
- anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE_END);
- anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE_END);
+ anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE);
+ anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE);
au_sword=scenario->sndcache->loadWAV("swrdsw2.wav");
}
Modified: trunk/src/objects/erik.cpp
===================================================================
--- trunk/src/objects/erik.cpp 2005-09-06 11:37:46 UTC (rev 152)
+++ trunk/src/objects/erik.cpp 2005-09-06 12:12:40 UTC (rev 153)
@@ -18,10 +18,10 @@
/*
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,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
- anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
- anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
- anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+ anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR));
+ anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR));
+ anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR));
+ anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR));
*/
anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD);
anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD);
@@ -36,22 +36,22 @@
anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD);
anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD);
anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD);
- anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
- anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+ anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE);
+ anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE);
anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD);
anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD);
- anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
- anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
- anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
- anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
- anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
- anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
- anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
- anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
- anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
- anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
- anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
- anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+ anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE);
+ anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE);
+ anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE);
+ anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE);
+ anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE);
+ anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE);
+ anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE);
+ anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE);
+ anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE);
+ anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE);
+ anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE);
+ anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE);
anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE);
/* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */
Modified: trunk/src/objects/fang.cpp
===================================================================
--- trunk/src/objects/fang.cpp 2005-09-06 11:37:46 UTC (rev 152)
+++ trunk/src/objects/fang.cpp 2005-09-06 12:12:40 UTC (rev 153)
@@ -16,8 +16,8 @@
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,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
- anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+ anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR));
+ anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,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");
Modified: trunk/src/objects/olaf.cpp
===================================================================
--- trunk/src/objects/olaf.cpp 2005-09-06 11:37:46 UTC (rev 152)
+++ trunk/src/objects/olaf.cpp 2005-09-06 12:12:40 UTC (rev 153)
@@ -16,9 +16,9 @@
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,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
- anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
- anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,BP_MD,ATYPE_ONCE_END,25);
+ anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR));
+ anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR));
+ anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,BP_MD,ATYPE_ONCE,25);
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);
Modified: trunk/src/objects/scorch.cpp
===================================================================
--- trunk/src/objects/scorch.cpp 2005-09-06 11:37:46 UTC (rev 152)
+++ trunk/src/objects/scorch.cpp 2005-09-06 12:12:40 UTC (rev 153)
@@ -16,8 +16,8 @@
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,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
- anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+ anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR));
+ anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,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");
More information about the lostpenguins-commits
mailing list