r66 - trunk/src
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Oct 2 18:14:51 EDT 2004
Author: jonas
Date: 2004-10-02 18:14:51 -0400 (Sat, 02 Oct 2004)
New Revision: 66
Modified:
trunk/src/anim.cpp
trunk/src/characters_common.cpp
trunk/src/events.cpp
trunk/src/input.cpp
trunk/src/input.h
trunk/src/objectpools.h
trunk/src/players_common.cpp
trunk/src/players_common.h
trunk/src/weapons.h
Log:
removed all player specific parts from the InputHandler, increased input state size to Uint32, minor improvements
Modified: trunk/src/anim.cpp
===================================================================
--- trunk/src/anim.cpp 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/anim.cpp 2004-10-02 22:14:51 UTC (rev 66)
@@ -87,6 +87,26 @@
tcurrent=SDL_GetTicks();
if (!paused) {
+ //released keys of player
+ if (player != NULL) {
+ if (input->getState(INPUTR_USE)) player->in_use(-1);
+ input->unsetState(INPUTR_USE);
+ if (input->getState(INPUTR_ACT)) player->in_act(-1);
+ input->unsetState(INPUTR_ACT);
+ if (input->getState(INPUTR_RIGHT)) player->in_right(-1);
+ input->unsetState(INPUTR_RIGHT);
+ if (input->getState(INPUTR_LEFT)) player->in_left(-1);
+ input->unsetState(INPUTR_LEFT);
+ if (input->getState(INPUTR_SP1)) player->in_sp1(-1);
+ input->unsetState(INPUTR_SP1);
+ if (input->getState(INPUTR_SP2)) player->in_sp2(-1);
+ input->unsetState(INPUTR_SP2);
+ if (input->getState(INPUTR_UP)) player->in_up(-1);
+ input->unsetState(INPUTR_UP);
+ if (input->getState(INPUTR_DOWN)) player->in_down(-1);
+ input->unsetState(INPUTR_DOWN);
+ input->unsetState(INPUTR_DEL);
+ }
object_iterator obit=pool->objectspool.begin();
while (obit!=pool->objectspool.end()) {
//remove marked objects
@@ -100,7 +120,7 @@
(*obit)->updateEvents(dt);
++obit;
}
- //handle current player
+ //handle current (new) player
if ((player!=NULL) && (!(player->getState(ESTATE_BUSY)))) {
if (input->getState(INPUT_USE)) player->in_use(dt);
if (input->getState(INPUT_ACT)) player->in_act(dt);
Modified: trunk/src/characters_common.cpp
===================================================================
--- trunk/src/characters_common.cpp 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/characters_common.cpp 2004-10-02 22:14:51 UTC (rev 66)
@@ -79,7 +79,7 @@
hitobj=checkMove(pos,false,true);
//are we falling?
- if ((!(hitobj.touch&DIR_DOWN)) || (gravity<0)) {
+ if ((!(hitobj.touch&DIR_DOWN)) || (gravity<0) || (speed<0)) {
setState(STATE_FALL);
}
}
Modified: trunk/src/events.cpp
===================================================================
--- trunk/src/events.cpp 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/events.cpp 2004-10-02 22:14:51 UTC (rev 66)
@@ -57,7 +57,7 @@
anim(runanim),
del(delanim),
sound(asound) {
- state|=ESTATE_ANIM;
+ if (anim) state|=ESTATE_ANIM;
if (anim!=NULL) duration=30000;
}
Uint16 AnimEvent::update(Uint16 dt) {
@@ -96,7 +96,7 @@
anim(runanim),
del(delanim),
sound(asound) {
- state|=ESTATE_ANIM;
+ if (anim) state|=ESTATE_ANIM;
if (anim!=NULL) duration=30000;
}
Uint16 CAnimEvent::update(Uint16 dt) {
Modified: trunk/src/input.cpp
===================================================================
--- trunk/src/input.cpp 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/input.cpp 2004-10-02 22:14:51 UTC (rev 66)
@@ -6,9 +6,7 @@
#include "gfxeng.h"
#include "sfxeng.h"
#include "objectpools.h"
-///\todo The player calls should be in anim.cpp
#include "objects_common.h"
-#include "players_common.h"
InputHandler::InputHandler():
@@ -38,32 +36,32 @@
case SDL_KEYUP: {
switch(event.key.keysym.sym) {
case SDLK_LEFT: {
- if (state&INPUT_LEFT) player->in_left(-1);
+ if (state&INPUT_LEFT) setState(INPUTR_LEFT);
state&=~INPUT_LEFT;
break;
}
case SDLK_RIGHT: {
- if (state&INPUT_RIGHT) player->in_right(-1);
+ if (state&INPUT_RIGHT) state|=INPUTR_RIGHT;
state&=~INPUT_RIGHT;
break;
}
case SDLK_UP: {
- if (state&INPUT_UP) player->in_up(-1);
+ if (state&INPUT_UP) setState(INPUTR_UP);
state&=~INPUT_UP;
break;
}
case SDLK_DOWN: {
- if (state&INPUT_DOWN) player->in_down(-1);
+ if (state&INPUT_DOWN) setState(INPUTR_DOWN);
state&=~INPUT_DOWN;
break;
}
case SDLK_SPACE: {
- if (state&INPUT_SP1) player->in_sp1(-1);
+ if (state&INPUT_SP1) setState(INPUTR_SP1);
state&=~INPUT_SP1;
break;
}
case SDLK_LSHIFT: {
- if (state&INPUT_SP2) player->in_sp2(-1);
+ if (state&INPUT_SP2) setState(INPUTR_SP2);
state&=~INPUT_SP2;
break;
}
@@ -72,16 +70,17 @@
break;
}
case SDLK_RETURN: {
- if (state&INPUT_ACT) player->in_act(-1);
+ if (state&INPUT_ACT) setState(INPUTR_ACT);
state&=~INPUT_ACT;
break;
}
case SDLK_INSERT: {
- if (state&INPUT_USE) player->in_use(-1);
+ if (state&INPUT_USE) setState(INPUTR_USE);
state&=~INPUT_USE;
break;
}
case SDLK_DELETE: {
+ if (state&INPUT_DEL) setState(INPUTR_DEL);
state&=~INPUT_DEL;
break;
}
Modified: trunk/src/input.h
===================================================================
--- trunk/src/input.h 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/input.h 2004-10-02 22:14:51 UTC (rev 66)
@@ -11,6 +11,15 @@
#define INPUT_ACT 0x00000040
#define INPUT_USE 0x00000080
#define INPUT_DEL 0x00000100
+#define INPUTR_LEFT 0x00010000
+#define INPUTR_RIGHT 0x00020000
+#define INPUTR_UP 0x00040000
+#define INPUTR_DOWN 0x00080000
+#define INPUTR_SP1 0x00100000
+#define INPUTR_SP2 0x00200000
+#define INPUTR_ACT 0x00400000
+#define INPUTR_USE 0x00800000
+#define INPUTR_DEL 0x01000000
#define INPUT_PAUSE 0x10000000
/** \brief Handels keyboard events
@@ -22,18 +31,18 @@
~InputHandler();
/// Check for keyboard events
void pollEvents();
- bool getState(Uint16 cstate) {
+ bool getState(Uint32 cstate) {
return (state&cstate);
}
- void setState(Uint16 cstate) {
+ void setState(Uint32 cstate) {
state|=cstate;
}
- void unsetState(Uint16 cstate) {
+ void unsetState(Uint32 cstate) {
state&=~cstate;
}
private:
/// Information about which buttons are pressed
- Uint16 state;
+ Uint32 state;
/// Sound: When the game is paused
Mix_Chunk* au_pause;
};
Modified: trunk/src/objectpools.h
===================================================================
--- trunk/src/objectpools.h 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/objectpools.h 2004-10-02 22:14:51 UTC (rev 66)
@@ -28,7 +28,7 @@
/// \param arg3 Third argument as string
/// \return Pointer to the new entry in the objectspool or NULL if
/// the object was not recognized
- Object* addObjectbyName(const string& obj, const string& image, Uint16 x=0, Uint16 y=0, const string& arg1="0", const string& arg2="0", const string& arg3="0");
+ Object* addObjectbyName(const string& obj, const string& image, Sint16 x=0, Sint16 y=0, const string& arg1="0", const string& arg2="0", const string& arg3="0");
//@{
/// Add an Object to the objectspool
/// \return Pointer to the new entry in the objectspool or NULL if it failed
Modified: trunk/src/players_common.cpp
===================================================================
--- trunk/src/players_common.cpp 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/players_common.cpp 2004-10-02 22:14:51 UTC (rev 66)
@@ -353,8 +353,8 @@
case W_TOUCH: {
//TODO: play animations (make new Event for this)
if (direction&(DIR_UP|DIR_DOWN)) sfxeng->playWAV(aud_hit);
- if (direction&DIR_LEFT) setEvent(new ESpeed(this,TSTRIKE,-100,-DSTRIKE,0,ESTATE_BUSY,aud_hit));
- else setEvent(new ESpeed(this,TSTRIKE,-100,DSTRIKE,0,ESTATE_BUSY,aud_hit));
+ if (direction&DIR_LEFT) setEvent(new ESpeed(this,TSTRIKE,-200,-DSTRIKE,0,ESTATE_BUSY,aud_hit));
+ else setEvent(new ESpeed(this,TSTRIKE,-200,DSTRIKE,0,ESTATE_BUSY,aud_hit));
break;
}
case W_WATER: {
Modified: trunk/src/players_common.h
===================================================================
--- trunk/src/players_common.h 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/players_common.h 2004-10-02 22:14:51 UTC (rev 66)
@@ -103,6 +103,8 @@
//@}
/// \brief Called when crashing into a dense object (default: ground)
/// \param dir Direction of the crash
+ /// \bug crash is called _after_ addEnter/etc, so if one of those sets
+ /// an event, it will be canceled by crash!
virtual void crash(Uint16 dir=DIR_DOWN);
/// \brief Called when this player dies
virtual void die();
Modified: trunk/src/weapons.h
===================================================================
--- trunk/src/weapons.h 2004-10-02 14:56:41 UTC (rev 65)
+++ trunk/src/weapons.h 2004-10-02 22:14:51 UTC (rev 66)
@@ -22,7 +22,7 @@
#define WS_PRESSURE 0x00000010
#define WS_HEAL 0x00000020
-#define DSTRIKE 100
+#define DSTRIKE 200
#define TSTRIKE 600
/** \brief Weapons
More information about the lostpenguins-commits
mailing list