Commit fc173b53 authored by alistert's avatar alistert

Fixes, including event paths.

parent 59956ced
......@@ -164,8 +164,8 @@ bool Event::step (unsigned int ticks, int msps) {
case 6:
// Use the path from the level file
dx = TTOF(gridX) + F16 + (level->pathX[level->pathNode] << 9) - x;
dy = TTOF(gridY) + (level->pathY[level->pathNode] << 9) - y;
dx = TTOF(gridX) + F16 + (level->path[set[E_MULTIPURPOSE]].x[level->path[set[E_MULTIPURPOSE]].node] << 9) - x;
dy = TTOF(gridY) + (level->path[set[E_MULTIPURPOSE]].y[level->path[set[E_MULTIPURPOSE]].node] << 9) - y;
dx = ((dx << 10) / msps) * set[E_MOVEMENTSP];
dy = ((dy << 10) / msps) * set[E_MOVEMENTSP];
......@@ -607,9 +607,11 @@ bool Event::step (unsigned int ticks, int msps) {
// Use the path from the level file
count = level->path[set[E_MULTIPURPOSE]].node;
// Check movement direction
if ((level->pathNode < 3) ||
(level->pathX[level->pathNode] <= level->pathX[level->pathNode - 3]))
if ((count < 3) ||
(level->path[set[E_MULTIPURPOSE]].x[count] <= level->path[set[E_MULTIPURPOSE]].x[count - 3]))
animType = E_LEFTANIM;
else
animType = E_RIGHTANIM;
......
......@@ -80,6 +80,8 @@ Level::Level (char *fileName, unsigned char diff, bool checkpoint) {
Level::~Level () {
int count;
// Free all data
stopMusic();
......@@ -112,8 +114,12 @@ Level::~Level () {
}
delete[] pathX;
delete[] pathY;
for (count = 0; count < PATHS; count++) {
delete[] path[count].x;
delete[] path[count].y;
}
SDL_FreeSurface(tileSet);
......
......@@ -52,6 +52,7 @@
#define BULLETS 32
#define BLENGTH 20 /* Length of bullets, in bytes */
#define ANIMS 128
#define PATHS 16
#define TKEY 127 /* Tileset colour key */
// Stages
......@@ -73,7 +74,7 @@
#define TTOI(x) ((x) << 5)
// Datatype
// Datatypes
typedef struct {
......@@ -86,6 +87,15 @@ typedef struct {
} GridElement;
typedef struct {
short int *x;
short int *y;
unsigned char length;
unsigned char node;
} EventPath;
// Classes
......@@ -103,7 +113,7 @@ class Level {
Anim animSet[ANIMS];
char miscAnims[4];
signed char bulletSet[BULLETS][BLENGTH];
signed char eventSet[EVENTS][ELENGTH]; // Not all used
signed char eventSet[EVENTS][ELENGTH];
char mask[240][64]; // At most 240 tiles, all with 8 * 8 masks
GridElement grid[LH][LW]; // All levels are the same size
int soundMap[32];
......@@ -114,7 +124,6 @@ class Level {
int sprites;
int levelNum, worldNum, nextLevelNum, nextWorldNum;
unsigned char difficulty;
int pathLength;
unsigned int endTime;
int enemies, items;
fixed waterLevel;
......@@ -136,11 +145,9 @@ class Level {
void timeCalcs (bool paused);
public:
Event *firstEvent;
Bullet *firstBullet;
int *pathX;
int *pathY;
int pathNode;
Event *firstEvent;
Bullet *firstBullet;
EventPath path[PATHS];
Level ();
Level (char *fileName, unsigned char diff,
......
......@@ -110,7 +110,7 @@ int Level::step () {
// Process active events
pathNode = (ticks >> 5) % pathLength;
for (x = 0; x < PATHS; x++) path[x].node = (ticks >> 5) % path[x].length;
if (firstEvent) {
......
......@@ -666,17 +666,22 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
// Load special event path
buffer = file->loadRLE(8192);
pathLength = buffer[0] + (buffer[1] << 8);
pathNode = 0;
if (pathLength < 1) pathLength = 1;
pathX = new int[pathLength];
pathY = new int[pathLength];
buffer = file->loadRLE(PATHS << 9);
for (count = 0; count < pathLength; count++) {
for (type = 0; type < PATHS; type++) {
pathX[count] = ((signed char *)buffer)[(count << 1) + 3] << 2;
pathY[count] = ((signed char *)buffer)[(count << 1) + 2];
path[type].length = buffer[type << 9] + (buffer[(type << 9) + 1] << 8);
path[type].node = 0;
if (path[type].length < 1) path[type].length = 1;
path[type].x = new short int[path[type].length];
path[type].y = new short int[path[type].length];
for (count = 0; count < path[type].length; count++) {
path[type].x[count] = ((signed char *)buffer)[(type << 9) + (count << 1) + 3] << 2;
path[type].y[count] = ((signed char *)buffer)[(type << 9) + (count << 1) + 2] << 2;
}
}
......
......@@ -107,13 +107,13 @@ bool Bird::step (unsigned int ticks, int msps) {
// To the left of the player, so move right
if (dx < F160) dx += 400 * msps;
if (dx < F80) dx += 400 * msps;
} else {
// To the right of the player, so move left
if (dx > -F160) dx -= 400 * msps;
if (dx > -F80) dx -= 400 * msps;
}
......@@ -137,13 +137,13 @@ bool Bird::step (unsigned int ticks, int msps) {
// Above the player, so move downwards
if (dy < F160) dy += 400 * msps;
if (dy < F80) dy += 400 * msps;
} else {
// Below the player, so move upwards
if (dy > -F160) dy -= 400 * msps;
if (dy > -F80) dy -= 400 * msps;
}
......
......@@ -496,7 +496,17 @@ bool Player::touchEvent (unsigned char gridX, unsigned char gridY, unsigned int
jumpY = y - (8 * F16);
} else x += set[E_MAGNITUDE] * 20 * msps;
} else if (set[E_MAGNITUDE] < 0) {
if (!level->checkMaskDown(x + PXO_L + (set[E_MAGNITUDE] * 20 * msps), y + PYO_MID))
x += set[E_MAGNITUDE] * 20 * msps;
} else {
if (!level->checkMaskDown(x + PXO_R + (set[E_MAGNITUDE] * 20 * msps), y + PYO_MID))
x += set[E_MAGNITUDE] * 20 * msps;
}
break;
......
......@@ -235,7 +235,7 @@ void Player::control (unsigned int ticks, int msps) {
speed = level->getEvent(eventX, eventY)[E_MULTIPURPOSE] * -F20;
if (speed == 0) speed = PYS_JUMP;
if (speed >= 0) speed = PYS_JUMP;
if (dy < speed) dy = speed;
......
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