Start of map mirroring.
This commit is contained in:
parent
05e7fc7cad
commit
0c631edd09
|
@ -79,6 +79,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define MAP_TILE_OUTSIDE 255
|
#define MAP_TILE_OUTSIDE 255
|
||||||
#define MAP_TILE_MAX 256
|
#define MAP_TILE_MAX 256
|
||||||
|
|
||||||
|
/* for mirroring */
|
||||||
|
#define MAP_PIXEL_WIDTH (MAP_WIDTH * MAP_TILE_SIZE)
|
||||||
|
|
||||||
#define JUMP_POWER -12
|
#define JUMP_POWER -12
|
||||||
#define MAX_OXYGEN (FPS * 10)
|
#define MAX_OXYGEN (FPS * 10)
|
||||||
#define MAX_KEY_TYPES 8
|
#define MAX_KEY_TYPES 8
|
||||||
|
@ -144,6 +147,7 @@ enum
|
||||||
#define EF_NO_OBSERVE (2 << 18)
|
#define EF_NO_OBSERVE (2 << 18)
|
||||||
#define EF_BULLET_HIT (2 << 19)
|
#define EF_BULLET_HIT (2 << 19)
|
||||||
#define EF_CRUSHABLE (2 << 20)
|
#define EF_CRUSHABLE (2 << 20)
|
||||||
|
#define EF_MIRROR (2 << 21)
|
||||||
|
|
||||||
#define GRAVITY_POWER 0.5f
|
#define GRAVITY_POWER 0.5f
|
||||||
#define FRICTION 0.75f
|
#define FRICTION 0.75f
|
||||||
|
|
|
@ -705,6 +705,11 @@ static void load(cJSON *root)
|
||||||
world.bob->x = cJSON_GetObjectItem(root, "x")->valueint;
|
world.bob->x = cJSON_GetObjectItem(root, "x")->valueint;
|
||||||
world.bob->y = cJSON_GetObjectItem(root, "y")->valueint;
|
world.bob->y = cJSON_GetObjectItem(root, "y")->valueint;
|
||||||
world.bob->facing = lookup(cJSON_GetObjectItem(root, "facing")->valuestring);
|
world.bob->facing = lookup(cJSON_GetObjectItem(root, "facing")->valuestring);
|
||||||
|
|
||||||
|
if (game.plus & PLUS_MIRROR)
|
||||||
|
{
|
||||||
|
world.bob->x = MAP_PIXEL_WIDTH - world.bob->x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void save(cJSON *root)
|
static void save(cJSON *root)
|
||||||
|
|
|
@ -316,6 +316,11 @@ static void load(cJSON *root)
|
||||||
s->closedX = cJSON_GetObjectItem(root, "closedX")->valueint;
|
s->closedX = cJSON_GetObjectItem(root, "closedX")->valueint;
|
||||||
s->closedY = cJSON_GetObjectItem(root, "closedY")->valueint;
|
s->closedY = cJSON_GetObjectItem(root, "closedY")->valueint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.plus & PLUS_MIRROR)
|
||||||
|
{
|
||||||
|
s->tx = MAP_PIXEL_WIDTH - s->tx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void save(cJSON *root)
|
static void save(cJSON *root)
|
||||||
|
|
|
@ -144,6 +144,11 @@ static void load(cJSON *root)
|
||||||
s->startX = cJSON_GetObjectItem(root, "startX")->valueint;
|
s->startX = cJSON_GetObjectItem(root, "startX")->valueint;
|
||||||
s->startY = cJSON_GetObjectItem(root, "startY")->valueint;
|
s->startY = cJSON_GetObjectItem(root, "startY")->valueint;
|
||||||
s->waitTime = cJSON_GetObjectItem(root, "waitTime")->valueint;
|
s->waitTime = cJSON_GetObjectItem(root, "waitTime")->valueint;
|
||||||
|
|
||||||
|
if (game.plus & PLUS_MIRROR)
|
||||||
|
{
|
||||||
|
s->tx = MAP_PIXEL_WIDTH - s->tx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void save(cJSON *root)
|
static void save(cJSON *root)
|
||||||
|
|
|
@ -32,3 +32,4 @@ extern void setGameplayMessage(int type, char *format, ...);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
|
extern Game game;
|
||||||
|
|
|
@ -32,3 +32,4 @@ extern void teleportEntity(Entity *e, float tx, float ty);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
|
extern Game game;
|
||||||
|
|
10
src/main.c
10
src/main.c
|
@ -111,11 +111,10 @@ static long capFrameRate(const long then)
|
||||||
|
|
||||||
static void handleCommandLine(int argc, char *argv[])
|
static void handleCommandLine(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, plus;
|
int i;
|
||||||
char *worldId;
|
char *worldId;
|
||||||
|
|
||||||
worldId = NULL;
|
worldId = NULL;
|
||||||
plus = PLUS_NONE;
|
|
||||||
|
|
||||||
for (i = 1 ; i < argc ; i++)
|
for (i = 1 ; i < argc ; i++)
|
||||||
{
|
{
|
||||||
|
@ -183,16 +182,11 @@ static void handleCommandLine(int argc, char *argv[])
|
||||||
initCredits();
|
initCredits();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(argv[i], "-plus") == 0)
|
|
||||||
{
|
|
||||||
plus = atoi(argv[++i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldId != NULL)
|
if (worldId != NULL)
|
||||||
{
|
{
|
||||||
initWorldTest(worldId, plus);
|
initWorldTest(worldId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ extern void init18N(int argc, char *argv[]);
|
||||||
extern void initGameSystem(void);
|
extern void initGameSystem(void);
|
||||||
extern void initLookups(void);
|
extern void initLookups(void);
|
||||||
extern void initSDL(void);
|
extern void initSDL(void);
|
||||||
extern void initWorldTest(char *worldId, int plus);
|
extern void initWorldTest(char *worldId);
|
||||||
extern void initEnding(void);
|
extern void initEnding(void);
|
||||||
extern void initCredits(void);
|
extern void initCredits(void);
|
||||||
extern void prepareScene(void);
|
extern void prepareScene(void);
|
||||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "worldTest.h"
|
#include "worldTest.h"
|
||||||
|
|
||||||
void initWorldTest(char *worldId, int plus)
|
void initWorldTest(char *worldId)
|
||||||
{
|
{
|
||||||
loadGame(0);
|
loadGame(0);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ void initWorldTest(char *worldId, int plus)
|
||||||
{
|
{
|
||||||
STRNCPY(game.worldId, worldId, MAX_NAME_LENGTH);
|
STRNCPY(game.worldId, worldId, MAX_NAME_LENGTH);
|
||||||
|
|
||||||
game.plus = plus;
|
game.plus = PLUS_MIRROR;
|
||||||
|
|
||||||
initWorld();
|
initWorld();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ static void compareEnvironments(void);
|
||||||
static int getMarkerType(void);
|
static int getMarkerType(void);
|
||||||
static int drawComparator(const void *a, const void *b);
|
static int drawComparator(const void *a, const void *b);
|
||||||
static void checkStuckInWall(void);
|
static void checkStuckInWall(void);
|
||||||
|
static void mirror(void);
|
||||||
|
|
||||||
static Entity *riders[MAX_RIDERS];
|
static Entity *riders[MAX_RIDERS];
|
||||||
static Entity *touched[MAX_TOUCHED];
|
static Entity *touched[MAX_TOUCHED];
|
||||||
|
@ -68,6 +69,8 @@ void initEntities(void)
|
||||||
|
|
||||||
self->w = r->w;
|
self->w = r->w;
|
||||||
self->h = r->h;
|
self->h = r->h;
|
||||||
|
|
||||||
|
mirror();
|
||||||
}
|
}
|
||||||
|
|
||||||
addToQuadtree(self, &world.quadtree);
|
addToQuadtree(self, &world.quadtree);
|
||||||
|
@ -103,6 +106,8 @@ void doEntities(void)
|
||||||
|
|
||||||
self->w = r->w;
|
self->w = r->w;
|
||||||
self->h = r->h;
|
self->h = r->h;
|
||||||
|
|
||||||
|
mirror();
|
||||||
}
|
}
|
||||||
|
|
||||||
removeFromQuadtree(self, &world.quadtree);
|
removeFromQuadtree(self, &world.quadtree);
|
||||||
|
@ -1138,6 +1143,40 @@ static int drawComparator(const void *a, const void *b)
|
||||||
return e2->type - e1->type;
|
return e2->type - e1->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mirror(void)
|
||||||
|
{
|
||||||
|
Structure *s;
|
||||||
|
|
||||||
|
if (self->flags & EF_MIRROR)
|
||||||
|
{
|
||||||
|
switch (self->type)
|
||||||
|
{
|
||||||
|
case ET_DOOR:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ET_LIFT:
|
||||||
|
s = (Structure*)self;
|
||||||
|
if (s->tx == s->x)
|
||||||
|
{
|
||||||
|
s->tx -= self->w;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ET_TELEPORTER:
|
||||||
|
s = (Structure*)self;
|
||||||
|
s->tx -= self->w;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->x -= self->w;
|
||||||
|
|
||||||
|
self->flags &= ~EF_MIRROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void destroyEntities(void)
|
void destroyEntities(void)
|
||||||
{
|
{
|
||||||
Entity *e;
|
Entity *e;
|
||||||
|
|
|
@ -24,6 +24,7 @@ static void loadMapData(void);
|
||||||
static void loadCommonTiles(void);
|
static void loadCommonTiles(void);
|
||||||
static void loadTileset(void);
|
static void loadTileset(void);
|
||||||
static void loadDecals(void);
|
static void loadDecals(void);
|
||||||
|
static void mirrorMap(void);
|
||||||
static SDL_Rect *loadTile(char *filename);
|
static SDL_Rect *loadTile(char *filename);
|
||||||
|
|
||||||
static int MAX_Y;
|
static int MAX_Y;
|
||||||
|
@ -287,9 +288,33 @@ static void loadMapData(void)
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
|
if (game.plus & PLUS_MIRROR)
|
||||||
|
{
|
||||||
|
mirrorMap();
|
||||||
|
}
|
||||||
|
|
||||||
calculateMapBounds();
|
calculateMapBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mirrorMap(void)
|
||||||
|
{
|
||||||
|
int x, y, w, t1, t2;
|
||||||
|
|
||||||
|
w = MAP_WIDTH - 1;
|
||||||
|
|
||||||
|
for (y = 0 ; y < MAP_HEIGHT ; y++)
|
||||||
|
{
|
||||||
|
for (x = 0 ; x < MAP_WIDTH / 2 ; x++)
|
||||||
|
{
|
||||||
|
t1 = world.map.data[x][y];
|
||||||
|
t2 = world.map.data[w - x][y];
|
||||||
|
|
||||||
|
world.map.data[x][y] = t2;
|
||||||
|
world.map.data[w - x][y] = t1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void loadCommonTiles(void)
|
static void loadCommonTiles(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -29,4 +29,5 @@ extern int rrnd(int low, int high);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Camera camera;
|
extern Camera camera;
|
||||||
|
extern Game game;
|
||||||
extern World world;
|
extern World world;
|
||||||
|
|
|
@ -142,6 +142,12 @@ static void loadTriggers(cJSON *root)
|
||||||
t->y = cJSON_GetObjectItem(node, "y")->valueint;
|
t->y = cJSON_GetObjectItem(node, "y")->valueint;
|
||||||
t->w = cJSON_GetObjectItem(node, "w")->valueint;
|
t->w = cJSON_GetObjectItem(node, "w")->valueint;
|
||||||
t->h = cJSON_GetObjectItem(node, "h")->valueint;
|
t->h = cJSON_GetObjectItem(node, "h")->valueint;
|
||||||
|
|
||||||
|
if (game.plus & PLUS_MIRROR)
|
||||||
|
{
|
||||||
|
t->x = MAP_PIXEL_WIDTH - t->x;
|
||||||
|
t->x -= t->w;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +196,13 @@ static void loadEntities(cJSON *root)
|
||||||
{
|
{
|
||||||
self->alive = ALIVE_DEAD;
|
self->alive = ALIVE_DEAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.plus & PLUS_MIRROR)
|
||||||
|
{
|
||||||
|
self->x = MAP_PIXEL_WIDTH - self->x;
|
||||||
|
|
||||||
|
self->flags |= EF_MIRROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue