[Clonekeenplus-commits] [SCM] clonekeenplus branch, master, updated. 7d3e41504860735263a4eb8ef2ca0e
Commander Keen Interpreter
Brought to you by:
gerstrong
From: Gerstrong <ger...@us...> - 2010-11-06 22:35:01
|
via 7d3e41504860735263a4eb8ef2ca0e0a4d8e60a9 (commit) via f313f23f987d15cae0d2f161f76d9aff48abe6ec (commit) from 396f8d0d934ef8b49d855dac2521bb2cdafd6758 (commit) - Log ----------------------------------------------------------------- commit 7d3e41504860735263a4eb8ef2ca0e0a4d8e60a9 Author: Gerhard Stein <ger...@gm...> Date: Sat Nov 6 23:34:01 2010 +0100 more vectorized stuff commit f313f23f987d15cae0d2f161f76d9aff48abe6ec Author: Gerhard Stein <ger...@gm...> Date: Sat Nov 6 23:15:03 2010 +0100 introduced 2D Vector for the position ----------------------------------------------------------------------- Summary of changes: src/common/CObject.cpp | 101 ++++++++++---------- src/common/CObject.h | 3 +- src/common/CObjectCollision.cpp | 46 +++++----- src/common/CPlane.cpp | 1 + src/common/CPlayer.cpp | 1 - src/engine/CCamera.cpp | 16 ++-- src/engine/galaxy/ai/CPlayerLevel.cpp | 32 +++++-- src/engine/galaxy/ai/CPlayerLevel.h | 1 + src/engine/galaxy/ai/CPlayerWM.cpp | 2 +- src/engine/vorticon/ai/CBallJack.cpp | 2 + src/engine/vorticon/ai/CFireBall.cpp | 5 +- src/engine/vorticon/ai/CMessie.cpp | 22 ++-- src/engine/vorticon/ai/CRay.cpp | 11 +-- src/engine/vorticon/ai/CRay.h | 6 +- src/engine/vorticon/ai/CSectorEffector.cpp | 2 +- src/engine/vorticon/ai/CTeleporter.cpp | 4 +- src/engine/vorticon/finale/CEndingEp1.cpp | 6 +- src/engine/vorticon/finale/CEndingEp2.cpp | 4 +- src/engine/vorticon/finale/CEndingEp3.cpp | 4 +- src/engine/vorticon/finale/CShipFlySys.cpp | 2 +- .../vorticon/playgame/CPlayGameGameState.cpp | 4 +- src/engine/vorticon/playgame/CPlayGameLevel.cpp | 8 +- 22 files changed, 152 insertions(+), 131 deletions(-) diff --git a/src/common/CObject.cpp b/src/common/CObject.cpp index 67f560a..4ecd4ac 100644 --- a/src/common/CObject.cpp +++ b/src/common/CObject.cpp @@ -24,7 +24,8 @@ sprite(BLANKSPRITE), mp_object(NULL), mp_Map(pmap), m_blinktime(0), -m_invincible(false) +m_invincible(false), +m_Pos(x,y) { bboxX1 = 0; bboxX2 = 0; @@ -36,8 +37,6 @@ m_invincible(false) solid = true; inhibitfall = false; - this->x = x; - this->y = y; canbezapped = false; onscreen = false; @@ -160,7 +159,7 @@ bool CObject::calcVisibility() (mp_Map->m_scrolly<<STC)-(visibility<<CSF); Uint32 down = ((mp_Map->m_scrolly+gameres.h)<<STC)+(visibility<<CSF); - bool inscreen = ( right > x && left < x && down > y && up < y ); + bool inscreen = ( right > m_Pos.x && left < m_Pos.x && down > m_Pos.y && up < m_Pos.y ); // Bullets should disappear when offscreen if(m_type == OBJ_SNDWAVE || m_type == OBJ_RAY || m_type == OBJ_FIREBALL) @@ -204,15 +203,20 @@ bool CObject::checkforScenario() // Used in some setup mode, like putting the player to // the current map position -void CObject::moveToForce(int new_x, int new_y) +void CObject::moveToForce(const VectorD2<int> &dir) { bool laststate = solid; solid = false; - moveTo(new_x, new_y); + moveTo(dir); solid = laststate; } +void CObject::moveToForce(int new_x, int new_y) +{ + moveToForce(VectorD2<int>(new_x, new_y)); +} + // For the vector functions void CObject::moveDir(const VectorD2<int> &dir) { @@ -222,23 +226,22 @@ void CObject::moveDir(const VectorD2<int> &dir) void CObject::moveTo(const VectorD2<Uint32> &new_loc) { - moveTo(new_loc.x, new_loc.y); + VectorD2<int> amount = new_loc - m_Pos; + + if(amount.x < 0) // move left + moveLeft(-amount.x); + else if(amount.x > 0) // move right + moveRight(amount.x); + + if(amount.y < 0) // means up + moveUp(-amount.y); + else if(amount.y > 0) // means down + moveDown(amount.y); } void CObject::moveTo(int new_x, int new_y) { - int amount_x = new_x-x; - int amount_y = new_y-y; - - if(amount_x < 0) // move left - moveLeft(-amount_x); - else if(amount_x > 0) // move right - moveRight(amount_x); - - if(amount_y < 0) // means up - moveUp(-amount_y); - else if(amount_y > 0) // means down - moveDown(amount_y); + moveTo(VectorD2<Uint32>(new_x, new_y)); } void CObject::moveXDir(int amount, bool force) @@ -261,17 +264,17 @@ void CObject::moveLeft(int amount, bool force) if(amount <= 0) return; - int y1 = y + bboxY1; - int y2 = y + bboxY2; + int y1 = m_Pos.y + bboxY1; + int y2 = m_Pos.y + bboxY2; blockedr = false; // If it is forced don't check for collision if(force) { - x -= amount; + m_Pos.x -= amount; return; } - if( y-amount < 0 ) + if( m_Pos.y-amount < 0 ) return; // If object isn't solid it won't be stopped anyway @@ -279,7 +282,7 @@ void CObject::moveLeft(int amount, bool force) { blockedr = blockedl = false; blockedu = blockedd = false; - x -= amount; + m_Pos.x -= amount; return; } @@ -290,13 +293,13 @@ void CObject::moveLeft(int amount, bool force) { if(amount > (1<<STC)) { - x -= (1<<STC); + m_Pos.x -= (1<<STC); moveSlopedTiles(getXMidPos()-64, y1, y2, -(1<<STC)); amount -= (1<<STC); } else { - x -= amount; + m_Pos.x -= amount; moveSlopedTiles(getXMidPos()-64, y1, y2, -amount); amount = 0; } @@ -310,12 +313,12 @@ void CObject::moveRight(int amount, bool force) if(amount <= 0) return; - int y1 = y + bboxY1; - int y2 = y + bboxY2; + int y1 = m_Pos.y + bboxY1; + int y2 = m_Pos.y + bboxY2; blockedl = false; if(force) { - x += amount; + m_Pos.x += amount; return; } @@ -323,7 +326,7 @@ void CObject::moveRight(int amount, bool force) { blockedr = blockedl = false; blockedu = blockedd = false; - x += amount; + m_Pos.x += amount; return; } @@ -335,13 +338,13 @@ void CObject::moveRight(int amount, bool force) { if(amount > (1<<STC)) { - x += (1<<STC); + m_Pos.x += (1<<STC); moveSlopedTiles(getXMidPos()+64, y1, y2, (1<<STC)); amount -= (1<<STC); } else { - x += amount; + m_Pos.x += amount; moveSlopedTiles(getXMidPos()+64, y1, y2, amount); amount = 0; } @@ -355,7 +358,7 @@ void CObject::moveUp(int amount) if(amount <= 0) return; - int y1 = y + bboxY1; + int y1 = m_Pos.y + bboxY1; if( y1-amount < 0 ) return; @@ -364,7 +367,7 @@ void CObject::moveUp(int amount) { blockedr = blockedl = false; blockedu = blockedd = false; - y -= amount; + m_Pos.y -= amount; return; } @@ -375,12 +378,12 @@ void CObject::moveUp(int amount) { if(amount > (1<<STC)) { - y -= (1<<STC); + m_Pos.y -= (1<<STC); amount -= (1<<STC); } else { - y -= amount; + m_Pos.y -= amount; amount = 0; } } @@ -399,7 +402,7 @@ void CObject::moveDown(int amount) { blockedr = blockedl = false; blockedu = blockedd = false; - y += amount; + m_Pos.y += amount; return; } @@ -410,12 +413,12 @@ void CObject::moveDown(int amount) { if(amount > (1<<STC)) { - y += (1<<STC); + m_Pos.y += (1<<STC); amount -= (1<<STC); } else { - y += amount; + m_Pos.y += amount; amount = 0; } } @@ -458,21 +461,21 @@ void CObject::InertiaAndFriction_X() } unsigned int CObject::getXPosition() -{ return x; } +{ return m_Pos.x; } unsigned int CObject::getYPosition() -{ return y; } +{ return m_Pos.y; } unsigned int CObject::getXLeftPos() -{ return x+bboxX1; } +{ return m_Pos.x+bboxX1; } unsigned int CObject::getXRightPos() -{ return x+bboxX2; } +{ return m_Pos.x+bboxX2; } unsigned int CObject::getXMidPos() -{ return x+(bboxX2-bboxX1)/2; } +{ return m_Pos.x+(bboxX2-bboxX1)/2; } unsigned int CObject::getYUpPos() -{ return y+bboxY1; } +{ return m_Pos.y+bboxY1; } unsigned int CObject::getYDownPos() -{ return y+bboxY2; } +{ return m_Pos.y+bboxY2; } unsigned int CObject::getYMidPos() -{ return y+(bboxY2-bboxY1)/2; } +{ return m_Pos.y+(bboxY2-bboxY1)/2; } /** @@ -637,8 +640,8 @@ void CObject::draw() CSprite &Sprite = g_pGfxEngine->getSprite(sprite); SDL_Surface *sfc = g_pVideoDriver->getBlitSurface(); - scrx = (x>>STC)-mp_Map->m_scrollx; - scry = (y>>STC)-mp_Map->m_scrolly; + scrx = (m_Pos.x>>STC)-mp_Map->m_scrollx; + scry = (m_Pos.y>>STC)-mp_Map->m_scrolly; SDL_Rect gameres = g_pVideoDriver->getGameResolution(); diff --git a/src/common/CObject.h b/src/common/CObject.h index f6350e7..ebb0c10 100644 --- a/src/common/CObject.h +++ b/src/common/CObject.h @@ -110,6 +110,7 @@ public: bool checkforScenario(); // Moving parts + void moveToForce(const VectorD2<int> &dir); void moveToForce(int new_x, int new_y); void moveDir(const VectorD2<int> &dir); void moveTo(const VectorD2<Uint32> &new_loc); @@ -176,7 +177,7 @@ protected: Uint16 m_blinktime; bool m_invincible; - unsigned int x, y; // x,y location in map coords, CSFed + VectorD2<Uint32> m_Pos; // x,y location in map coords, CSFed, represent as 2D Vector static int m_number_of_objects; diff --git a/src/common/CObjectCollision.cpp b/src/common/CObjectCollision.cpp index f78945d..e28ee97 100644 --- a/src/common/CObjectCollision.cpp +++ b/src/common/CObjectCollision.cpp @@ -17,12 +17,12 @@ void CObject::performCollisionsSameBox() { // Left/Right borders - blockedl = checkSolidL(x+bboxX1, x+bboxX2, y+bboxY1, y+bboxY2); - blockedr = checkSolidR(x+bboxX1, x+bboxX2, y+bboxY1, y+bboxY2); + blockedl = checkSolidL(m_Pos.x+bboxX1, m_Pos.x+bboxX2, m_Pos.y+bboxY1, m_Pos.y+bboxY2); + blockedr = checkSolidR(m_Pos.x+bboxX1, m_Pos.x+bboxX2, m_Pos.y+bboxY1, m_Pos.y+bboxY2); // Upper/Lower borders - blockedu = checkSolidU(x+bboxX1, x+bboxX2, y+bboxY1); - blockedd = checkSolidD(x+bboxX1, x+bboxX2, y+bboxY2); + blockedu = checkSolidU(m_Pos.x+bboxX1, m_Pos.x+bboxX2, m_Pos.y+bboxY1); + blockedd = checkSolidD(m_Pos.x+bboxX1, m_Pos.x+bboxX2, m_Pos.y+bboxY2); if(g_pBehaviorEngine->getEpisode() > 3) { // now check for the sloped tiles @@ -56,9 +56,9 @@ const int COLISION_RES = (1<<STC); void CObject::performCollisionOnSlopedTiles() { const Uint32 halftile = ((1<<CSF)/2); - const Uint32 x1 = x + bboxX1; - const Uint32 x2 = x + bboxX2; - const Uint32 y2 = y + bboxY2; + const Uint32 x1 = m_Pos.x + bboxX1; + const Uint32 x2 = m_Pos.x + bboxX2; + const Uint32 y2 = m_Pos.y + bboxY2; std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTileProperties(); onslope = false; @@ -133,8 +133,8 @@ void CObject::pushOutofSolidTiles() { if(onslope) { - const int px= (x+(bboxX1+bboxX2)/2); - const int py= (y+bboxY2+1); + const int px= (m_Pos.x+(bboxX1+bboxX2)/2); + const int py= (m_Pos.y+bboxY2+1); std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTileProperties(); const char slope = TileProperty[mp_Map->at(px>>CSF, py>>CSF)].bup; @@ -147,7 +147,7 @@ void CObject::pushOutofSolidTiles() const int yh = yb1 + dy; if( py%512 > yh ) - y -= ((py%512) - yh); + m_Pos.y -= ((py%512) - yh); } } } @@ -222,14 +222,14 @@ bool CObject::moveSlopedTileDown( int x, int y, int xspeed ) if( x_r >= 480 && ( yb1>yb2 ) ) // At Tile edge { new_y = (new_y>>CSF)<<CSF; - dy = this->y - (new_y+yb2); + dy = m_Pos.y - (new_y+yb2); moveUp( dy ); moveRight( dy ); } else // In the Tile itself or walking into... { - moveYDir( new_y - this->y ); + moveYDir( new_y - m_Pos.y ); } } else if(xspeed < 0) // Going left @@ -238,13 +238,13 @@ bool CObject::moveSlopedTileDown( int x, int y, int xspeed ) if( x_r <= 32 && ( yb1<yb2 ) ) // At Tile edge { new_y = (new_y>>CSF)<<CSF; - dy = (new_y+yb1) - this->y; + dy = (new_y+yb1) - m_Pos.y; moveYDir( dy ); moveLeft( dy ); } else // In the Tile itself or walking into... { - moveYDir( new_y - this->y ); + moveYDir( new_y - m_Pos.y ); } } return true; @@ -305,7 +305,7 @@ void CObject::moveSlopedTileUp( int x, int y, int xspeed ) // get new position const Uint32 new_y = y_pos - bboxY1 + (1<<STC); - moveYDir( new_y - this->y ); + moveYDir( new_y - m_Pos.y ); } // returns nonzero if object1 overlaps object2 @@ -315,16 +315,16 @@ bool CObject::hitdetect(CObject &hitobject) unsigned int rect2x1, rect2y1, rect2x2, rect2y2; // get the bounding rectangle of the first object - rect1x1 = x + bboxX1; - rect1y1 = y + bboxY1; - rect1x2 = x + bboxX2; - rect1y2 = y + bboxY2; + rect1x1 = m_Pos.x + bboxX1; + rect1y1 = m_Pos.y + bboxY1; + rect1x2 = m_Pos.x + bboxX2; + rect1y2 = m_Pos.y + bboxY2; // get the bounding rectangle of the second object - rect2x1 = hitobject.x + hitobject.bboxX1; - rect2y1 = hitobject.y + hitobject.bboxY1; - rect2x2 = hitobject.x + hitobject.bboxX2; - rect2y2 = hitobject.y + hitobject.bboxY2; + rect2x1 = hitobject.getXPosition() + hitobject.bboxX1; + rect2y1 = hitobject.getYPosition() + hitobject.bboxY1; + rect2x2 = hitobject.getXPosition() + hitobject.bboxX2; + rect2y2 = hitobject.getYPosition() + hitobject.bboxY2; // find out if the rectangles overlap if ((rect1x1 <= rect2x1) && (rect1x2 <= rect2x1)) return false; diff --git a/src/common/CPlane.cpp b/src/common/CPlane.cpp index daaf251..cc3de6f 100644 --- a/src/common/CPlane.cpp +++ b/src/common/CPlane.cpp @@ -31,6 +31,7 @@ word CPlane::getMapDataAt(Uint16 x, Uint16 y) { if( x < m_width && y < m_height ) return mp_data[y*m_width+x]; + return 0; } void CPlane::setMapDataAt(Uint16 t, Uint16 x, Uint16 y) diff --git a/src/common/CPlayer.cpp b/src/common/CPlayer.cpp index be95801..47763ea 100644 --- a/src/common/CPlayer.cpp +++ b/src/common/CPlayer.cpp @@ -68,7 +68,6 @@ void CPlayer::setDatatoZero() performCollisions(); m_type = OBJ_PLAYER; - moveTo(0,0); ankhtime = 0; exists = true; onscreen = true; diff --git a/src/engine/CCamera.cpp b/src/engine/CCamera.cpp index b2af636..a1c3a87 100644 --- a/src/engine/CCamera.cpp +++ b/src/engine/CCamera.cpp @@ -72,15 +72,15 @@ void CCamera::process() } else { - if(mp_AttachedObject->getXPosition() > x) - moveRight(mp_AttachedObject->getXPosition() - x ); - else if(mp_AttachedObject->getXPosition() < x) - moveLeft(x - mp_AttachedObject->getXPosition()); - - if(mp_AttachedObject->getYPosition() > y) - moveDown(mp_AttachedObject->getYPosition() - y); - else if(mp_AttachedObject->getYPosition() < y) - moveUp(y - mp_AttachedObject->getYPosition()); + if(mp_AttachedObject->getXPosition() > getXPosition()) + moveRight(mp_AttachedObject->getXPosition() - getXPosition() ); + else if(mp_AttachedObject->getXPosition() < getXPosition()) + moveLeft(getXPosition() - mp_AttachedObject->getXPosition()); + + if(mp_AttachedObject->getYPosition() > getYPosition()) + moveDown(mp_AttachedObject->getYPosition() - getYPosition()); + else if(mp_AttachedObject->getYPosition() < getYPosition()) + moveUp(getYPosition() - mp_AttachedObject->getYPosition()); } diff --git a/src/engine/galaxy/ai/CPlayerLevel.cpp b/src/engine/galaxy/ai/CPlayerLevel.cpp index 4ffc685..b635488 100644 --- a/src/engine/galaxy/ai/CPlayerLevel.cpp +++ b/src/engine/galaxy/ai/CPlayerLevel.cpp @@ -25,7 +25,8 @@ CObject(pmap, x, y, OBJ_NONE), m_animation(0), m_animation_time(1), m_animation_ticker(0), -m_ObjectPtrs(ObjectPtrs) +m_ObjectPtrs(ObjectPtrs), +m_cliff_hanging(false) { m_index = 0; m_direction = facedir; @@ -216,15 +217,30 @@ void CPlayerLevel::processMoving() // Normal moving if(!m_playcontrol[PA_FIRE]) { - if( m_playcontrol[PA_X]<0 && !blockedl) + if( m_playcontrol[PA_X]<0 ) { - xinertia = -movespeed; - m_direction = LEFT; + if(!blockedl) + { + // make him walk + xinertia = -movespeed; + m_direction = LEFT; + } + else + { + // TODO: check if keen can hang on the cliff + } } - else if( m_playcontrol[PA_X]>0 && !blockedr) + else if( m_playcontrol[PA_X]>0) { - xinertia = movespeed; - m_direction = RIGHT; + if(!blockedr) + { + xinertia = movespeed; + m_direction = RIGHT; + } + else + { + // TODO: check if keen can hang on the cliff + } } Uint16 l_x = ( getXLeftPos() + getXRightPos() ) / 2; @@ -247,7 +263,7 @@ void CPlayerLevel::processMoving() if(m_direction == RIGHT) x_pole -= 6<<STC; - moveTo(x_pole, getYPosition()); + moveTo(VectorD2<int>(x_pole, getYPosition())); xinertia = 0; } } diff --git a/src/engine/galaxy/ai/CPlayerLevel.h b/src/engine/galaxy/ai/CPlayerLevel.h index f465181..d8b8588 100644 --- a/src/engine/galaxy/ai/CPlayerLevel.h +++ b/src/engine/galaxy/ai/CPlayerLevel.h @@ -78,6 +78,7 @@ private: bool m_pfiring; int m_jumpheight; + bool m_cliff_hanging; }; } diff --git a/src/engine/galaxy/ai/CPlayerWM.cpp b/src/engine/galaxy/ai/CPlayerWM.cpp index 4a09b36..fe64735 100644 --- a/src/engine/galaxy/ai/CPlayerWM.cpp +++ b/src/engine/galaxy/ai/CPlayerWM.cpp @@ -155,7 +155,7 @@ void CPlayerWM::finishLevel(Uint16 object) if(mp_Map->findTile(flag_dest, &x, &y, 2)) { // spawn the flag - VectorD2<Uint32> src(this->x, this->y); + VectorD2<Uint32> src(getXPosition(), getYPosition()); VectorD2<Uint32> dst((x<<CSF), (y<<CSF)); CFlag *pFlag = new CFlag(mp_Map, src, dst); diff --git a/src/engine/vorticon/ai/CBallJack.cpp b/src/engine/vorticon/ai/CBallJack.cpp index 6b11fc0..2b1b47d 100644 --- a/src/engine/vorticon/ai/CBallJack.cpp +++ b/src/engine/vorticon/ai/CBallJack.cpp @@ -135,6 +135,7 @@ void CBallJack::getShotByRay() { case DUPRIGHT: m_Direction = DUPLEFT; break; case DDOWNRIGHT: m_Direction = DDOWNLEFT; break; + default : break; } } else @@ -143,6 +144,7 @@ void CBallJack::getShotByRay() { case DUPLEFT: m_Direction = DUPRIGHT; break; case DDOWNLEFT: m_Direction = DDOWNRIGHT; break; + default : break; } } } diff --git a/src/engine/vorticon/ai/CFireBall.cpp b/src/engine/vorticon/ai/CFireBall.cpp index ea79f13..0f067d1 100644 --- a/src/engine/vorticon/ai/CFireBall.cpp +++ b/src/engine/vorticon/ai/CFireBall.cpp @@ -1,5 +1,5 @@ #include "CFireBall.h" -#include "../../../sdl/sound/CSound.h" +#include "sdl/sound/CSound.h" // fireball projectile shot out by Vorticon Mother (Ep3) @@ -22,7 +22,8 @@ CRay(p_map, x, y, dir, byType, byID) blockedl = blockedr = 0; canbezapped = 1; if(dir == LEFT) - this->x-=(14<<STC); + m_Pos -= VectorD2<Uint32>(14<<STC,0); + m_speed = (mp_Map->m_Difficulty>1) ? FIREBALL_HARD_SPEED : FIREBALL_SPEED; sprite = (m_Direction == RIGHT) ? FIREBALL_RIGHT_FRAME : FIREBALL_LEFT_FRAME; performCollisions(); diff --git a/src/engine/vorticon/ai/CMessie.cpp b/src/engine/vorticon/ai/CMessie.cpp index a33eafc..b6076c2 100644 --- a/src/engine/vorticon/ai/CMessie.cpp +++ b/src/engine/vorticon/ai/CMessie.cpp @@ -76,7 +76,7 @@ void CMessie::process() { if (mounted[it_player->m_index]) { - it_player->moveTo(x, y); + it_player->moveTo(m_Pos); isMounted = true; } } @@ -96,17 +96,17 @@ void CMessie::process() { case NESSIE_SWIMNORMAL: // arrived at destination? - if ( x > (destx-NESSIE_SPEED/2) && - x < (destx+NESSIE_SPEED/2) ) + if ( getXPosition() > (destx-NESSIE_SPEED/2) && + getXPosition() < (destx+NESSIE_SPEED/2) ) { - if ( y > (desty-NESSIE_SPEED/2) && - y < (desty+NESSIE_SPEED/2) ) + if ( getYPosition() > (desty-NESSIE_SPEED/2) && + getYPosition() < (desty+NESSIE_SPEED/2) ) { nessie_find_next_checkpoint(); // set up/down and left/right direction flags for frame selection - bool goleft = (destx < x); - bool godown = (desty > y); + bool goleft = (destx < getXPosition()); + bool godown = (desty > getYPosition()); if(goleft && !godown) m_direction = LEFTUP; @@ -147,14 +147,14 @@ void CMessie::move_nessie() baseframe = NESSIE_UPRIGHT_FRAME; // head to destination - if (x < destx) + if (getXPosition() < destx) moveRight(NESSIE_SPEED); - else if (x > destx) + else if (getXPosition() > destx) moveLeft(NESSIE_SPEED); - if (y < desty) + if (getYPosition() < desty) moveDown(NESSIE_SPEED); - else if (y > desty) + else if (getYPosition() > desty) moveUp(NESSIE_SPEED); } diff --git a/src/engine/vorticon/ai/CRay.cpp b/src/engine/vorticon/ai/CRay.cpp index b23195a..91f9a69 100644 --- a/src/engine/vorticon/ai/CRay.cpp +++ b/src/engine/vorticon/ai/CRay.cpp @@ -25,9 +25,6 @@ m_speed(speed) else if(Episode == 2) sprite = OBJ_RAY_DEFSPRITE_EP2; else if(Episode == 3) sprite = OBJ_RAY_DEFSPRITE_EP3; - this->x=x; - this->y=y; - CSprite &rSprite = g_pGfxEngine->getSprite(sprite); bboxX1 = rSprite.m_bboxX1; bboxX2 = rSprite.m_bboxX2; bboxY1 = rSprite.m_bboxY1; bboxY2 = rSprite.m_bboxY2; @@ -113,9 +110,9 @@ void CRay::moveinAir() { // don't go through bonklethal tiles, even if they're not solid // (for the arms on mortimer's machine) - if (TileProperties.at(mp_Map->at(((x>>(CSF-4))+raysprite.getWidth())>>4, (y>>CSF)+1)).behaviour == 1) + if (TileProperties.at(mp_Map->at(((getXPosition()>>(CSF-4))+raysprite.getWidth())>>4, (getYPosition()>>CSF)+1)).behaviour == 1) hitlethal = true; - else if (TileProperties.at(mp_Map->at(((x>>(CSF-4))+raysprite.getWidth())>>4, ((y>>(CSF-4))+(raysprite.getHeight()-1))>>(CSF-4))).behaviour == 1) + else if (TileProperties.at(mp_Map->at(((getXPosition()>>(CSF-4))+raysprite.getWidth())>>4, ((getYPosition()>>(CSF-4))+(raysprite.getHeight()-1))>>(CSF-4))).behaviour == 1) hitlethal = true; else hitlethal = false; @@ -131,9 +128,9 @@ void CRay::moveinAir() } else if (m_Direction == LEFT) { - if (TileProperties.at(mp_Map->at((x-1)>>CSF, (y+1)>>CSF)).behaviour == 1) + if (TileProperties.at(mp_Map->at((getXPosition()-1)>>CSF, (getYPosition()+1)>>CSF)).behaviour == 1) hitlethal = true; - else if (TileProperties.at(mp_Map->at((x-1)>>CSF, ((y>>(CSF-4))+(raysprite.getHeight()-1))>>(CSF-4))).behaviour == 1) + else if (TileProperties.at(mp_Map->at((getXPosition()-1)>>CSF, ((getYPosition()>>(CSF-4))+(raysprite.getHeight()-1))>>(CSF-4))).behaviour == 1) hitlethal = true; else hitlethal = false; diff --git a/src/engine/vorticon/ai/CRay.h b/src/engine/vorticon/ai/CRay.h index 7ceba47..8eb532a 100644 --- a/src/engine/vorticon/ai/CRay.h +++ b/src/engine/vorticon/ai/CRay.h @@ -6,9 +6,9 @@ #define RAY_AUTO_SPEED 120 #define RAY_ZAPZOT_TIME 10 -#include "../../../common/CObject.h" -#include "../../../common/CPlayer.h" -#include "../../../common/objenums.h" +#include "common/CObject.h" +#include "common/CPlayer.h" +#include "common/objenums.h" #include <vector> // reference to ../misc.cpp diff --git a/src/engine/vorticon/ai/CSectorEffector.cpp b/src/engine/vorticon/ai/CSectorEffector.cpp index 2337f2d..386c23a 100644 --- a/src/engine/vorticon/ai/CSectorEffector.cpp +++ b/src/engine/vorticon/ai/CSectorEffector.cpp @@ -282,7 +282,7 @@ void CSectorEffector::se_mortimer_spark() { set_mortimer_surprised(true); g_pGfxEngine->pushEffectPtr(new CVibrate(200)); - mp_Map->redrawAt(this->x>>CSF, this->y>>CSF); + mp_Map->redrawAt(getXPosition()>>CSF, getYPosition()>>CSF); // if there are any sparks left, destroy the spark, // else destroy mortimer's arms diff --git a/src/engine/vorticon/ai/CTeleporter.cpp b/src/engine/vorticon/ai/CTeleporter.cpp index d0b46b6..4b74e68 100644 --- a/src/engine/vorticon/ai/CTeleporter.cpp +++ b/src/engine/vorticon/ai/CTeleporter.cpp @@ -105,7 +105,7 @@ void CTeleporter::process() // In this part the player must be invisible and go to the new position, then get teleported out. x = destx<<CSF; y = desty<<CSF; - moveTo(x, y); + moveTo(VectorD2<int>(x, y)); m_Player[player].pdir = DOWN; m_Player[player].beingteleported = true; m_Player[player].solid = false; @@ -133,7 +133,7 @@ void CTeleporter::process() if(!m_Player[player].scrollTriggers() && diff_x<=TELEPORTATION_SPEED && diff_y<=TELEPORTATION_SPEED) { - m_Player[player].moveTo(x, y); + m_Player[player].moveTo(VectorD2<int>(x, y)); direction = TELEPORTING_OUT; idleframe = mp_Map->at(x>>CSF, y>>CSF); diff --git a/src/engine/vorticon/finale/CEndingEp1.cpp b/src/engine/vorticon/finale/CEndingEp1.cpp index 8e6c621..86c3c47 100644 --- a/src/engine/vorticon/finale/CEndingEp1.cpp +++ b/src/engine/vorticon/finale/CEndingEp1.cpp @@ -55,7 +55,7 @@ void CEndingEp1::ReturnsToShip() // draw keen next to his ship m_Player[0].hideplayer = false; m_Player[0].solid = false; - m_Player[0].moveTo(6636, 19968); + m_Player[0].moveTo(VectorD2<int>(6636, 19968)); m_Player[0].sprite = PMAPLEFTFRAME; while(m_Player[0].scrollTriggers()); // Scroll the map to players position @@ -90,7 +90,7 @@ void CEndingEp1::ShipFlyMarsToEarth() MapLoader.load(1, 81, path); m_Player[0].hideplayer = false; - m_Player[0].moveTo(6<<CSF, 5<<CSF); + m_Player[0].moveTo(VectorD2<int>(6<<CSF, 5<<CSF)); mp_ShipFlySys = new CShipFlySys( m_Player[0], &m_Map, SPR_SHIP_RIGHT, SPR_SHIP_LEFT); @@ -196,7 +196,7 @@ void CEndingEp1::ShipFlyEarthToMShip() m_Player[0].hideplayer = false; x = 48<<CSF; y = 23<<CSF; - m_Player[0].moveTo(x,y); + m_Player[0].moveTo(VectorD2<int>(x,y)); m_Map.gotoPos((x>>STC)-100, (y>>STC)-160); diff --git a/src/engine/vorticon/finale/CEndingEp2.cpp b/src/engine/vorticon/finale/CEndingEp2.cpp index b93de7c..484f271 100644 --- a/src/engine/vorticon/finale/CEndingEp2.cpp +++ b/src/engine/vorticon/finale/CEndingEp2.cpp @@ -71,7 +71,7 @@ void CEndingEp2::HeadsForEarth() int x, y; m_Map.findTile(593, &x, &y); - m_Player[0].moveTo(x<<CSF, y<<CSF); + m_Player[0].moveTo(VectorD2<int>(x<<CSF, y<<CSF)); mp_Textbox = new CMessageBox(g_pBehaviorEngine->getString("EP2_ESEQ_PART1"), true); @@ -113,7 +113,7 @@ void CEndingEp2::LimpsHome() MapLoader.load(2, 81, path); m_Player[0].hideplayer = false; - m_Player[0].moveTo(8<<CSF, 26<<CSF); + m_Player[0].moveTo(VectorD2<int>(8<<CSF, 26<<CSF)); m_Player[0].solid = false; mp_ShipFlySys = new CShipFlySys( m_Player[0], &m_Map, SPR_VORTICON_MOTHERSHIP, SPR_VORTICON_MOTHERSHIP ); diff --git a/src/engine/vorticon/finale/CEndingEp3.cpp b/src/engine/vorticon/finale/CEndingEp3.cpp index 37eb9d8..971cbcd 100644 --- a/src/engine/vorticon/finale/CEndingEp3.cpp +++ b/src/engine/vorticon/finale/CEndingEp3.cpp @@ -52,7 +52,7 @@ void CEndingEp3::HonorScene() MapLoader.load(3, 81, path); m_Player[0].hideplayer = false; - m_Player[0].moveTo(244<<STC, 104<<STC); + m_Player[0].moveTo(VectorD2<int>(244<<STC, 104<<STC)); m_Player[0].sprite = 0; m_Map.gotoPos(32, 32); @@ -112,7 +112,7 @@ void CEndingEp3::PaparazziScene() m_step++; m_mustsetup = true; m_Player[0].hideplayer = true; - m_Player[0].moveToForce(330<<STC, 104<<STC); + m_Player[0].moveToForce(VectorD2<int>(330<<STC, 104<<STC)); m_Player[0].sprite = 0; } } diff --git a/src/engine/vorticon/finale/CShipFlySys.cpp b/src/engine/vorticon/finale/CShipFlySys.cpp index 7603fef..9172121 100644 --- a/src/engine/vorticon/finale/CShipFlySys.cpp +++ b/src/engine/vorticon/finale/CShipFlySys.cpp @@ -90,7 +90,7 @@ void CShipFlySys::process() x = m_player.getXPosition(); y = m_player.getYPosition(); - mp_mark->moveTo(x + (1<<CSF), y - (1<<CSF)); + mp_mark->moveTo(VectorD2<int>(x + (1<<CSF), y - (1<<CSF))); break; case CMD_SPAWNSPR: mp_mark->sprite = m_shipqueue[m_ShipQueuePtr].flag1; diff --git a/src/engine/vorticon/playgame/CPlayGameGameState.cpp b/src/engine/vorticon/playgame/CPlayGameGameState.cpp index df369e5..79ad382 100644 --- a/src/engine/vorticon/playgame/CPlayGameGameState.cpp +++ b/src/engine/vorticon/playgame/CPlayGameGameState.cpp @@ -78,7 +78,7 @@ bool CPlayGameVorticon::loadGameState() player->setupforLevelPlay(); m_SavedGame.decodeData(x); m_SavedGame.decodeData(y); - player->moveToForce(x,y-(4<<STC)); + player->moveToForce(VectorD2<int>(x,y-(4<<STC))); m_SavedGame.decodeData(player->blockedd); m_SavedGame.decodeData(player->blockedu); m_SavedGame.decodeData(player->blockedl); @@ -105,7 +105,7 @@ bool CPlayGameVorticon::loadGameState() m_SavedGame.decodeData(object->m_type); m_SavedGame.decodeData(x); m_SavedGame.decodeData(y); - object->moveToForce(x,y); + object->moveToForce(VectorD2<int>(x,y)); m_SavedGame.decodeData(object->dead); m_SavedGame.decodeData(object->onscreen); m_SavedGame.decodeData(object->hasbeenonscreen); diff --git a/src/engine/vorticon/playgame/CPlayGameLevel.cpp b/src/engine/vorticon/playgame/CPlayGameLevel.cpp index 9c61fa1..11d2515 100644 --- a/src/engine/vorticon/playgame/CPlayGameLevel.cpp +++ b/src/engine/vorticon/playgame/CPlayGameLevel.cpp @@ -6,10 +6,10 @@ */ #include "CPlayGameVorticon.h" -#include "../ai/CSectorEffector.h" -#include "../../../common/objenums.h" -#include "../../../sdl/sound/CSound.h" -#include "../finale/CTantalusRay.h" +#include "engine/vorticon/ai/CSectorEffector.h" +#include "common/objenums.h" +#include "sdl/sound/CSound.h" +#include "engine/vorticon/finale/CTantalusRay.h" void CPlayGameVorticon::processInLevel() { hooks/post-receive -- clonekeenplus |