Start of resolution updates.

This commit is contained in:
Steve 2018-12-22 21:53:19 +00:00
parent 9acb52163c
commit 86be9a25b9
32 changed files with 328 additions and 219 deletions

View File

@ -1,5 +1,5 @@
VERSION = 1.1
REVISION = 1
VERSION = 1.2
REVISION = 0
LOCALE_MO = $(patsubst %.po,%.mo,$(wildcard locale/*.po))
OUT = bin

View File

@ -39,6 +39,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SAVE_FILENAME "game.save"
#define CONFIG_FILENAME "config.json"
#define UI_WIDTH 1280
#define UI_HEIGHT 720
#define SCREEN_WIDTH 1280
#define SCREEN_HEIGHT 720
@ -63,9 +66,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MAP_WIDTH 200
#define MAP_HEIGHT 200
#define MAP_RENDER_WIDTH ((SCREEN_WIDTH / MAP_TILE_SIZE) + 1)
#define MAP_RENDER_HEIGHT ((SCREEN_HEIGHT / MAP_TILE_SIZE) + 1)
#define MAP_TILE_SIZE 64
#define MAP_TILE_AIR 0
#define MAP_TILE_WATER 1

View File

@ -127,7 +127,7 @@ static void lookForPlayer(void)
distance = getDistance(world.bob->x, world.bob->y, self->x, self->y);
if (distance > SCREEN_HEIGHT)
if (distance > app.config.winHeight)
{
moveTowardsPlayer(1);
return;
@ -144,7 +144,7 @@ static void lookForPlayer(void)
selectWeapon();
}
if (distance < SCREEN_HEIGHT / 4)
if (distance < app.config.winHeight / 4)
{
moveTowardsPlayer(-6);
}

View File

@ -39,6 +39,7 @@ extern double randF(void);
extern int rrnd(int low, int high);
extern void updateObjective(char *targetName);
extern App app;
extern Entity *self;
extern Game game;
extern World world;

View File

@ -65,7 +65,7 @@ static void tick(void)
/* don't allow the player to kill everything on the map by firing constantly */
if (b->owner->type == ET_BOB)
{
if (b->x < camera.x || b->y < camera.y || b->x > camera.x + SCREEN_WIDTH || b->y > camera.y + SCREEN_HEIGHT)
if (b->x < camera.x || b->y < camera.y || b->x > camera.x + app.config.winWidth || b->y > camera.y + app.config.winHeight)
{
b->alive = ALIVE_DEAD;
}

View File

@ -26,6 +26,7 @@ extern void initEntity(Entity *e);
extern void playBattleSound(int snd, int ch, int x, int y);
extern void swapSelf(Entity *e);
extern App app;
extern Camera camera;
extern Entity *self;
extern Game game;

View File

@ -129,7 +129,7 @@ static void tick(void)
if (u->spawnedIn)
{
if (getDistance(u->x, u->y, world.bob->x, world.bob->y) < SCREEN_WIDTH)
if (getDistance(u->x, u->y, world.bob->x, world.bob->y) < app.config.winWidth)
{
u->spawnedInTimer = FPS * 5;
}

View File

@ -36,6 +36,7 @@ extern float limit(float i, float a, float b);
extern void playBattleSound(int snd, int ch, int x, int y);
extern int rrnd(int low, int high);
extern App app;
extern Entity *self;
extern Game game;
extern World world;

View File

@ -96,20 +96,20 @@ static void draw(void)
int w, h;
Credit *c;
scale = (SCREEN_WIDTH * 1.0) / background->rect.w;
scale = (app.config.winWidth * 1.0) / background->rect.w;
w = background->rect.w * scale;
h = background->rect.h * scale;
blitRectScaled(atlasTexture->texture, 0, SCREEN_HEIGHT - h, w, h, &background->rect, 0);
blitRectScaled(atlasTexture->texture, 0, app.config.winHeight - h, w, h, &background->rect, 0);
limitTextWidth(CREDIT_LINE_LIMIT);
for (c = head.next ; c != NULL ; c = c->next)
{
if (c->y > -c->h && c->y < SCREEN_HEIGHT)
if (c->y > -c->h && c->y < app.config.winHeight)
{
drawText(SCREEN_WIDTH / 2, (int)c->y, c->size, TA_CENTER, colors.white, c->text);
drawText(app.config.winWidth / 2, (int)c->y, c->size, TA_CENTER, colors.white, c->text);
}
}
@ -122,7 +122,7 @@ static void loadCredits(void)
char *text, *line, *saveptr;
Credit *c;
y = SCREEN_HEIGHT + 50;
y = app.config.winHeight + 50;
text = readFile("data/misc/credits.txt");

View File

@ -158,18 +158,18 @@ static void draw(void)
{
float h;
h = (SCREEN_WIDTH / 800.0) * background->rect.h;
h = (app.config.winWidth / 800.0) * background->rect.h;
if (section == SECTION_MAIN)
{
drawText(SCREEN_WIDTH / 2, 50, 40, TA_CENTER, colors.white, app.strings[ST_OPTIONS]);
drawText(app.config.winWidth / 2, 50, 40, TA_CENTER, colors.white, app.strings[ST_OPTIONS]);
}
else
{
drawText(SCREEN_WIDTH / 2, 50, 40, TA_CENTER, colors.white, app.strings[ST_CONTROLS]);
drawText(app.config.winWidth / 2, 50, 40, TA_CENTER, colors.white, app.strings[ST_CONTROLS]);
}
blitRectScaled(atlasTexture->texture, 0, SCREEN_HEIGHT - h, SCREEN_WIDTH, h, &background->rect, 0);
blitRectScaled(atlasTexture->texture, 0, app.config.winHeight - h, app.config.winWidth, h, &background->rect, 0);
drawWidgets();
}
@ -191,6 +191,8 @@ static void musicVolume(void)
static void fullscreen(void)
{
app.config.fullscreen = fullscreenWidget->value[0];
SDL_SetWindowFullscreen(app.window, app.config.fullscreen? SDL_WINDOW_FULLSCREEN : 0);
}
static void windowSize(void)
@ -200,6 +202,17 @@ static void windowSize(void)
i = windowSizeWidget->value[0];
sscanf(windowSizeWidget->options[i], "%d x %d", &app.config.winWidth, &app.config.winHeight);
SDL_SetWindowSize(app.window, app.config.winWidth, app.config.winHeight);
app.uiOffset.x = (app.config.winWidth / 2) - (UI_WIDTH / 2);
app.uiOffset.y = (app.config.winHeight / 2) - (UI_HEIGHT / 2);
SDL_DestroyTexture(app.backBuffer);
app.backBuffer = SDL_CreateTexture(app.renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, app.config.winWidth, app.config.winHeight);
initBackground();
}
static void bloodGore(void)

View File

@ -39,6 +39,7 @@ extern void playSound(int snd, int ch);
extern void saveConfig(void);
extern void showWidgetGroup(char *group);
extern void startSectionTransition(void);
extern void initBackground(void);
extern App app;
extern Colors colors;

View File

@ -100,29 +100,31 @@ void drawStats(void)
int i, y, startIndex;
SDL_Rect r;
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
r.w = 500;
r.h = 500;
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
r.x = (UI_WIDTH / 2) - r.w / 2;
r.y = (UI_HEIGHT / 2) - r.h / 2;
drawRect(r.x, r.y, r.w, r.h, 0, 0, 0, 192);
drawOutlineRect(r.x, r.y, r.w, r.h, 200, 200, 200, 255);
drawText(SCREEN_WIDTH / 2, r.y + 5, 28, TA_CENTER, colors.white, "Stats");
drawText(UI_WIDTH / 2, r.y + 5, 28, TA_CENTER, colors.white, "Stats");
drawText(SCREEN_WIDTH / 2, r.y + 45, 16, TA_CENTER, colors.lightGrey, "Page %d / %d", page + 1, (int)maxPages);
drawText(UI_WIDTH / 2, r.y + 45, 16, TA_CENTER, colors.lightGrey, "Page %d / %d", page + 1, (int)maxPages);
if (page > 0)
{
blitRect(atlasTexture->texture, SCREEN_WIDTH / 2 - 100, r.y + 25, &left->rect, 1);
blitRect(atlasTexture->texture, UI_WIDTH / 2 - 100, r.y + 25, &left->rect, 1);
}
if (page < maxPages - 1)
{
blitRect(atlasTexture->texture, SCREEN_WIDTH / 2 + 100, r.y + 25, &right->rect, 1);
blitRect(atlasTexture->texture, UI_WIDTH / 2 + 100, r.y + 25, &right->rect, 1);
}
SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255);
@ -163,4 +165,6 @@ void drawStats(void)
drawText(r.x + r.w - 20, r.y + r.h - 95, 18, TA_RIGHT, colors.white, timeToString(game.stats[STAT_TIME_PLAYED], 1));
drawWidgets();
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}

View File

@ -139,26 +139,28 @@ static void logic(void)
static void draw(void)
{
SDL_SetTextureAlphaMod(atlasTexture->texture, titleAlpha);
blitRect(atlasTexture->texture, SCREEN_WIDTH / 2, 175, &title->rect, 1);
blitRect(atlasTexture->texture, app.config.winWidth / 2, 175, &title->rect, 1);
SDL_SetTextureAlphaMod(atlasTexture->texture, 255);
drawText(10, SCREEN_HEIGHT - 30, 16, TA_LEFT, colors.white, "Copyright 2014, 2018 Parallel Realities");
drawText(SCREEN_WIDTH - 10, SCREEN_HEIGHT - 30, 16, TA_RIGHT, colors.white, "Version %.1f.%d", VERSION, REVISION);
drawText(10, app.config.winHeight - 30, 16, TA_LEFT, colors.white, "Copyright 2014, 2018 Parallel Realities");
drawText(app.config.winWidth - 10, app.config.winHeight - 30, 16, TA_RIGHT, colors.white, "Version %.1f.%d", VERSION, REVISION);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
drawWidgets();
SDL_SetRenderTarget(app.renderer, app.backBuffer);
if (saveAction == SA_NEW)
{
drawText(SCREEN_WIDTH / 2, 275, 24, TA_CENTER, colors.white, app.strings[ST_CHOOSE_SAVE]);
drawText(app.config.winWidth / 2, 275, 24, TA_CENTER, colors.white, app.strings[ST_CHOOSE_SAVE]);
}
else if (saveAction == SA_LOAD)
{
drawText(SCREEN_WIDTH / 2, 275, 24, TA_CENTER, colors.white, app.strings[ST_LOAD]);
drawText(app.config.winWidth / 2, 275, 24, TA_CENTER, colors.white, app.strings[ST_LOAD]);
}
else if (saveAction == SA_DELETE)
{
drawText(SCREEN_WIDTH / 2, 350, 24, TA_CENTER, colors.white, app.strings[ST_OVERWRITE_1]);
drawText(SCREEN_WIDTH / 2, 400, 22, TA_CENTER, colors.white, app.strings[ST_OVERWRITE_2]);
drawText(app.config.winWidth / 2, 350, 24, TA_CENTER, colors.white, app.strings[ST_OVERWRITE_1]);
drawText(app.config.winWidth / 2, 400, 22, TA_CENTER, colors.white, app.strings[ST_OVERWRITE_2]);
}
}

View File

@ -95,12 +95,14 @@ void drawTrophies(void)
SDL_Rect r;
int start, end, i, x, y;
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
r.w = 600;
r.h = 650;
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
r.x = (UI_WIDTH / 2) - r.w / 2;
r.y = (UI_HEIGHT / 2) - r.h / 2;
r.y += 15;
@ -108,18 +110,18 @@ void drawTrophies(void)
drawOutlineRect(r.x, r.y, r.w, r.h, 200, 200, 200, 255);
drawText(SCREEN_WIDTH / 2, 60, 28, TA_CENTER, colors.white, app.strings[ST_TROPHIES]);
drawText(UI_WIDTH / 2, 60, 28, TA_CENTER, colors.white, app.strings[ST_TROPHIES]);
drawText(SCREEN_WIDTH / 2, 100, 16, TA_CENTER, colors.lightGrey, app.strings[ST_PAGE], page + 1, (int)maxPages);
drawText(UI_WIDTH / 2, 100, 16, TA_CENTER, colors.lightGrey, app.strings[ST_PAGE], page + 1, (int)maxPages);
if (page > 0)
{
blitRect(atlasTexture->texture, SCREEN_WIDTH / 2 - 100, 110, &left->rect, 1);
blitRect(atlasTexture->texture, UI_WIDTH / 2 - 100, 110, &left->rect, 1);
}
if (page < maxPages - 1)
{
blitRect(atlasTexture->texture, SCREEN_WIDTH / 2 + 100, 110, &right->rect, 1);
blitRect(atlasTexture->texture, UI_WIDTH / 2 + 100, 110, &right->rect, 1);
}
x = r.x + 15;
@ -174,6 +176,8 @@ void drawTrophies(void)
SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 255);
drawWidgets();
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
void awardTrophy(char *id)

View File

@ -95,8 +95,8 @@ void initHub(void)
}
}
cursor.x = SCREEN_WIDTH / 2;
cursor.y = SCREEN_HEIGHT / 2;
cursor.x = app.config.winWidth / 2;
cursor.y = app.config.winHeight / 2;
getWidget("startMission", "mission")->action = startMission;
getWidget("cancel", "mission")->action = cancel;
@ -132,9 +132,9 @@ void initHub(void)
showing = SHOW_NONE;
cursor.x = SCREEN_WIDTH / 2;
cursor.y = SCREEN_HEIGHT / 2;
SDL_WarpMouseInWindow(app.window, cursor.x * app.scaleX, cursor.y * app.scaleY);
cursor.x = app.config.winWidth / 2;
cursor.y = app.config.winHeight / 2;
SDL_WarpMouseInWindow(app.window, cursor.x, cursor.y);
game.isComplete = 1;
@ -290,32 +290,32 @@ static void doCursor(void)
{
if (app.mouse.dx != 0 || app.mouse.dy != 0)
{
cursor.x = app.mouse.x * app.scaleX;
cursor.y = app.mouse.y * app.scaleY;
cursor.x = app.mouse.x;
cursor.y = app.mouse.y;
}
if (isControl(CONTROL_UP) || app.keyboard[SDL_SCANCODE_UP])
{
cursor.y -= CURSOR_SPEED;
SDL_WarpMouseInWindow(app.window, cursor.x / app.scaleX, cursor.y / app.scaleY);
SDL_WarpMouseInWindow(app.window, cursor.x, cursor.y);
}
if (isControl(CONTROL_DOWN) || app.keyboard[SDL_SCANCODE_DOWN])
{
cursor.y += CURSOR_SPEED;
SDL_WarpMouseInWindow(app.window, cursor.x / app.scaleX, cursor.y / app.scaleY);
SDL_WarpMouseInWindow(app.window, cursor.x, cursor.y);
}
if (isControl(CONTROL_LEFT) || app.keyboard[SDL_SCANCODE_LEFT])
{
cursor.x -= CURSOR_SPEED;
SDL_WarpMouseInWindow(app.window, cursor.x / app.scaleX, cursor.y / app.scaleY);
SDL_WarpMouseInWindow(app.window, cursor.x, cursor.y);
}
if (isControl(CONTROL_RIGHT) || app.keyboard[SDL_SCANCODE_RIGHT])
{
cursor.x += CURSOR_SPEED;
SDL_WarpMouseInWindow(app.window, cursor.x / app.scaleX, cursor.y / app.scaleY);
SDL_WarpMouseInWindow(app.window, cursor.x, cursor.y);
}
}
@ -349,7 +349,7 @@ static void doMissionInfo(void)
{
Widget *w;
w = selectWidgetAt(cursor.x, cursor.y);
w = selectWidgetAt(cursor.x - app.uiOffset.x, cursor.y - app.uiOffset.y);
if ((w != NULL) && (isControl(CONTROL_FIRE) || app.mouse.button[SDL_BUTTON_LEFT]))
{
@ -375,7 +375,7 @@ static void doMissionInfo(void)
static void draw(void)
{
blitRectScaled(atlasTexture->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, &worldMap->rect, 0);
blitRectScaled(atlasTexture->texture, 0, 0, app.config.winWidth, app.config.winHeight, &worldMap->rect, 0);
drawBackground(atlasTexture->texture, &clouds->rect);
@ -397,7 +397,11 @@ static void draw(void)
drawPlusSettings();
}
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
drawWidgets();
/* draw on both the UI buffer and main buffer, just to cheat */
blitRect(atlasTexture->texture, cursor.x - app.uiOffset.x, cursor.y - app.uiOffset.y, getCurrentFrame(cursorSpr), 1);
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
blitRect(atlasTexture->texture, cursor.x, cursor.y, getCurrentFrame(cursorSpr), 1);
break;
@ -419,6 +423,11 @@ static void draw(void)
static void drawMissions(void)
{
HubMission *mission;
double ratioX, ratioY;
/* the original Attrition is based on 800x600, so multiply up */
ratioX = app.config.winWidth / 800.0;
ratioY = app.config.winHeight / 600.0;
for (mission = hubMissionHead.next ; mission != NULL ; mission = mission->next)
{
@ -426,15 +435,15 @@ static void drawMissions(void)
{
case MS_INCOMPLETE:
SDL_SetTextureColorMod(atlasTexture->texture, 255, 0, 0);
blitRectScaled(atlasTexture->texture, mission->x, mission->y, blipSize, blipSize, &alert->rect, 1);
drawText(mission->x, mission->y - 32, 18, TA_CENTER, colors.white, mission->name);
blitRectScaled(atlasTexture->texture, mission->x * ratioX, mission->y * ratioY, blipSize, blipSize, &alert->rect, 1);
drawText(mission->x * ratioX, (mission->y * ratioY) - 32, 18, TA_CENTER, colors.white, mission->name);
break;
case MS_PARTIAL:
case MS_MISSING_HEART_CELL:
SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 0);
blitRectScaled(atlasTexture->texture, mission->x, mission->y, blipSize, blipSize, &alert->rect, 1);
drawText(mission->x, mission->y - 32, 18, TA_CENTER, colors.white, mission->name);
blitRectScaled(atlasTexture->texture, mission->x * ratioX, mission->y * ratioY, blipSize, blipSize, &alert->rect, 1);
drawText(mission->x * ratioX, (mission->y * ratioY) - 32, 18, TA_CENTER, colors.white, mission->name);
break;
default:
@ -447,45 +456,55 @@ static void drawMissions(void)
static void drawInfoBar(void)
{
drawRect(0, 0, SCREEN_WIDTH, 32, 0, 0, 0, 192);
int x;
x = (50 + (app.config.winWidth - 50)) / 5;
drawRect(0, 0, app.config.winWidth, 32, 0, 0, 0, 192);
drawText(10, 5, 18, TA_LEFT, colors.white, app.strings[ST_HUB_MISSIONS], game.stats[STAT_MISSIONS_COMPLETE], unlockedMissions);
drawText(210, 5, 18, TA_LEFT, colors.white, app.strings[ST_HUB_MIAS], game.stats[STAT_MIAS_RESCUED], game.totalMIAs);
drawText(x, 5, 18, TA_CENTER, colors.white, app.strings[ST_HUB_MIAS], game.stats[STAT_MIAS_RESCUED], game.totalMIAs);
drawText(410, 5, 18, TA_LEFT, colors.white, app.strings[ST_HUB_TARGETS], game.stats[STAT_TARGETS_DEFEATED], game.totalTargets);
drawText(x * 2, 5, 18, TA_CENTER, colors.white, app.strings[ST_HUB_TARGETS], game.stats[STAT_TARGETS_DEFEATED], game.totalTargets);
drawText(610, 5, 18, TA_LEFT, colors.white, app.strings[ST_HUB_KEYS], game.stats[STAT_KEYS_FOUND], game.totalKeys);
drawText(x * 3, 5, 18, TA_CENTER, colors.white, app.strings[ST_HUB_KEYS], game.stats[STAT_KEYS_FOUND], game.totalKeys);
drawText(810, 5, 18, TA_LEFT, colors.white, app.strings[ST_HUB_HEARTS], game.stats[STAT_HEARTS_FOUND], game.totalHearts);
drawText(x * 4, 5, 18, TA_CENTER, colors.white, app.strings[ST_HUB_HEARTS], game.stats[STAT_HEARTS_FOUND], game.totalHearts);
drawText(1010, 5, 18, TA_LEFT, colors.white, app.strings[ST_HUB_CELLS], game.stats[STAT_CELLS_FOUND], game.totalCells);
drawText(app.config.winWidth - 10, 5, 18, TA_RIGHT, colors.white, app.strings[ST_HUB_CELLS], game.stats[STAT_CELLS_FOUND], game.totalCells);
}
static void drawHudWidgets(void)
{
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
drawWidgetFrame();
drawWidgets();
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
static void drawMissionInfo(void)
{
int w, h, x, y, size, mid, i;
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
w = 800;
h = 550;
x = (SCREEN_WIDTH - w) / 2;
y = (SCREEN_HEIGHT - h) / 2;
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
x = (UI_WIDTH - w) / 2;
y = (UI_HEIGHT - h) / 2;
drawRect(x, y, w, h, 0, 0, 0, 192);
drawOutlineRect(x, y, w, h, 255, 255, 255, 255);
drawText(SCREEN_WIDTH / 2, y + 25, 32, TA_CENTER, colors.white, selectedMission->name);
drawText(UI_WIDTH / 2, y + 25, 32, TA_CENTER, colors.white, selectedMission->name);
limitTextWidth(w - 150);
drawText(x + 15, y + 100, 22, TA_LEFT, colors.white, selectedMission->description);
@ -494,13 +513,13 @@ static void drawMissionInfo(void)
size = 65;
mid = size / 2;
y = (((SCREEN_HEIGHT - h) / 2) + h) - 225;
y = (((UI_HEIGHT - h) / 2) + h) - 225;
drawText(SCREEN_WIDTH / 2, y, 24, TA_CENTER, colors.white, "Keys");
drawText(UI_WIDTH / 2, y, 24, TA_CENTER, colors.white, "Keys");
y += 64;
x = ((SCREEN_WIDTH - w) / 2) + 30;
x = ((UI_WIDTH - w) / 2) + 30;
for (i = 0 ; i < MAX_KEY_TYPES ; i++)
{
@ -517,24 +536,30 @@ static void drawMissionInfo(void)
x += (size + 30);
}
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
static void drawPlusSettings(void)
{
int w, h, x, y;
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
w = 800;
h = 550;
x = (SCREEN_WIDTH - w) / 2;
y = (SCREEN_HEIGHT - h) / 2;
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
x = (UI_WIDTH - w) / 2;
y = (UI_HEIGHT - h) / 2;
drawRect(x, y, w, h, 0, 0, 0, 192);
drawOutlineRect(x, y, w, h, 255, 255, 255, 255);
drawText(SCREEN_WIDTH / 2, y + 25, 32, TA_CENTER, colors.white, selectedMission->name);
drawText(SCREEN_WIDTH / 2, y + 75, 24, TA_CENTER, colors.white, app.strings[ST_MISSION_CONFIG]);
drawText(UI_WIDTH / 2, y + 25, 32, TA_CENTER, colors.white, selectedMission->name);
drawText(UI_WIDTH / 2, y + 75, 24, TA_CENTER, colors.white, app.strings[ST_MISSION_CONFIG]);
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
static void unlockMission(char *id)
@ -614,6 +639,11 @@ HubMission *getMissionAt(int x, int y)
HubMission *rtn;
HubMission *mission;
float distance, dist;
double ratioX, ratioY;
/* the original Attrition is based on 800x600, so multiply up */
ratioX = app.config.winWidth / 800.0;
ratioY = app.config.winHeight / 600.0;
rtn = NULL;
distance = 32;
@ -622,7 +652,7 @@ HubMission *getMissionAt(int x, int y)
{
if (mission->status == MS_INCOMPLETE || mission->status == MS_MISSING_HEART_CELL || mission->status == MS_PARTIAL)
{
dist = getDistance(x, y, mission->x, mission->y);
dist = getDistance(x, y, mission->x * ratioX, mission->y * ratioY);
if (dist < distance)
{
@ -755,11 +785,6 @@ static void loadMissions(void)
cJSON *root, *node;
char *text;
HubMission *mission;
double ratioX, ratioY;
/* the original Attrition is based on 800x600, so multiply up */
ratioX = SCREEN_WIDTH / 800.0;
ratioY = SCREEN_HEIGHT / 600.0;
text = readFile("data/hub/missions.json");
@ -778,8 +803,8 @@ static void loadMissions(void)
STRNCPY(mission->requires, cJSON_GetObjectItem(node, "requires")->valuestring, MAX_NAME_LENGTH);
mission->status = MS_LOCKED;
mission->x = cJSON_GetObjectItem(node, "x")->valuedouble * ratioX;
mission->y = cJSON_GetObjectItem(node, "y")->valuedouble * ratioY;
mission->x = cJSON_GetObjectItem(node, "x")->valuedouble;
mission->y = cJSON_GetObjectItem(node, "y")->valuedouble;
}
cJSON_Delete(root);

View File

@ -58,7 +58,7 @@ void initPostMission(void)
oNum = 0;
missionCompleteY = SCREEN_HEIGHT;
missionCompleteY = UI_HEIGHT;
playSound(SND_MISSION_COMPLETE, 0);
@ -191,16 +191,18 @@ static void draw(void)
char *status;
int x, y, w, i;
blitRectScaled(atlasTexture->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, &background->rect, 0);
blitRectScaled(atlasTexture->texture, 0, 0, app.config.winWidth, app.config.winHeight, &background->rect, 0);
drawText(SCREEN_WIDTH / 2, missionCompleteY, 45, TA_CENTER, colors.white, app.strings[ST_MISSION_COMPLETE]);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
drawText(UI_WIDTH / 2, missionCompleteY, 45, TA_CENTER, colors.white, app.strings[ST_MISSION_COMPLETE]);
i = 0;
if (missionCompleteY == 50)
{
w = 800;
x = (SCREEN_WIDTH - w) / 2;
x = (UI_WIDTH - w) / 2;
y = 150;
for (o = world.objectiveHead.next ; o != NULL ; o = o->next)
@ -215,7 +217,7 @@ static void draw(void)
}
drawText(x + 20, y, 24, TA_LEFT, c, o->description);
drawText(SCREEN_WIDTH / 2 + 100, y, 24, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue);
drawText(UI_WIDTH / 2 + 100, y, 24, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue);
drawText(x + w - 20, y, 24, TA_RIGHT, c, status);
y += 55;
@ -226,10 +228,12 @@ static void draw(void)
}
}
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 80, 24, TA_CENTER, colors.white, app.strings[ST_PRESS_FIRE]);
drawText(UI_WIDTH / 2, UI_HEIGHT - 80, 24, TA_CENTER, colors.white, app.strings[ST_PRESS_FIRE]);
canContinue = 1;
}
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
static int getPostMissionStatus(void)

View File

@ -338,14 +338,14 @@ typedef struct {
typedef struct {
char *saveDir;
float scaleX;
float scaleY;
SDL_Point uiOffset;
Mouse mouse;
SDL_Joystick *joypad;
int keyboard[MAX_KEYBOARD_KEYS];
int joypadButton[SDL_CONTROLLER_BUTTON_MAX];
int joypadAxis[JOYPAD_AXIS_MAX];
SDL_Texture *backBuffer;
SDL_Texture *uiBuffer;
SDL_Renderer *renderer;
SDL_Window *window;
Delegate delegate;

View File

@ -26,17 +26,17 @@ static PointF backgroundPoint[4];
void initBackground(void)
{
backgroundPoint[0].x = -SCREEN_WIDTH / 2;
backgroundPoint[0].y = -SCREEN_HEIGHT / 2;
backgroundPoint[0].x = -app.config.winWidth / 2;
backgroundPoint[0].y = -app.config.winHeight / 2;
backgroundPoint[1].x = SCREEN_WIDTH / 2;
backgroundPoint[1].y = -SCREEN_HEIGHT / 2;
backgroundPoint[1].x = app.config.winWidth / 2;
backgroundPoint[1].y = -app.config.winHeight / 2;
backgroundPoint[2].x = -SCREEN_WIDTH / 2;
backgroundPoint[2].y = SCREEN_HEIGHT / 2;
backgroundPoint[2].x = -app.config.winWidth / 2;
backgroundPoint[2].y = app.config.winHeight / 2;
backgroundPoint[3].x = SCREEN_WIDTH / 2;
backgroundPoint[3].y = SCREEN_HEIGHT / 2;
backgroundPoint[3].x = app.config.winWidth / 2;
backgroundPoint[3].y = app.config.winHeight / 2;
}
void initGraphics(void)
@ -53,16 +53,21 @@ void initGraphics(void)
initColor(&colors.lightGrey, 192, 192, 192);
initColor(&colors.darkGrey, 128, 128, 128);
app.backBuffer = SDL_CreateTexture(app.renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT);
app.backBuffer = SDL_CreateTexture(app.renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, app.config.winWidth, app.config.winHeight);
app.uiBuffer = SDL_CreateTexture(app.renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, UI_WIDTH, UI_HEIGHT);
SDL_SetTextureBlendMode(app.uiBuffer, SDL_BLENDMODE_BLEND);
app.scaleX = SCREEN_WIDTH;
app.scaleX /= app.config.winWidth;
app.scaleY = SCREEN_HEIGHT;
app.scaleY /= app.config.winHeight;
app.uiOffset.x = (app.config.winWidth / 2) - (UI_WIDTH / 2);
app.uiOffset.y = (app.config.winHeight / 2) - (UI_HEIGHT / 2);
}
void prepareScene(void)
{
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
SDL_RenderClear(app.renderer);
SDL_SetRenderTarget(app.renderer, app.backBuffer);
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 255);
SDL_RenderClear(app.renderer);
@ -70,17 +75,26 @@ void prepareScene(void)
void presentScene(void)
{
SDL_Rect uiDest;
uiDest.w = UI_WIDTH;
uiDest.h = UI_HEIGHT;
uiDest.x = (app.config.winWidth / 2) - (UI_WIDTH / 2);
uiDest.y = (app.config.winHeight / 2) - (UI_HEIGHT / 2);
if (dev.debug)
{
drawText(5, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "DEBUG MODE");
drawText(5, app.config.winHeight - 25, 14, TA_LEFT, colors.white, "DEBUG MODE");
if (dev.showFPS)
{
drawText(SCREEN_WIDTH - 5, SCREEN_HEIGHT - 25, 14, TA_RIGHT, colors.white, "FPS: %d", dev.fps);
drawText(app.config.winWidth - 5, app.config.winHeight - 25, 14, TA_RIGHT, colors.white, "FPS: %d", dev.fps);
}
}
SDL_SetRenderTarget(app.renderer, NULL);
SDL_RenderCopy(app.renderer, app.backBuffer, NULL, NULL);
SDL_RenderCopy(app.renderer, app.uiBuffer, NULL, &uiDest);
SDL_RenderPresent(app.renderer);
}
@ -220,22 +234,22 @@ void scrollBackground(float x, float y)
if (backgroundPoint[i].x < 0)
{
backgroundPoint[i].x += (SCREEN_WIDTH * 2);
backgroundPoint[i].x += (app.config.winWidth * 2);
}
if (backgroundPoint[i].x >= SCREEN_WIDTH)
if (backgroundPoint[i].x >= app.config.winWidth)
{
backgroundPoint[i].x -= (SCREEN_WIDTH * 2);
backgroundPoint[i].x -= (app.config.winWidth * 2);
}
if (backgroundPoint[i].y < 0)
{
backgroundPoint[i].y += (SCREEN_HEIGHT * 2);
backgroundPoint[i].y += (app.config.winHeight * 2);
}
if (backgroundPoint[i].y >= SCREEN_HEIGHT)
if (backgroundPoint[i].y >= app.config.winHeight)
{
backgroundPoint[i].y -= (SCREEN_HEIGHT * 2);
backgroundPoint[i].y -= (app.config.winHeight * 2);
}
}
}
@ -246,7 +260,7 @@ void drawBackground(SDL_Texture *texture, SDL_Rect *srcRect)
for (i = 0 ; i < 4 ; i++)
{
blitRectScaled(texture, backgroundPoint[i].x, backgroundPoint[i].y, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, srcRect, 0);
blitRectScaled(texture, backgroundPoint[i].x, backgroundPoint[i].y, app.config.winWidth - 1, app.config.winHeight - 1, srcRect, 0);
}
}

View File

@ -101,6 +101,11 @@ void initSDL(void)
initJoypad();
app.uiOffset.x = (app.config.winWidth / 2) - (UI_WIDTH / 2);
app.uiOffset.y = (app.config.winHeight / 2) - (UI_HEIGHT / 2);
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "UI offset: %d,%d\n", app.uiOffset.x, app.uiOffset.y);
SDL_ShowCursor(SDL_DISABLE);
}
@ -164,10 +169,10 @@ static void showLoadingStep(float step, float maxSteps)
prepareScene();
r.w = SCREEN_WIDTH - 400;
r.h = 14;
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
r.w = 600;
r.h = 12;
r.x = (app.config.winWidth / 2) - r.w / 2;
r.y = (app.config.winHeight / 2) - r.h / 2;
SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255);
SDL_RenderDrawRect(app.renderer, &r);

View File

@ -368,7 +368,7 @@ void showWidgetGroup(char *group)
hideAllWidgets();
frame.x = frame.y = SCREEN_WIDTH;
frame.x = frame.y = UI_WIDTH;
frame.w = frame.h = 0;
for (i = 0 ; i < numWidgets ; i++)
@ -449,7 +449,7 @@ static void loadWidgetGroup(char *filename)
if (w->x == -1)
{
w->x = (SCREEN_WIDTH - w->w) / 2;
w->x = (UI_WIDTH - w->w) / 2;
}
switch (w->type)

View File

@ -27,8 +27,8 @@ void cameraTrack(Entity *e)
camera.x = (int) e->x + e->w / 2;
camera.y = (int) e->y + e->h / 2;
camera.x -= (SCREEN_WIDTH / 2);
camera.y -= (SCREEN_HEIGHT / 2);
camera.x -= (app.config.winWidth / 2);
camera.y -= (app.config.winHeight / 2);
clipCamera();
}
@ -40,8 +40,8 @@ float cameraChase(Entity *e, int maxSpeed)
x = camera.x;
y = camera.y;
tx = e->x - (SCREEN_WIDTH / 2);
ty = e->y - (SCREEN_HEIGHT / 2);
tx = e->x - (app.config.winWidth / 2);
ty = e->y - (app.config.winHeight / 2);
diffX = fabs(tx - x);
diffY = fabs(ty - y);
@ -95,5 +95,5 @@ int isOnScreen(Entity *e)
x = (-camera.x + e->x);
y = (-camera.y + e->y);
return (x >= 0 && y >= 0 && x - e->w < SCREEN_WIDTH && y - e->h < SCREEN_HEIGHT);
return (x >= 0 && y >= 0 && x - e->w < app.config.winWidth && y - e->h < app.config.winHeight);
}

View File

@ -22,5 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern float limit(float i, float a, float b);
extern App app;
extern Camera camera;
extern World world;

View File

@ -87,8 +87,8 @@ void doEntities(void)
memset(riders, 0, sizeof(Entity*) * MAX_RIDERS);
camMidX = camera.x + (SCREEN_WIDTH / 2);
camMidY = camera.y + (SCREEN_HEIGHT / 2);
camMidX = camera.x + (app.config.winWidth / 2);
camMidY = camera.y + (app.config.winHeight / 2);
doMarker(&targetMarker[0], 1);
doMarker(&targetMarker[1], -1);
@ -142,7 +142,7 @@ void doEntities(void)
continue;
}
if ((self->flags & EF_ALWAYS_PROCESS) > 0 || getDistance(camMidX, camMidY, self->x, self->y) < SCREEN_WIDTH || isObserving())
if ((self->flags & EF_ALWAYS_PROCESS) > 0 || getDistance(camMidX, camMidY, self->x, self->y) < app.config.winWidth || isObserving())
{
self->isVisible = 1;
}
@ -283,12 +283,12 @@ void doEntitiesStatic(void)
{
int camMidX, camMidY;
camMidX = camera.x + (SCREEN_WIDTH / 2);
camMidY = camera.y + (SCREEN_HEIGHT / 2);
camMidX = camera.x + (app.config.winWidth / 2);
camMidY = camera.y + (app.config.winHeight / 2);
for (self = world.entityHead.next ; self != NULL ; self = self->next)
{
if (getDistance(camMidX, camMidY, self->x, self->y) < SCREEN_WIDTH || isObserving())
if (getDistance(camMidX, camMidY, self->x, self->y) < app.config.winWidth || isObserving())
{
self->isVisible = 1;
}
@ -300,7 +300,7 @@ void drawEntities(int plane)
int x, y, draw, i, t;
Entity **candidates;
candidates = getAllEntsWithin(camera.x, camera.y, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
candidates = getAllEntsWithin(camera.x, camera.y, app.config.winWidth, app.config.winHeight, NULL);
/* counting entities to draw */
for (i = 0, self = candidates[i] ; self != NULL ; self = candidates[++i]) {};
@ -448,8 +448,8 @@ static void moveEntity(void)
if (!(self->flags & (EF_KILL_OFFSCREEN | EF_NO_CLIP)))
{
self->x = limit(self->x, world.map.bounds.x, world.map.bounds.w + SCREEN_WIDTH - self->w);
self->y = limit(self->y, world.map.bounds.y - (self->h - 1), world.map.bounds.h + SCREEN_HEIGHT - self->h);
self->x = limit(self->x, world.map.bounds.x, world.map.bounds.w + app.config.winWidth - self->w);
self->y = limit(self->y, world.map.bounds.y - (self->h - 1), world.map.bounds.h + app.config.winHeight - self->h);
}
}

View File

@ -41,6 +41,7 @@ extern void playBattleSound(int snd, int ch, int x, int y);
extern void removeFromQuadtree(Entity *e, Quadtree *root);
extern void terminateJetpack(void);
extern App app;
extern Camera camera;
extern Entity *self;
extern World world;

View File

@ -39,7 +39,7 @@ static Atlas *oxygenIcon;
void initHud(void)
{
messageTime = FPS * 2;
messageTime = 0;
messageType = MSG_STANDARD;
strcpy(message, "");
messageColor = colors.white;
@ -88,18 +88,18 @@ void drawHud(void)
}
else if (messageTime > 0)
{
drawRect(0, SCREEN_HEIGHT - 32, SCREEN_WIDTH, 32, 0, 0, 0, 200);
drawRect(0, app.config.winHeight - 32, app.config.winWidth, 32, 0, 0, 0, 200);
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 26, 16, TA_CENTER, messageColor, message);
drawText(app.config.winWidth / 2, app.config.winHeight - 26, 16, TA_CENTER, messageColor, message);
}
if (infoMessageTime > 0)
{
limitTextWidth(500);
h = getWrappedTextHeight(infoMessage, 20) + 20;
drawRect((SCREEN_WIDTH / 2) - 300, 40, 600, h, 0, 0, 0, 168);
drawOutlineRect((SCREEN_WIDTH / 2) - 300, 40, 600, h, 192, 192, 192, 255);
drawText(SCREEN_WIDTH / 2, 50, 20, TA_CENTER, colors.white, infoMessage);
drawRect((app.config.winWidth / 2) - 300, 40, 600, h, 0, 0, 0, 168);
drawOutlineRect((app.config.winWidth / 2) - 300, 40, 600, h, 192, 192, 192, 255);
drawText(app.config.winWidth / 2, 50, 20, TA_CENTER, colors.white, infoMessage);
limitTextWidth(0);
}
@ -197,7 +197,7 @@ static void drawInventory(void)
size = 45;
mid = size / 2;
x = 930;
x = app.config.winWidth - 350;
y = 5;
for (i = 0 ; i < MAX_ITEMS ; i++)
@ -205,7 +205,7 @@ static void drawInventory(void)
if (i > 0 && i % (MAX_ITEMS / 2) == 0)
{
y += (size + 5);
x = 930;
x = app.config.winWidth - 350;
}
drawRect(x, y, size, size, 0, 0, 0, 128);
@ -238,22 +238,25 @@ static void drawInventory(void)
static void drawBossHealth(void)
{
float percent;
int w;
int w, x;
percent = world.boss->health;
percent /= world.boss->healthMax;
w = MAX(500 * percent, 0);
drawRect(0, SCREEN_HEIGHT - 32, SCREEN_WIDTH, 32, 0, 0, 0, 200);
drawText(440, SCREEN_HEIGHT - 28, 16, TA_RIGHT, colors.white, world.boss->name);
x = (app.config.winWidth - 500) / 2;
x += 100;
drawRect(450, SCREEN_HEIGHT - 24, w, 16, 255, 0, 0, 255);
drawOutlineRect(450, SCREEN_HEIGHT - 24, 500, 16, 192, 192, 192, 255);
drawRect(0, app.config.winHeight - 32, app.config.winWidth, 32, 0, 0, 0, 200);
drawText(x, app.config.winHeight - 28, 16, TA_RIGHT, colors.white, world.boss->name);
drawRect(x + 10, app.config.winHeight - 24, w, 16, 255, 0, 0, 255);
drawOutlineRect(x + 10, app.config.winHeight - 24, 500, 16, 192, 192, 192, 255);
}
void drawMissionStatus(void)
void drawMissionStatus(int showFirePrompt)
{
Objective *o;
int y, x, w, h, size, mid, i, textSize, lineSpacing;
@ -262,16 +265,18 @@ void drawMissionStatus(void)
SDL_Rect *r;
char *status;
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
w = 800;
h = 550;
x = (SCREEN_WIDTH - w) / 2;
x = (UI_WIDTH - w) / 2;
drawRect(x, (SCREEN_HEIGHT - h) / 2, w, h, 0, 0, 0, 128);
drawOutlineRect(x, (SCREEN_HEIGHT - h) / 2, w, h, 255, 255, 255, 200);
drawRect(x, (UI_HEIGHT - h) / 2, w, h, 0, 0, 0, 128);
drawOutlineRect(x, (UI_HEIGHT - h) / 2, w, h, 255, 255, 255, 200);
drawText(SCREEN_WIDTH / 2, 100, 40, TA_CENTER, colors.white, app.strings[ST_OBJECTIVES]);
drawText(UI_WIDTH / 2, 100, 40, TA_CENTER, colors.white, app.strings[ST_OBJECTIVES]);
y = 180;
textSize = 24;
@ -295,7 +300,7 @@ void drawMissionStatus(void)
}
drawText(x + 20, y, textSize, TA_LEFT, c, o->description);
drawText(SCREEN_WIDTH / 2 + 100, y, textSize, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue);
drawText(UI_WIDTH / 2 + 100, y, textSize, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue);
drawText(x + w - 20, y, textSize, TA_RIGHT, c, status);
y += lineSpacing;
@ -304,16 +309,16 @@ void drawMissionStatus(void)
size = 60;
mid = size / 2;
y = (((SCREEN_HEIGHT - h) / 2) + h) - 165;
y = (((UI_HEIGHT - h) / 2) + h) - 165;
x = ((SCREEN_WIDTH - w) / 2) + 90;
x = ((UI_WIDTH - w) / 2) + 90;
for (i = 0 ; i < MAX_ITEMS ; i++)
{
if (i > 0 && i % (MAX_ITEMS / 2) == 0)
{
y += (size + 20);
x = ((SCREEN_WIDTH - w) / 2) + 90;
x = ((UI_WIDTH - w) / 2) + 90;
}
drawRect(x, y, size, size, 0, 0, 0, 128);
@ -346,6 +351,13 @@ void drawMissionStatus(void)
x += (size + 30);
}
if (showFirePrompt)
{
drawText(UI_WIDTH / 2, UI_HEIGHT - 80, 24, TA_CENTER, colors.white, app.strings[ST_PRESS_FIRE]);
}
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
void setGameplayMessage(int newMessageType, const char *format, ...)

View File

@ -54,15 +54,18 @@ void initMap(void)
void drawMap(void)
{
int mx, x1, x2, my, y1, y2, tile, decal, x, y;
int mx, x1, x2, my, y1, y2, tile, decal, x, y, renderWidth, renderHeight;
renderWidth = (app.config.winWidth / MAP_TILE_SIZE) + 1;
renderHeight = (app.config.winHeight / MAP_TILE_SIZE) + 1;
mx = camera.x / MAP_TILE_SIZE;
x1 = (camera.x % MAP_TILE_SIZE) * -1;
x2 = x1 + MAP_RENDER_WIDTH * MAP_TILE_SIZE + (x1 == 0 ? 0 : MAP_TILE_SIZE);
x2 = x1 + renderWidth * MAP_TILE_SIZE + (x1 == 0 ? 0 : MAP_TILE_SIZE);
my = camera.y / MAP_TILE_SIZE;
y1 = (camera.y % MAP_TILE_SIZE) * -1;
y2 = y1 + MAP_RENDER_HEIGHT * MAP_TILE_SIZE + (y1 == 0 ? 0 : MAP_TILE_SIZE);
y2 = y1 + renderHeight * MAP_TILE_SIZE + (y1 == 0 ? 0 : MAP_TILE_SIZE);
tile = 0;
decal = 0;
@ -171,7 +174,10 @@ int isWalkable(int x, int y)
static void calculateMapBounds(void)
{
int x, y;
int x, y, renderWidth, renderHeight;
renderWidth = (app.config.winWidth / MAP_TILE_SIZE) + 1;
renderHeight = (app.config.winHeight / MAP_TILE_SIZE) + 1;
for (y = 0 ; y < MAP_HEIGHT; y++)
{
@ -202,21 +208,21 @@ static void calculateMapBounds(void)
}
}
if (world.map.bounds.h - MAP_RENDER_HEIGHT < world.map.bounds.y)
if (world.map.bounds.h - renderHeight < world.map.bounds.y)
{
world.map.bounds.y -= (MAP_RENDER_HEIGHT - (world.map.bounds.h - world.map.bounds.y));
world.map.bounds.y -= (renderHeight - (world.map.bounds.h - world.map.bounds.y));
}
world.map.bounds.x = (int) limit(world.map.bounds.x, 0, MAP_WIDTH - MAP_RENDER_WIDTH);
world.map.bounds.y = (int) limit(world.map.bounds.y, 0, MAP_HEIGHT - MAP_RENDER_HEIGHT);
world.map.bounds.x = (int) limit(world.map.bounds.x, 0, MAP_WIDTH - renderWidth);
world.map.bounds.y = (int) limit(world.map.bounds.y, 0, MAP_HEIGHT - renderHeight);
world.map.bounds.x *= MAP_TILE_SIZE;
world.map.bounds.y *= MAP_TILE_SIZE;
world.map.bounds.w *= MAP_TILE_SIZE;
world.map.bounds.h *= MAP_TILE_SIZE;
world.map.bounds.w -= SCREEN_WIDTH;
world.map.bounds.h -= SCREEN_HEIGHT;
world.map.bounds.w -= app.config.winWidth;
world.map.bounds.h -= app.config.winHeight;
world.map.bounds.w += MAP_TILE_SIZE;
world.map.bounds.h += MAP_TILE_SIZE;

View File

@ -52,8 +52,8 @@ void doParticles(void)
Particle *p, *prev;
int camMidX, camMidY;
camMidX = camera.x + (SCREEN_WIDTH / 2);
camMidY = camera.y + (SCREEN_HEIGHT / 2);
camMidX = camera.x + (app.config.winWidth / 2);
camMidY = camera.y + (app.config.winHeight / 2);
prev = &world.particleHead;
@ -77,7 +77,7 @@ void doParticles(void)
free(p);
p = prev;
}
else if (getDistance(camMidX, camMidY, p->x, p->y) < SCREEN_WIDTH)
else if (getDistance(camMidX, camMidY, p->x, p->y) < app.config.winWidth)
{
p->onScreen = 1;
}

View File

@ -29,5 +29,6 @@ extern Texture *getTexture(const char *filename);
extern double randF(void);
extern int rrnd(int low, int high);
extern App app;
extern Camera camera;
extern World world;

View File

@ -37,12 +37,17 @@ static Texture *atlasTexture;
static Atlas *background;
static Atlas *arrow;
static int blinkTimer;
static SDL_Point offset;
static Marker marker[MAX_MARKERS];
static Entity *blips[MAX_BLIPS];
void initRadar(void)
{
SDL_Rect limits;
int renderWidth, renderHeight;
renderWidth = (app.config.winWidth / MAP_TILE_SIZE) + 1;
renderHeight = (app.config.winHeight / MAP_TILE_SIZE) + 1;
startSectionTransition();
@ -59,8 +64,8 @@ void initRadar(void)
limits.x = world.map.bounds.x / MAP_TILE_SIZE;
limits.y = world.map.bounds.y / MAP_TILE_SIZE;
limits.w = (world.map.bounds.w / MAP_TILE_SIZE) - (VIEW_SIZE_X - MAP_RENDER_WIDTH) - 1;
limits.h = (world.map.bounds.h / MAP_TILE_SIZE) - (VIEW_SIZE_Y - MAP_RENDER_HEIGHT);
limits.w = (world.map.bounds.w / MAP_TILE_SIZE) - (VIEW_SIZE_X - renderWidth) - 1;
limits.h = (world.map.bounds.h / MAP_TILE_SIZE) - (VIEW_SIZE_Y - renderHeight);
viewRect.x = limit(viewRect.x, limits.x, limits.w);
viewRect.y = limit(viewRect.y, limits.y, limits.h);
@ -78,27 +83,30 @@ void initRadar(void)
arrow = getImageFromAtlas("gfx/radar/arrow.png");
/* top */
initMarker(0, SCREEN_WIDTH / 2 - 275, SCREEN_HEIGHT / 2 - 275, 0, M_MIA);
initMarker(1, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 275, 0, M_ITEM);
initMarker(2, SCREEN_WIDTH / 2 + 275, SCREEN_HEIGHT / 2 - 275, 0, M_ENEMY);
initMarker(0, app.config.winWidth / 2 - 275, app.config.winHeight / 2 - 275, 0, M_MIA);
initMarker(1, app.config.winWidth / 2, app.config.winHeight / 2 - 275, 0, M_ITEM);
initMarker(2, app.config.winWidth / 2 + 275, app.config.winHeight / 2 - 275, 0, M_ENEMY);
/* bottom */
initMarker(3, SCREEN_WIDTH / 2 - 275, SCREEN_HEIGHT / 2 + 275, 180, M_MIA);
initMarker(4, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 + 275, 180, M_ITEM);
initMarker(5, SCREEN_WIDTH / 2 + 275, SCREEN_HEIGHT / 2 + 275, 180, M_ENEMY);
initMarker(3, app.config.winWidth / 2 - 275, app.config.winHeight / 2 + 275, 180, M_MIA);
initMarker(4, app.config.winWidth / 2, app.config.winHeight / 2 + 275, 180, M_ITEM);
initMarker(5, app.config.winWidth / 2 + 275, app.config.winHeight / 2 + 275, 180, M_ENEMY);
/* left */
initMarker(6, SCREEN_WIDTH / 2 - 450, SCREEN_HEIGHT / 2 - 200, 270, M_MIA);
initMarker(7, SCREEN_WIDTH / 2 - 450, SCREEN_HEIGHT / 2, 270, M_ITEM);
initMarker(8, SCREEN_WIDTH / 2 - 450, SCREEN_HEIGHT / 2 + 200, 270, M_ENEMY);
initMarker(6, app.config.winWidth / 2 - 450, app.config.winHeight / 2 - 200, 270, M_MIA);
initMarker(7, app.config.winWidth / 2 - 450, app.config.winHeight / 2, 270, M_ITEM);
initMarker(8, app.config.winWidth / 2 - 450, app.config.winHeight / 2 + 200, 270, M_ENEMY);
/* right */
initMarker(9, SCREEN_WIDTH / 2 + 450, SCREEN_HEIGHT / 2 - 200, 90, M_MIA);
initMarker(10, SCREEN_WIDTH / 2 + 450, SCREEN_HEIGHT / 2, 90, M_ITEM);
initMarker(11, SCREEN_WIDTH / 2 + 450, SCREEN_HEIGHT / 2 + 200, 90, M_ENEMY);
initMarker(9, app.config.winWidth / 2 + 450, app.config.winHeight / 2 - 200, 90, M_MIA);
initMarker(10, app.config.winWidth / 2 + 450, app.config.winHeight / 2, 90, M_ITEM);
initMarker(11, app.config.winWidth / 2 + 450, app.config.winHeight / 2 + 200, 90, M_ENEMY);
initBlips();
offset.x = ((app.config.winWidth - (RADAR_TILE_SIZE * VIEW_SIZE_X)) / 2);
offset.y = ((app.config.winHeight - (RADAR_TILE_SIZE * VIEW_SIZE_Y)) / 2);
endSectionTransition();
}
@ -222,7 +230,7 @@ static void logic(void)
static void draw(void)
{
blitRectScaled(atlasTexture->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, &background->rect, 0);
blitRectScaled(atlasTexture->texture, 0, 0, app.config.winWidth, app.config.winHeight, &background->rect, 0);
drawMap();
@ -230,14 +238,14 @@ static void draw(void)
drawMarkers();
drawRect((SCREEN_WIDTH / 2) - 230, SCREEN_HEIGHT - 58, 14, 14, 255, 255, 0, 255);
drawText((SCREEN_WIDTH / 2) - 200, SCREEN_HEIGHT - 65, 20, TA_LEFT, colors.yellow, app.strings[ST_MIAS]);
drawRect((app.config.winWidth / 2) - 230, app.config.winHeight - 58, 14, 14, 255, 255, 0, 255);
drawText((app.config.winWidth / 2) - 200, app.config.winHeight - 65, 20, TA_LEFT, colors.yellow, app.strings[ST_MIAS]);
drawRect((SCREEN_WIDTH / 2) - 30, SCREEN_HEIGHT - 58, 14, 14, 0, 255, 255, 255);
drawText((SCREEN_WIDTH / 2), SCREEN_HEIGHT - 65, 20, TA_LEFT, colors.cyan, app.strings[ST_ITEMS]);
drawRect((app.config.winWidth / 2) - 30, app.config.winHeight - 58, 14, 14, 0, 255, 255, 255);
drawText((app.config.winWidth / 2), app.config.winHeight - 65, 20, TA_LEFT, colors.cyan, app.strings[ST_ITEMS]);
drawRect((SCREEN_WIDTH / 2) + 170, SCREEN_HEIGHT - 58, 14, 14, 255, 0, 0, 255);
drawText((SCREEN_WIDTH / 2) + 200, SCREEN_HEIGHT - 65, 20, TA_LEFT, colors.red, app.strings[ST_TARGETS]);
drawRect((app.config.winWidth / 2) + 170, app.config.winHeight - 58, 14, 14, 255, 0, 0, 255);
drawText((app.config.winWidth / 2) + 200, app.config.winHeight - 65, 20, TA_LEFT, colors.red, app.strings[ST_TARGETS]);
}
static void drawMap(void)
@ -252,7 +260,7 @@ static void drawMap(void)
mx = viewRect.x + x;
my = viewRect.y + y;
drawRect(OFFSET_X + (x * RADAR_TILE_SIZE), OFFSET_Y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, 0, 0, 0, 255);
drawRect(offset.x + (x * RADAR_TILE_SIZE), offset.y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, 0, 0, 0, 255);
if (isWithinMap(mx, my))
{
@ -262,13 +270,13 @@ static void drawMap(void)
{
getMapTileColor(i, &c);
drawRect(OFFSET_X + (x * RADAR_TILE_SIZE), OFFSET_Y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, c.r, c.g, c.b, 255);
drawRect(offset.x + (x * RADAR_TILE_SIZE), offset.y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, c.r, c.g, c.b, 255);
}
}
}
}
drawOutlineRect(OFFSET_X, OFFSET_Y, viewRect.w * RADAR_TILE_SIZE, viewRect.h * RADAR_TILE_SIZE, 0, 128, 0, 255);
drawOutlineRect(offset.x, offset.y, viewRect.w * RADAR_TILE_SIZE, viewRect.h * RADAR_TILE_SIZE, 0, 128, 0, 255);
}
static void getMapTileColor(int i, SDL_Color *c)
@ -324,7 +332,7 @@ static void drawEntities(void)
if (blinkTimer < 30)
{
drawRect(OFFSET_X + (x * RADAR_TILE_SIZE), OFFSET_Y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, c.r, c.g, c.b, 255);
drawRect(offset.x + (x * RADAR_TILE_SIZE), offset.y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, c.r, c.g, c.b, 255);
}
}
}

View File

@ -30,8 +30,6 @@ enum
#define MAX_BLIPS 32
#define MAX_MARKERS 12
#define OFFSET_X ((SCREEN_WIDTH - (RADAR_TILE_SIZE * VIEW_SIZE_X)) / 2)
#define OFFSET_Y ((SCREEN_HEIGHT - (RADAR_TILE_SIZE * VIEW_SIZE_Y)) / 2)
#define RADAR_TILE_SIZE 16
#define VIEW_SIZE_X 50
#define VIEW_SIZE_Y 30

View File

@ -205,13 +205,12 @@ static void draw(void)
{
case WS_PAUSED:
drawNormal();
drawMissionStatus();
drawMissionStatus(0);
break;
case WS_START:
drawNormal();
drawMissionStatus();
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 80, 24, TA_CENTER, colors.white, app.strings[ST_PRESS_FIRE]);
drawMissionStatus(1);
break;
case WS_GAME_OVER:
@ -250,16 +249,20 @@ static void draw(void)
static void drawInGameWidgets(void)
{
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
drawWidgetFrame();
drawWidgets();
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
static void drawNormal(void)
{
blitScaled(background->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
blitScaled(background->texture, 0, 0, app.config.winWidth, app.config.winHeight, 0);
drawEntities(PLANE_BACKGROUND);
@ -455,8 +458,8 @@ static void doWorldObserving(void)
int tx, ty;
float diffX, diffY;
tx = world.entityToTrack->x - (SCREEN_WIDTH / 2);
ty = world.entityToTrack->y - (SCREEN_HEIGHT / 2);
tx = world.entityToTrack->x - (app.config.winWidth / 2);
ty = world.entityToTrack->y - (app.config.winHeight / 2);
doEntitiesStatic();
@ -666,7 +669,7 @@ static void spawnEnemies(void)
y = world.bob->y;
y += ((randF() - randF()) * 5) * MAP_TILE_SIZE;
if (x >= world.map.bounds.x && y >= world.map.bounds.y && x < world.map.bounds.w + SCREEN_WIDTH - 64 && y < world.map.bounds.h + SCREEN_HEIGHT - 64)
if (x >= world.map.bounds.x && y >= world.map.bounds.y && x < world.map.bounds.w + app.config.winWidth - 64 && y < world.map.bounds.h + app.config.winHeight - 64)
{
sprintf(name, "%s%s", world.enemyTypes[r], (rand() % 2 ? "Blob" : "EyeDroid"));
@ -752,7 +755,7 @@ void observeActivation(Entity *e)
world.observationTimer = FPS * 1.5;
return;
}
else if (getDistance(e->x, e->y, world.entitiesToObserve[i]->x, world.entitiesToObserve[i]->y) < SCREEN_HEIGHT - 50)
else if (getDistance(e->x, e->y, world.entitiesToObserve[i]->x, world.entitiesToObserve[i]->y) < app.config.winHeight - 50)
{
return;
}
@ -774,11 +777,11 @@ void drawGameOver(void)
fadeAmount = MIN((world.gameOverTimer + FPS) * -1, 128);
}
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, fadeAmount);
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, fadeAmount);
if (world.gameOverTimer <= -FPS * 2)
{
blitRect(atlasTexture->texture, SCREEN_WIDTH / 2, 240, &missionFailed->rect, 1);
blitRect(atlasTexture->texture, app.config.winWidth / 2, 240, &missionFailed->rect, 1);
if (world.gameOverTimer <= -FPS * 3)
{
@ -793,40 +796,44 @@ void drawQuit(void)
{
SDL_Rect r;
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128);
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
r.w = 650;
r.h = 325;
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
r.x = (UI_WIDTH / 2) - r.w / 2;
r.y = (UI_HEIGHT / 2) - r.h / 2;
drawRect(r.x, r.y, r.w, r.h, 0, 0, 0, 192);
drawOutlineRect(r.x, r.y, r.w, r.h, 200, 200, 200, 255);
limitTextWidth(r.w - 100);
drawText(SCREEN_WIDTH / 2, r.y + 10, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_HUB]);
drawText(UI_WIDTH / 2, r.y + 10, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_HUB]);
if (world.missionType == MT_TRAINING)
{
drawText(SCREEN_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_TUTORIAL]);
drawText(UI_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_TUTORIAL]);
}
else if (game.isComplete)
{
drawText(SCREEN_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_FREE_PLAY]);
drawText(UI_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_FREE_PLAY]);
}
else if (world.isReturnVisit)
{
drawText(SCREEN_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_SAVE]);
drawText(UI_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_SAVE]);
}
else
{
drawText(SCREEN_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_LOSE]);
drawText(UI_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_LOSE]);
}
limitTextWidth(0);
drawWidgets();
SDL_SetRenderTarget(app.renderer, app.backBuffer);
}
void exitRadar(void)

View File

@ -61,7 +61,7 @@ extern void doWidgets(void);
extern void drawEntities(int plane);
extern void drawHud(void);
extern void drawMap(void);
extern void drawMissionStatus(void);
extern void drawMissionStatus(int showFirePrompt);
extern void drawOutlineRect(int x, int y, int w, int h, int r, int g, int b, int a);
extern void drawParticles(int plane);
extern void drawRect(int x, int y, int w, int h, int r, int g, int b, int a);