Added effects reduction option for game speed up

This commit is contained in:
George Sokianos 2022-08-21 23:49:36 +01:00
parent 69b714860b
commit 3b3fe085fa
7 changed files with 140 additions and 2 deletions

View File

@ -1,6 +1,7 @@
{
"winWidth" : 1280,
"winHeight" : 720,
"effects" : 0,
"fullscreen" : 0,
"musicVolume" : 8,
"soundVolume" : 10,
@ -41,3 +42,4 @@
"healthBars" : 1
}
}

View File

@ -10,6 +10,17 @@
"w" : 400,
"h": 34
},
{
"name" : "effects",
"group" : "options",
"type" : "WT_SELECT",
"text" : "Effects Reduction",
"options" : "0;1;2",
"x" : -1,
"y" : 225,
"w" : 400,
"h": 34
},
{
"name" : "soundVolume",
"group" : "options",
@ -17,7 +28,7 @@
"text" : "Sound Volume",
"options" : "0;1;2;3;4;5;6;7;8;9;10",
"x" : -1,
"y" : 250,
"y" : 275,
"w" : 400,
"h": 34
},
@ -64,3 +75,4 @@
"h": 34
}
]

View File

@ -203,6 +203,10 @@ void addBulletHitEffect(int x, int y, int r, int g, int b)
e->type = EFFECT_TEXTURE;
e->texture = explosionTexture;
e->size = 16;
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->x = x;
e->y = y;
@ -216,6 +220,10 @@ void addBulletHitEffect(int x, int y, int r, int g, int b)
e->b = b;
e->a = 64;
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
}
}
@ -234,11 +242,19 @@ void addSmallFighterExplosion(void)
e->y = self->y + (rand() % 16 - rand() % 16);
e->texture = explosionTexture;
e->size = 32;
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
setRandomFlameHue(e);
e->a = 128 + (rand() % 128);
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -259,11 +275,19 @@ void addDebrisFire(int x, int y)
e->y = y + (rand() % 8 - rand() % 8);
e->texture = explosionTexture;
e->size = 4 + rand() % 12;
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
setRandomFlameHue(e);
e->a = rand() % 256;
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -291,12 +315,20 @@ void addSmallExplosion(void)
e->dy *= 0.025;
e->texture = explosionTexture;
e->size = 32 + (rand() % 64);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 255;
setRandomFlameHue(e);
e->a = 128 + (rand() % 128);
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -319,6 +351,10 @@ void addSmallExplosion(void)
e->a = 128;
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
setRandomFlameHue(e);
}
@ -342,12 +378,20 @@ void addMineExplosion(void)
e->y = self->y + rand() % 64 - rand() % 64;
e->texture = explosionTexture;
e->size = 64 + (rand() % 64);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 255;
setRandomFlameHue(e);
e->a = 32 + (rand() % 192);
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -363,6 +407,10 @@ void addMineExplosion(void)
e->x = self->x;
e->y = self->y;
e->size = 64;
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->scaleAmount = 6;
e->texture = haloTexture;
@ -372,6 +420,10 @@ void addMineExplosion(void)
e->a = 128;
e->health = 128;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
}
void addLargeExplosion(void)
@ -396,12 +448,20 @@ void addLargeExplosion(void)
e->dy *= 0.01;
e->texture = explosionTexture;
e->size = 128 + (rand() % 512);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 255;
setRandomFlameHue(e);
e->a = 128 + (rand() % 128);
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -417,6 +477,10 @@ void addLargeExplosion(void)
e->x = self->x;
e->y = self->y;
e->size = 256;
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->scaleAmount = 4;
e->texture = haloTexture;
@ -426,6 +490,10 @@ void addLargeExplosion(void)
e->a = 255;
e->health = 255;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
}
void addMissileExplosion(Bullet *b)
@ -450,12 +518,20 @@ void addMissileExplosion(Bullet *b)
e->dy *= 0.025;
e->texture = explosionTexture;
e->size = 32 + (rand() % 64);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 255;
setRandomFlameHue(e);
e->a = 128 + (rand() % 128);
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -478,6 +554,10 @@ void addMissileExplosion(Bullet *b)
e->a = 128;
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
setRandomFlameHue(e);
}
@ -508,12 +588,20 @@ void addEngineEffect(void)
e->texture = explosionTexture;
e->size = 16;
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 128;
e->g = 128;
e->b = 255;
e->a = 64;
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -541,12 +629,20 @@ void addLargeEngineEffect(void)
e->texture = explosionTexture;
e->size = 64;
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 128;
e->g = 128;
e->b = 255;
e->a = 64;
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -574,10 +670,18 @@ void addMissileEngineEffect(Bullet *b)
e->texture = explosionTexture;
e->size = 12;
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
setRandomFlameHue(e);
e->a = 128;
e->health = e->a;
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2;
e->y -= e->size / 2;
@ -695,3 +799,4 @@ void destroyEffects(void)
effectsToDraw = NULL;
}

View File

@ -80,7 +80,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define NUM_ATLAS_BUCKETS 64
#define NUM_GLYPH_BUCKETS 128
#define MAX_STARS 500
#define MAX_STARS 250
#define MAX_CHALLENGES 3
@ -421,3 +421,4 @@ enum
TROPHY_UNEARNED,
TROPHY_MAX
};

View File

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "options.h"
static void changeWindowSize(char *value);
static void changeEffectsReduction(char *value);
static void changeSoundVolume(char *value);
static void changeMusicVolume(char *value);
static void changeFullscreen(char *value);
@ -41,6 +42,7 @@ void initOptions(void (*rtn)(void))
selectWidget("windowSize", "options");
getWidget("windowSize", "options")->onChange = changeWindowSize;
getWidget("effects", "options")->onChange = changeEffectsReduction;
getWidget("soundVolume", "options")->onChange = changeSoundVolume;
getWidget("musicVolume", "options")->onChange = changeMusicVolume;
getWidget("fullscreen", "options")->onChange = changeFullscreen;
@ -51,6 +53,9 @@ void initOptions(void (*rtn)(void))
sprintf(optionStr, "%d x %d", app.winWidth, app.winHeight);
setWidgetOption("windowSize", "options", optionStr);
sprintf(optionStr, "%d", app.effects);
setWidgetOption("effects", "options", optionStr);
sprintf(optionStr, "%d", app.soundVolume);
setWidgetOption("soundVolume", "options", optionStr);
@ -172,6 +177,13 @@ static void changeWindowSize(char *value)
initStars();
}
static void changeEffectsReduction(char *value)
{
app.effects = atoi(value);
// Mix_Volume(-1, app.effects * MIX_MAX_VOLUME / 10);
}
static void changeSoundVolume(char *value)
{
app.soundVolume = atoi(value);
@ -204,3 +216,4 @@ static void controlsOK(void)
{
show = SHOW_MAIN;
}

View File

@ -521,6 +521,7 @@ typedef struct {
int keyControls[CONTROL_MAX];
int mouseControls[CONTROL_MAX];
int textWidth;
int effects;
} App;
typedef struct {
@ -576,3 +577,4 @@ typedef struct {
typedef struct {
int32_t length, offset;
} MOEntry;

View File

@ -229,6 +229,7 @@ static void loadConfigFile(char *filename)
app.winWidth = cJSON_GetObjectItem(root, "winWidth")->valueint;
app.winHeight = cJSON_GetObjectItem(root, "winHeight")->valueint;
app.effects = cJSON_GetObjectItem(root, "effects")->valueint;
app.fullscreen = cJSON_GetObjectItem(root, "fullscreen")->valueint;
app.musicVolume = cJSON_GetObjectItem(root, "musicVolume")->valueint;
app.soundVolume = cJSON_GetObjectItem(root, "soundVolume")->valueint;
@ -284,6 +285,7 @@ void saveConfig(void)
root = cJSON_CreateObject();
cJSON_AddNumberToObject(root, "winWidth", app.winWidth);
cJSON_AddNumberToObject(root, "winHeight", app.winHeight);
cJSON_AddNumberToObject(root, "effects", app.effects);
cJSON_AddNumberToObject(root, "fullscreen", app.fullscreen);
cJSON_AddNumberToObject(root, "musicVolume", app.musicVolume);
cJSON_AddNumberToObject(root, "soundVolume", app.soundVolume);
@ -383,3 +385,4 @@ void cleanup(void)
SDL_Quit();
}