r82 - in trunk: . src src/objects
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Wed Feb 2 15:27:44 EST 2005
Author: jonas
Date: 2005-02-02 15:27:43 -0500 (Wed, 02 Feb 2005)
New Revision: 82
Modified:
trunk/TODO
trunk/src/characters_common.h
trunk/src/common.cpp
trunk/src/common.h
trunk/src/objects/fang.cpp
trunk/src/objects/olaf.cpp
trunk/src/objects/scorch.cpp
trunk/src/objects/zombie.cpp
trunk/src/players_common.cpp
Log:
- Made the air resistance less frame rate dependant
- Introduced a helper function boost that increases resp. decreases
the absolute value of an integer (used for air resistance)
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/TODO 2005-02-02 20:27:43 UTC (rev 82)
@@ -1,6 +1,6 @@
Bugs
====
- o rewrite zombie (attacks too often, use events, etc...)
+ o rewrite zombie (bug in movement!, attacks too often, use events, etc...)
o memleaks, segfaults?
@@ -15,7 +15,7 @@
This would help in many ways and should be a frame information and not an
image as done for players atm!
- o Fall/push/crash/collisions:
+ o Move/Fall/push/crash/collisions:
o the character should have more information what he hits
o movements into dense objects should involve a push()
o I have no idea about how the push should look like, elevators can be pushed
Modified: trunk/src/characters_common.h
===================================================================
--- trunk/src/characters_common.h 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/src/characters_common.h 2005-02-02 20:27:43 UTC (rev 82)
@@ -9,7 +9,7 @@
#define V_KRIT 1000
#define T_GRAV_EFFECT 10
#define T_AI_EFFECT 20
-#define SPEED_STEP 10
+#define HSPEED_MULT 100
//Character states
//facing: either left or right (not left)
Modified: trunk/src/common.cpp
===================================================================
--- trunk/src/common.cpp 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/src/common.cpp 2005-02-02 20:27:43 UTC (rev 82)
@@ -22,3 +22,9 @@
s << i;
return s.str();
}
+
+int boost(int a, int b) {
+ if (a>=0) return a=max(0,a+b);
+ else return a=min(0,a-b);
+}
+
Modified: trunk/src/common.h
===================================================================
--- trunk/src/common.h 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/src/common.h 2005-02-02 20:27:43 UTC (rev 82)
@@ -108,6 +108,8 @@
void usage();
/// Helper function that converts an integer to a string
string itos(int);
+/// Helper function boost that increases/decreases the absolute value
+int boost(int,int);
//@}
//global variables
Modified: trunk/src/objects/fang.cpp
===================================================================
--- trunk/src/objects/fang.cpp 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/src/objects/fang.cpp 2005-02-02 20:27:43 UTC (rev 82)
@@ -49,8 +49,8 @@
void Fang::fall(Uint16 dt) {
if (!getState(STATE_MRIGHT|STATE_MLEFT)) {
- if (!getState(STATE_FALL)) hspeed*=0.9;
- else hspeed*=0.96;
+ if (!getState(STATE_FALL)) hspeed=boost(hspeed,-dt*HSPEED_MULT/100);
+ else hspeed=boost(hspeed,-dt*HSPEED_MULT/200);
}
Dgrav+=dt;
if (Dgrav>T_GRAV_EFFECT) {
Modified: trunk/src/objects/olaf.cpp
===================================================================
--- trunk/src/objects/olaf.cpp 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/src/objects/olaf.cpp 2005-02-02 20:27:43 UTC (rev 82)
@@ -182,8 +182,8 @@
void Olaf::fall(Uint16 dt) {
if (!getState(STATE_MRIGHT|STATE_MLEFT)) {
- if (!getState(STATE_FALL)) hspeed*=0.9;
- else hspeed*=0.96;
+ if (!getState(STATE_FALL)) hspeed=boost(hspeed,-dt*HSPEED_MULT/100);
+ else hspeed=boost(hspeed,-dt*HSPEED_MULT/200);
}
Dgrav+=dt;
if (Dgrav>T_GRAV_EFFECT) {
Modified: trunk/src/objects/scorch.cpp
===================================================================
--- trunk/src/objects/scorch.cpp 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/src/objects/scorch.cpp 2005-02-02 20:27:43 UTC (rev 82)
@@ -36,8 +36,8 @@
void Scorch::fall(Uint16 dt) {
if (!getState(STATE_MRIGHT|STATE_MLEFT)) {
- if (!getState(STATE_FALL)) hspeed*=0.9;
- else hspeed*=0.96;
+ if (!getState(STATE_FALL)) hspeed=boost(hspeed,-dt*HSPEED_MULT/100);
+ else hspeed=boost(hspeed,-dt*HSPEED_MULT/200);
}
Dgrav+=dt;
if (Dgrav>T_GRAV_EFFECT) {
Modified: trunk/src/objects/zombie.cpp
===================================================================
--- trunk/src/objects/zombie.cpp 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/src/objects/zombie.cpp 2005-02-02 20:27:43 UTC (rev 82)
@@ -32,7 +32,7 @@
void Zombie::ai_left(Uint16 dt) {
SDL_Rect oldpos=pos;
- if ((hspeed-SPEED_STEP)>maxspeedx) hspeed-=SPEED_STEP;
+ if ((hspeed-HSPEED_MULT*dt/100)>(-maxspeedx)) hspeed-=HSPEED_MULT*dt/100;
else if (hspeed>(-maxspeedx)) hspeed=-maxspeedx;
Hit hit=move(dt,true);
if (hit.touch&enemy_types) {
@@ -52,7 +52,7 @@
void Zombie::ai_right(Uint16 dt) {
SDL_Rect oldpos=pos;
- if ((hspeed+SPEED_STEP)<maxspeedx) hspeed+=SPEED_STEP;
+ if ((hspeed+HSPEED_MULT*dt/100)<maxspeedx) hspeed+=HSPEED_MULT*dt/100;
else if (hspeed<maxspeedx) hspeed=maxspeedx;
Hit hit=move(dt,true);
if (hit.touch&enemy_types) {
Modified: trunk/src/players_common.cpp
===================================================================
--- trunk/src/players_common.cpp 2005-02-02 17:40:44 UTC (rev 81)
+++ trunk/src/players_common.cpp 2005-02-02 20:27:43 UTC (rev 82)
@@ -204,7 +204,7 @@
}
unsetState(STATE_LEFT);
setState(STATE_MRIGHT);
- if ((hspeed+SPEED_STEP)<maxspeedx) hspeed+=SPEED_STEP;
+ if ((hspeed+HSPEED_MULT*dt/100)<maxspeedx) hspeed+=HSPEED_MULT*dt/100;
else if (hspeed<maxspeedx) hspeed=maxspeedx;
}
@@ -215,7 +215,7 @@
}
setState(STATE_LEFT);
setState(STATE_MLEFT);
- if ((hspeed-SPEED_STEP)>(-maxspeedx)) hspeed-=SPEED_STEP;
+ if ((hspeed-HSPEED_MULT*dt/100)>(-maxspeedx)) hspeed-=HSPEED_MULT*dt/100;
else if (hspeed>(-maxspeedx)) hspeed=-maxspeedx;
}
void Player::in_up(Sint16) { }
@@ -229,8 +229,8 @@
void Player::fall(Uint16 dt) {
if (!getState(STATE_MRIGHT|STATE_MLEFT)) {
- if (!getState(STATE_FALL)) hspeed*=0.9;
- else hspeed*=0.96;
+ if (!getState(STATE_FALL)) hspeed=boost(hspeed,-dt*HSPEED_MULT/100);
+ else hspeed=boost(hspeed,-dt*HSPEED_MULT/200);
}
Character::fall(dt);
}
More information about the lostpenguins-commits
mailing list