Commit 6e631c48 authored by AlisterT's avatar AlisterT

Bug fixes.

parent 5421b4d6
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#define CONTROLS 11 #define CONTROLS 11
// Time interval // Time interval
#define T_KEY 500 #define T_KEY 200
// Class // Class
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -537,7 +537,7 @@ void WaterPaletteEffect::apply (SDL_Color *shownPalette, bool direct, ...@@ -537,7 +537,7 @@ void WaterPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
if (next) next->apply(shownPalette, direct, mspf); if (next) next->apply(shownPalette, direct, mspf);
position = localPlayer->getY() - level->getWaterLevel(0); position = localPlayer->getY() - level->getWaterLevel();
if (position <= 0) return; if (position <= 0) return;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -63,7 +63,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) { ...@@ -63,7 +63,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
SDL_MixAudio(stream, SDL_MixAudio(stream,
sounds[count].data + sounds[count].position, len, sounds[count].data + sounds[count].position, len,
SDL_MIX_MAXVOLUME >> 1); SDL_MIX_MAXVOLUME >> 2);
sounds[count].position += len; sounds[count].position += len;
...@@ -74,7 +74,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) { ...@@ -74,7 +74,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
SDL_MixAudio(stream, SDL_MixAudio(stream,
sounds[count].data + sounds[count].position, sounds[count].data + sounds[count].position,
sounds[count].length - sounds[count].position, sounds[count].length - sounds[count].position,
SDL_MIX_MAXVOLUME >> 1); SDL_MIX_MAXVOLUME >> 2);
sounds[count].position = -1; sounds[count].position = -1;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -202,7 +202,7 @@ bool Bullet::step (unsigned int ticks, int msps) { ...@@ -202,7 +202,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
// If the event is within range, hit it // If the event is within range, hit it
if (event->overlap(x - F160, y - F100, 2 * F160, 2 * F100)) if (event->overlap(x - F160, y - F100, 2 * F160, 2 * F100))
event->hit(source, ticks); event->hit(source, true, ticks);
event = event->getNext(); event = event->getNext();
...@@ -245,7 +245,7 @@ bool Bullet::step (unsigned int ticks, int msps) { ...@@ -245,7 +245,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
if (event->overlap(x, y, 0, 0)) { if (event->overlap(x, y, 0, 0)) {
// If the event is hittable, hit it and destroy the bullet // If the event is hittable, hit it and destroy the bullet
if (event->hit(source, ticks)) return true; if (event->hit(source, false, ticks)) return true;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -43,11 +43,14 @@ ...@@ -43,11 +43,14 @@
Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) { Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) {
x = TTOF(gX);
y = TTOF(gY + 1);
dx = 0;
dy = 0;
next = nextEvent; next = nextEvent;
gridX = gX; gridX = gX;
gridY = gY; gridY = gY;
x = TTOF(gX);
y = TTOF(gY + 1);
flashTime = 0; flashTime = 0;
// Choose initial settings // Choose initial settings
...@@ -56,6 +59,7 @@ Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) { ...@@ -56,6 +59,7 @@ Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) {
case 21: // Destructible block case 21: // Destructible block
case 25: // Float up / Belt case 25: // Float up / Belt
case 37: // Sucker tubes
case 38: // Sucker tubes case 38: // Sucker tubes
case 40: // Monochrome case 40: // Monochrome
case 57: // Bubbles case 57: // Bubbles
...@@ -141,15 +145,17 @@ void Event::destroy (unsigned int ticks) { ...@@ -141,15 +145,17 @@ void Event::destroy (unsigned int ticks) {
} }
bool Event::hit (Player *source, unsigned int ticks) { bool Event::hit (Player *source, bool TNT, unsigned int ticks) {
int hitsRemaining; int hitsRemaining;
// Deal with bullet collisions // Deal with bullet collisions
// Check if event has already been destroyed
if ((animType == E_LFINISHANIM) || (animType == E_RFINISHANIM) || if ((animType == E_LFINISHANIM) || (animType == E_RFINISHANIM) ||
(ticks < flashTime)) return false; (ticks < flashTime)) return false;
hitsRemaining = level->hitEvent(source, gridX, gridY); hitsRemaining = level->hitEvent(gridX, gridY, source, TNT);
// If the event cannot be hit, do not register hit // If the event cannot be hit, do not register hit
if (hitsRemaining < 0) return false; if (hitsRemaining < 0) return false;
...@@ -177,28 +183,27 @@ fixed Event::getWidth () { ...@@ -177,28 +183,27 @@ fixed Event::getWidth () {
fixed width; fixed width;
if (animType && (getProperty(animType) >= 0)) { if (!animType) return F32;
width = ITOF(level->getAnim(getProperty(animType))->getWidth());
// Blank sprites for e.g. invisible springs if (getProperty(animType) <= 0) return 0;
if ((width == F1) && (getHeight() == F1)) return F32;
return width; width = ITOF(level->getAnim(getProperty(animType))->getWidth());
} // Blank sprites for e.g. invisible springs
if ((width == F1) && (getHeight() == F1)) return F32;
return F32; return width;
} }
fixed Event::getHeight () { fixed Event::getHeight () {
if (animType && (getProperty(animType) >= 0)) if (!animType) return F32;
return ITOF(level->getAnim(getProperty(animType))->getHeight());
if (getProperty(animType) <= 0) return 0;
return F32; return ITOF(level->getAnim(getProperty(animType))->getHeight());
} }
......
...@@ -94,7 +94,7 @@ class Event : public Movable { ...@@ -94,7 +94,7 @@ class Event : public Movable {
Event * getNext (); Event * getNext ();
void removeNext (); void removeNext ();
bool hit (Player *source, unsigned int ticks); bool hit (Player *source, bool TNT, unsigned int ticks);
bool isFrom (unsigned char gX, unsigned char gY); bool isFrom (unsigned char gX, unsigned char gY);
fixed getWidth (); fixed getWidth ();
fixed getHeight (); fixed getHeight ();
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -272,7 +272,7 @@ void Level::clearEvent (unsigned char gridX, unsigned char gridY) { ...@@ -272,7 +272,7 @@ void Level::clearEvent (unsigned char gridX, unsigned char gridY) {
} }
int Level::hitEvent (Player *source, unsigned char gridX, unsigned char gridY) { int Level::hitEvent (unsigned char gridX, unsigned char gridY, Player *source, bool TNT) {
GridElement *ge; GridElement *ge;
unsigned char buffer[MTL_L_GRID]; unsigned char buffer[MTL_L_GRID];
...@@ -286,7 +286,8 @@ int Level::hitEvent (Player *source, unsigned char gridX, unsigned char gridY) { ...@@ -286,7 +286,8 @@ int Level::hitEvent (Player *source, unsigned char gridX, unsigned char gridY) {
if (!hitsToKill) return -1; if (!hitsToKill) return -1;
// Increase the hit count // Increase the hit count
ge->hits++; if (TNT) ge->hits = hitsToKill;
else ge->hits++;
// Check if the event has been killed // Check if the event has been killed
if (ge->hits == hitsToKill) { if (ge->hits == hitsToKill) {
...@@ -389,7 +390,7 @@ void Level::setWaterLevel (unsigned char gridY) { ...@@ -389,7 +390,7 @@ void Level::setWaterLevel (unsigned char gridY) {
unsigned char buffer[MTL_L_PROP]; unsigned char buffer[MTL_L_PROP];
waterLevel = TTOF(gridY); waterLevelTarget = TTOF(gridY);
if (gameMode) { if (gameMode) {
...@@ -407,10 +408,9 @@ void Level::setWaterLevel (unsigned char gridY) { ...@@ -407,10 +408,9 @@ void Level::setWaterLevel (unsigned char gridY) {
} }
fixed Level::getWaterLevel (int phase) { fixed Level::getWaterLevel () {
if (phase & 1024) return waterLevel - ((phase & 1023) * 32); return waterLevel;
return waterLevel - ((1024 - (phase & 1023)) * 32);
} }
...@@ -475,7 +475,7 @@ void Level::receive (unsigned char *buffer) { ...@@ -475,7 +475,7 @@ void Level::receive (unsigned char *buffer) {
} else if (buffer[2] == 1) { } else if (buffer[2] == 1) {
waterLevel = TTOF(buffer[3]); waterLevelTarget = TTOF(buffer[3]);
} else if (buffer[2] == 2) { } else if (buffer[2] == 2) {
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -118,6 +118,8 @@ class Level { ...@@ -118,6 +118,8 @@ class Level {
unsigned int endTime; unsigned int endTime;
int enemies, items; int enemies, items;
fixed waterLevel; fixed waterLevel;
fixed waterLevelTarget;
fixed waterLevelSpeed;
fixed energyBar; fixed energyBar;
int stage; int stage;
...@@ -148,23 +150,20 @@ class Level { ...@@ -148,23 +150,20 @@ class Level {
bool checkMaskDown (fixed x, fixed y); bool checkMaskDown (fixed x, fixed y);
bool checkSpikes (fixed x, fixed y); bool checkSpikes (fixed x, fixed y);
void setNext (int nextLevel, int nextWorld); void setNext (int nextLevel, int nextWorld);
void setTile (unsigned char gridX, unsigned char gridY, void setTile (unsigned char gridX, unsigned char gridY, unsigned char tile);
unsigned char tile);
signed char * getEvent (unsigned char gridX, unsigned char gridY); signed char * getEvent (unsigned char gridX, unsigned char gridY);
unsigned char getEventHits (unsigned char gridX, unsigned char gridY); unsigned char getEventHits (unsigned char gridX, unsigned char gridY);
unsigned int getEventTime (unsigned char gridX, unsigned char gridY); unsigned int getEventTime (unsigned char gridX, unsigned char gridY);
void clearEvent (unsigned char gridX, unsigned char gridY); void clearEvent (unsigned char gridX, unsigned char gridY);
int hitEvent (Player *source, unsigned char gridX, int hitEvent (unsigned char gridX, unsigned char gridY, Player *source, bool TNT);
unsigned char gridY); void setEventTime (unsigned char gridX, unsigned char gridY, unsigned int time);
void setEventTime (unsigned char gridX, unsigned char gridY,
unsigned int time);
signed char * getBullet (unsigned char bullet); signed char * getBullet (unsigned char bullet);
Sprite * getSprite (unsigned char sprite); Sprite * getSprite (unsigned char sprite);
Anim * getAnim (unsigned char anim); Anim * getAnim (unsigned char anim);
Anim * getMiscAnim (unsigned char anim); Anim * getMiscAnim (unsigned char anim);
void addTimer (); void addTimer ();
void setWaterLevel (unsigned char gridY); void setWaterLevel (unsigned char gridY);
fixed getWaterLevel (int phase); fixed getWaterLevel ();
void playSound (int sound); void playSound (int sound);
void setStage (int stage); void setStage (int stage);
int getStage (); int getStage ();
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -133,6 +133,14 @@ int Level::step () { ...@@ -133,6 +133,14 @@ int Level::step () {
} }
// Handle change in water level
if (waterLevel < waterLevelTarget) waterLevelSpeed += 100 * msps;
else waterLevelSpeed -= 100 * msps;
if (waterLevelSpeed > 40000) waterLevelSpeed = 40000;
if (waterLevelSpeed < -40000) waterLevelSpeed = -40000;
waterLevel += (waterLevelSpeed * msps) >> 10;
return E_NONE; return E_NONE;
...@@ -303,8 +311,11 @@ void Level::draw () { ...@@ -303,8 +311,11 @@ void Level::draw () {
} }
// Uncomment the following for a line showing the water level // Temporary lines showing the water level
/* drawRect(0, FTOI(getWaterLevel(ticks) - viewY), screenW, 2, 24); */ drawRect(0, FTOI(waterLevel - viewY), screenW, 2, 24);
drawRect(0, FTOI(waterLevel - viewY) + 3, screenW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY) + 6, screenW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY) + 10, screenW, 1, 24);
SDL_SetClipRect(screen, NULL); SDL_SetClipRect(screen, NULL);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -610,6 +610,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) { ...@@ -610,6 +610,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
grid[y][x].bg = buffer[((y + (x * LH)) << 1) + 1] >> 7; grid[y][x].bg = buffer[((y + (x * LH)) << 1) + 1] >> 7;
grid[y][x].event = buffer[((y + (x * LH)) << 1) + 1] & 127; grid[y][x].event = buffer[((y + (x * LH)) << 1) + 1] & 127;
grid[y][x].hits = 0; grid[y][x].hits = 0;
grid[y][x].time = 0;
} }
...@@ -823,9 +824,11 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) { ...@@ -823,9 +824,11 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
setNext(x, y); setNext(x, y);
// Thanks to Doubble Dutch for this next bit // Thanks to Doubble Dutch for the water level bytes
file->seek(4, false); file->seek(4, false);
waterLevel = ITOF(file->loadShort()); waterLevelTarget = ITOF(file->loadShort());
waterLevel = waterLevelTarget - F8;
waterLevelSpeed = 0;
// Thanks to Feline and the JCS94 team for the next bits: // Thanks to Feline and the JCS94 team for the next bits:
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -118,11 +118,11 @@ bool Bird::step (unsigned int ticks, int msps) { ...@@ -118,11 +118,11 @@ bool Bird::step (unsigned int ticks, int msps) {
} }
if (y > level->getWaterLevel(ticks) - F24) { if (y > level->getWaterLevel() - F24) {
// Always stay above water // Always stay above water
y = level->getWaterLevel(ticks) - F24; y = level->getWaterLevel() - F24;
dy = 0; dy = 0;
} else { } else {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -678,7 +678,7 @@ void Player::floatUp (signed char *newEvent, int speed) { ...@@ -678,7 +678,7 @@ void Player::floatUp (signed char *newEvent, int speed) {
void Player::belt (int speed) { void Player::belt (int speed) {
dx += speed * 160; dx += speed * 20;
return; return;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -98,11 +98,11 @@ ...@@ -98,11 +98,11 @@
#define T_WARP 1000 #define T_WARP 1000
// Player offsets // Player offsets
#define PXO_L (F12 - F10) #define PXO_MID F16
#define PXO_ML (F12 - F4) #define PXO_L (PXO_MID - F10)
#define PXO_MID F12 #define PXO_ML (PXO_MID - F4)
#define PXO_MR (F12 + F4) #define PXO_MR (PXO_MID + F4)
#define PXO_R (F12 + F10) #define PXO_R (PXO_MID + F10)
#define PYO_TOP (-F20) #define PYO_TOP (-F20)
#define PYO_MID (-F10) #define PYO_MID (-F10)
...@@ -176,7 +176,7 @@ class Player : public Movable { ...@@ -176,7 +176,7 @@ class Player : public Movable {
3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange */ 3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange */
bool floating; // false = normal, true = boarding/bird/etc. bool floating; // false = normal, true = boarding/bird/etc.
bool facing; bool facing;
unsigned int lookTime; /* Negative if looking up, positive if looking int lookTime; /* Negative if looking up, positive if looking
down, 0 if neither */ down, 0 if neither */
int reaction; int reaction;
unsigned int reactionTime; unsigned int reactionTime;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -153,7 +153,7 @@ void Player::control (unsigned int ticks, int msps) { ...@@ -153,7 +153,7 @@ void Player::control (unsigned int ticks, int msps) {
if (dy < -PXS_RUN) dy = -PXS_RUN; if (dy < -PXS_RUN) dy = -PXS_RUN;
if (dy > PXS_RUN) dy = PXS_RUN; if (dy > PXS_RUN) dy = PXS_RUN;
} else if (y > level->getWaterLevel(ticks)) { } else if (y + PYO_MID > level->getWaterLevel()) {
if (pcontrols[C_JUMP]) { if (pcontrols[C_JUMP]) {
...@@ -213,8 +213,8 @@ void Player::control (unsigned int ticks, int msps) { ...@@ -213,8 +213,8 @@ void Player::control (unsigned int ticks, int msps) {
jumpY = y - jumpHeight; jumpY = y - jumpHeight;
// Increase jump height if walking/running // Increase jump height if walking/running
if (dx < 0) jumpY += dx >> 4; if (dx < 0) jumpY += dx >> 3;
else if (dx > 0) jumpY -= dx >> 4; else if (dx > 0) jumpY -= dx >> 3;
event = NULL; event = NULL;
...@@ -248,9 +248,19 @@ void Player::control (unsigned int ticks, int msps) { ...@@ -248,9 +248,19 @@ void Player::control (unsigned int ticks, int msps) {
dy = (jumpY - y - F64) * 4; dy = (jumpY - y - F64) * 4;
// Avoid jumping to fast, unless caused by an event // Spring speed limit
if (!event && (dy < (ITOF(-92) - F64) * 4)) if (event && (event[E_MODIFIER] == 29)) {
dy = (ITOF(-92) - F64) * 4;
if ((event[E_MULTIPURPOSE] == 0) && (dy < PYS_JUMP))
dy = PYS_JUMP;
if ((event[E_MULTIPURPOSE] > 0) && (dy < event[E_MULTIPURPOSE] * -F20))
dy = event[E_MULTIPURPOSE] * -F20;
}
// Avoid jumping too fast, unless caused by an event
if (!event && (dy < PYS_JUMP)) dy = PYS_JUMP;
} else { } else {
...@@ -261,7 +271,8 @@ void Player::control (unsigned int ticks, int msps) { ...@@ -261,7 +271,8 @@ void Player::control (unsigned int ticks, int msps) {
} }
// Stop looking // Stop looking
if (!pcontrols[C_UP] && !pcontrols[C_DOWN]) lookTime = 0; if (!pcontrols[C_UP] && (lookTime < 0)) lookTime = 0;
if (!pcontrols[C_DOWN] && (lookTime > 0)) lookTime = 0;
} }
...@@ -534,22 +545,19 @@ void Player::view (unsigned int ticks, int mspf) { ...@@ -534,22 +545,19 @@ void Player::view (unsigned int ticks, int mspf) {
// Find new position // Find new position
viewX = x + F8 - (viewW << 9); viewX = x + F8 - (viewW << 9);
viewY = y - F24 - (viewH << 9);
if (!lookTime || (ticks < 1000 + lookTime) || (ticks < 1000 - lookTime)) { if ((lookTime > 0) && ((int)ticks > 1000 + lookTime)) {
viewY = y - F24 - (viewH << 9);
} else if (lookTime > 0) {
if (ticks < 2000 + lookTime) // Look down
viewY = y - F24 - (64 * (lookTime + 1000 - ticks)) - (viewH << 9); if ((int)ticks < 2000 + lookTime) viewY += 64 * (ticks - (1000 + lookTime));
else viewY = y + F64 - F24 - (viewH << 9); else viewY += F64;
} else { } else if ((lookTime < 0) && ((int)ticks > 1000 - lookTime)) {
if (ticks < 2000 - lookTime) // Look up
viewY = y - F24 - (64 * (lookTime - 1000 + ticks)) - (viewH << 9); if ((int)ticks < 2000 - lookTime) viewY -= 64 * (ticks - (1000 - lookTime));
else viewY = y - F64 - F24 - (viewH << 9); else viewY -= F64;
} }
...@@ -595,7 +603,7 @@ void Player::draw (unsigned int ticks, int change) { ...@@ -595,7 +603,7 @@ void Player::draw (unsigned int ticks, int change) {
(reactionTime - ticks > PRT_HURT - PRT_HURTANIM)) (reactionTime - ticks > PRT_HURT - PRT_HURTANIM))
anim = anims[facing? PA_RHURT: PA_LHURT]; anim = anims[facing? PA_RHURT: PA_LHURT];
else if (y > level->getWaterLevel(ticks)) else if (y + PYO_MID > level->getWaterLevel())
anim = anims[facing? PA_RSWIM: PA_LSWIM]; anim = anims[facing? PA_RSWIM: PA_LSWIM];
else if (floating) anim = anims[facing? PA_RBOARD: PA_LBOARD]; else if (floating) anim = anims[facing? PA_RBOARD: PA_LBOARD];
...@@ -639,12 +647,12 @@ void Player::draw (unsigned int ticks, int change) { ...@@ -639,12 +647,12 @@ void Player::draw (unsigned int ticks, int change) {
else if (pcontrols[C_FIRE]) else if (pcontrols[C_FIRE])
anim = anims[facing? PA_RSHOOT: PA_LSHOOT]; anim = anims[facing? PA_RSHOOT: PA_LSHOOT];
else if ((lookTime < 0) && (ticks > 1000 - lookTime)) else if ((lookTime < 0) && ((int)ticks > 1000 - lookTime))
anim = anims[PA_LOOKUP]; anim = anims[PA_LOOKUP];
else if (lookTime > 0) { else if (lookTime > 0) {
if (ticks < 1000 + lookTime) if ((int)ticks < 1000 + lookTime)
anim = anims[facing? PA_RCROUCH: PA_LCROUCH]; anim = anims[facing? PA_RCROUCH: PA_LCROUCH];
else anim = anims[PA_LOOKDOWN]; else anim = anims[PA_LOOKDOWN];
...@@ -691,6 +699,17 @@ void Player::draw (unsigned int ticks, int change) { ...@@ -691,6 +699,17 @@ void Player::draw (unsigned int ticks, int change) {
an->restorePalette(); an->restorePalette();
// Uncomment the following to see the area of the player
/*drawRect(FTOI(getDrawX(change) + PXO_L - viewX),
FTOI(getDrawY(change) + PYO_TOP - viewY),
FTOI(PXO_R - PXO_L),
FTOI(-PYO_TOP), 89);
drawRect(FTOI(getDrawX(change) + PXO_ML - viewX),
FTOI(getDrawY(change) + PYO_TOP - viewY),
FTOI(PXO_MR - PXO_ML),
FTOI(-PYO_TOP), 88);*/
if (reaction == PR_INVINCIBLE) { if (reaction == PR_INVINCIBLE) {
// Show invincibility stars // Show invincibility stars
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment