Misc updates.

This commit is contained in:
Steve 2018-02-09 19:20:37 +00:00
parent a93950056d
commit 88a8d34425
5 changed files with 73 additions and 5 deletions

View File

@ -24,4 +24,3 @@ extern Unit *createUnit(void);
extern void initEvilBlob(Unit *u); extern void initEvilBlob(Unit *u);
extern Sprite *getSprite(char *name); extern Sprite *getSprite(char *name);
extern Entity *self;

View File

@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h" #include "../../common.h"
#include "../../json/cJSON.h" #include "../../json/cJSON.h"
extern void initEntity(Entity *e);
extern Sprite *getSprite(char *name); extern Sprite *getSprite(char *name);
extern void removeItem(char *name); extern void removeItem(char *name);
extern int hasItem(char *name); extern int hasItem(char *name);

View File

@ -23,12 +23,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void initAtlasTest(void) void initAtlasTest(void)
{ {
dev.cheatNoEnemies = 1; dev.cheatNoEnemies = 1;
dev.cheatKeys = 1;
dev.cheatPower = 1;
initGame(); initGame();
initHub(); initHub();
loadWorld("data/maps/beachFront1.json"); loadWorld("data/maps/beachFront2.json");
initWorld(); initWorld();

66
src/world/radar.c Normal file
View File

@ -0,0 +1,66 @@
#define RADAR_TILE_SIZE 32
#define OFFSET_X ((SCREEN_WIDTH - (RADAR_TILE_SIZE * RADAR_TILE_SIZE)) / 2)
#define OFFSET_Y ((SCREEN_HEIGHT - (RADAR_TILE_SIZE * RADAR_TILE_SIZE)) / 2)
static void logic(void);
static void draw(void);
static void drawMap(void);
static SDL_Rect viewRect;
void initRadar(void)
{
app.delegate.logic = logic;
app.delegate.logic = draw;
viewRect.x = (world.bob->x / MAP_TILE_SIZE) - (RADAR_TILE_SIZE / 2);
viewRect.y = (world.bob->y / MAP_TILE_SIZE) - (RADAR_TILE_SIZE / 2);
viewRect.w = RADAR_TILE_SIZE;
viewRect.h = RADAR_TILE_SIZE;
}
static void logic(void)
{
}
static void draw(void)
{
drawMap();
}
static void drawMap(void)
{
int x, y, mx, my;
for (x = 0 ; x < viewRect.w ; x++)
{
for (y = 0 ; y < viewRect.h ; y++)
{
mx = viewRect.x + x;
my = viewRect.y + y;
if (withinMap(mx, my))
{
drawRect(OFFSET_X + (x * RADAR_TILE_SIZE), OFFSET_Y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, 0, 200, 0, 255);
}
}
}
}
static void drawEntities(void)
{
Entity *e;
Entity **candidates;
int i, x, y;
candidates = getAllEntsWithin(viewRect.x * MAP_TILE_SIZE, viewRect.y * MAP_TILE_SIZE, viewRect.w * MAP_TILE_SIZE, viewRect.h * MAP_TILE_SIZE, NULL);
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{
x = viewRect.x + (e->x / RADAR_TILE_SIZE);
y = viewRect.y + (e->y / RADAR_TILE_SIZE);
drawRect(OFFSET_X + (x * RADAR_TILE_SIZE), OFFSET_Y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, 200, 0, 0, 255);
}
}

View File

@ -88,8 +88,9 @@ void initWorld(void)
app.delegate.logic = logic; app.delegate.logic = logic;
app.delegate.draw = draw; app.delegate.draw = draw;
world.bob->x = 166 * MAP_TILE_SIZE; startMission();
world.bob->y = 103 * MAP_TILE_SIZE; world.bob->x = 140 * MAP_TILE_SIZE;
world.bob->y = 106 * MAP_TILE_SIZE;
} }
static void logic(void) static void logic(void)
@ -436,6 +437,7 @@ static void spawnEnemies(void)
world.numToSpawn = 3 + (rand() % 3); world.numToSpawn = 3 + (rand() % 3);
world.spawnInterval = 0; world.spawnInterval = 0;
} }
return; return;
} }