Skip to content

Commit

Permalink
Push for v0.12.0b
Browse files Browse the repository at this point in the history
  • Loading branch information
123outerme committed Aug 16, 2018
1 parent dea4332 commit ccf07b1
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 31 deletions.
8 changes: 7 additions & 1 deletion SDLGateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,13 +1136,19 @@ bool executeScriptAction(script* scriptData, player* player)
{
if (scriptData->action == script_trigger_dialogue || scriptData->action == script_trigger_dialogue_once || scriptData->action == script_force_dialogue)
{
drawTextBox(scriptData->data, (SDL_Color){0, 0, 0, 0xFF}, (SDL_Rect){.x = 0, .y = 9 * TILE_SIZE * (player->spr.y < 9 * TILE_SIZE), .w = SCREEN_WIDTH, .h = (HEIGHT_IN_TILES - 9) * TILE_SIZE}, true);
drawTextBox(scriptData->data, (SDL_Color){0, 0, 0, 0xFF}, (SDL_Rect){.x = 0, .y = 9 * TILE_SIZE * (player->spr.y < 8 * TILE_SIZE), .w = SCREEN_WIDTH, .h = (HEIGHT_IN_TILES - 9) * TILE_SIZE}, true);
SWING_CHANNEL = Mix_PlayChannel(-1, SWING_SOUND, 0);
waitForKey(true);
SWING_CHANNEL = Mix_PlayChannel(SWING_CHANNEL, SWING_SOUND, 0);
if (scriptData->action == script_trigger_dialogue_once)
{
scriptData->disabled = true;
player->disabledScripts[scriptData->lineNum] = true; //disable permanently
}
if (scriptData->action == script_trigger_dialogue)
{
_globalInt1 = 5; //5 frames of cooldown before you can talk again... used to ensure pressing space works to close the textbox
}
}
if (scriptData->action == script_trigger_boss)
{
Expand Down
2 changes: 2 additions & 0 deletions SDLGateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ int FPS, targetTime, startTime, frame;
bool doorFlags[4];
bool noclip;

int _globalInt1, _globalInt2, _globalInt3; //for general use purposes

char mainFilePath[MAX_FILE_PATH], mapFilePath[MAX_FILE_PATH - 9], tileFilePath[MAX_FILE_PATH - 9],
saveFilePath[MAX_FILE_PATH - 9], scriptFilePath[MAX_FILE_PATH - 9];

Expand Down
21 changes: 15 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int toolchain_main();

#define ALL_TECHNIQUES {"Dash", "Spin", "Illusion", "Laser", "Charge"}

#define HELP_MENU_TEXT1 "Gateway to Legend\nis an Action-Puzzle game. Use (default) [WASD]+[Space]+[L-Shift]+[Esc]\n to maneuver various worlds."
#define HELP_MENU_TEXT1 "Gateway to Legend\nis an Action-Puzzle game. Use (default)\n[WASD]+[Space]\n+[L-Shift]+[Esc]\n to maneuver various worlds."
#define HELP_MENU_TEXT2 "Play and create different map-packs! You can create engaging content and play others' content as well!"
#define HELP_MENU_TEXT3 "Made by:\nStephen Policelli"
/* search this
Expand All @@ -77,8 +77,6 @@ bool loadBoss;
script* allScripts;
int sizeOfAllScripts;

int _globalInt1, _globalInt2, _globalInt3; //for general use purposes

bool debugFlag;
Sint64 gameTicks;

Expand Down Expand Up @@ -140,6 +138,7 @@ int main(int argc, char* argv[])
SDL_SetRenderDrawColor(mainRenderer, AMENU_MAIN_TEXTCOLOR);
int key = 0;
while(!key)
//while(key != SDLK_SPACE) //uncomment for videos
{
SDL_RenderClear(mainRenderer);
SDL_RenderCopy(mainRenderer, titlescreen, NULL, NULL);
Expand Down Expand Up @@ -599,7 +598,8 @@ bool upgradeShop(player* playerSprite)
_globalInt1 = playerSprite->money;
_globalInt2 = coinsPerTech;
int retCode = aMenu(tilesetTexture, MAIN_ARROW_ID, "Buy Abilities", (char**) techniqueArray, nextPos, 0, AMENU_MAIN_THEME, true, false, aMenu_drawMoney);

_globalInt1 = 0;
_globalInt2 = 0;
if (retCode == ANYWHERE_QUIT || retCode == nextPos)
{
bQuit = true;
Expand Down Expand Up @@ -1918,11 +1918,13 @@ int mainLoop(player* playerSprite)
{
thisScript = theseScripts[i];
thisScript->active = true;
if (thisScript->disabled || (((thisScript->action == script_trigger_dialogue || thisScript->action == script_trigger_dialogue_once) && !checkSKInteract) || (thisScript->action == script_trigger_boss && (bossLoaded || !bossUndefeated))))
if (thisScript->disabled || (((thisScript->action == script_trigger_dialogue || thisScript->action == script_trigger_dialogue_once) && (!checkSKInteract || _globalInt1 != 0)) || (thisScript->action == script_trigger_boss && (bossLoaded || !bossUndefeated))))
thisScript->active = false;
else
break;
}
if (_globalInt1 > 0)
_globalInt1--;
}
}

Expand Down Expand Up @@ -1980,11 +1982,16 @@ int mainLoop(player* playerSprite)
spinCycle = (spinCycle + 1) % 24;
//e

if (!((thisScript->action == script_trigger_dialogue || thisScript->action == script_trigger_dialogue_once) && thisScript->active) && initSword)
if (!((thisScript->action == script_trigger_dialogue || thisScript->action == script_trigger_dialogue_once) && (thisScript->active == 1 || _globalInt1 > 0)) && initSword)
{
if (swordTimer <= 0)
swordTimer = SDL_GetTicks() + 750 + 150 * (spinCycle > 0) - 150 * (laserTimer > 0);
}
else
{
if (!(spinCycle || laserTimer || swordTimer))
Mix_HaltChannel(SWING_CHANNEL);
}
initSword = false;
}
if (playerSprite->invincCounter)
Expand Down Expand Up @@ -2086,6 +2093,8 @@ int mainLoop(player* playerSprite)
thisScript->active = 0;
}

_globalInt1 = 0;

if (playerSprite->HP < 1)
{
exitCode = 5 - gameOver();
Expand Down
5 changes: 3 additions & 2 deletions mainToolchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,8 @@ script visualLoadScript(mapPack* workingPack)
script loadedScript;
bool quit = false;
char* temp = "";
int scriptLineNum = 0, maxLines = checkFile(workingPack->mapFilePath, -1);
int scriptLineNum = 0, maxLines = checkFile(workingPack->scriptFilePath, -1);
printf("%d\n", maxLines); //this is wrong I think!
readScript(&loadedScript, readLine(workingPack->scriptFilePath, scriptLineNum, &temp), 0);
SDL_Keycode key;
while(!quit)
Expand All @@ -1703,7 +1704,7 @@ script visualLoadScript(mapPack* workingPack)

if (key == SDL_GetKeyFromScancode(SC_DOWN))
{
if (scriptLineNum < maxLines)
if (scriptLineNum < maxLines - 10)
scriptLineNum += 10;
readScript(&loadedScript, readLine(workingPack->scriptFilePath, scriptLineNum, &temp), scriptLineNum);
}
Expand Down
16 changes: 8 additions & 8 deletions outermeSDL.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ int createFile(char* filePath)
*
* Checks if a file exists and/or if it has the desired number of lines. desiredLines < 0 -> get number of lines instead.
*/
bool checkFile(char* filePath, int desiredLines)
int checkFile(char* filePath, int desiredLines)
{
FILE* filePtr = fopen(filePath, "r");
if (!filePtr)
Expand All @@ -356,11 +356,11 @@ bool checkFile(char* filePath, int desiredLines)
int lines = 0;
while(!feof(filePtr))
{
ch = fgetc(filePtr);
if(ch == '\n')
{
lines++;
}
ch = fgetc(filePtr);
if(ch == '\n' || ch == '\r')
{
lines++;
}
}
fclose(filePtr);
return desiredLines >= 0 ? lines >= desiredLines : lines;
Expand Down Expand Up @@ -390,10 +390,10 @@ char* readLine(char* filePath, int lineNum, char** output)
return NULL;
else
{
char* thisLine = calloc(2048, sizeof(char));
char* thisLine = calloc(4096, sizeof(char));
fseek(filePtr, 0, SEEK_SET);
for(int p = 0; p <= lineNum; p++)
fgets(thisLine, 2048, filePtr);
fgets(thisLine, 4096, filePtr);
//printf("%s @ %d\n", thisLine, thisLine);
*output = thisLine;
//printf("%s @ %d\n", output, output);
Expand Down
2 changes: 1 addition & 1 deletion outermeSDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void closeSDL(); //closes SDL and related stuff
int intSeqSearch(int value, int array[], size_t arraySize); //finds an int in an int array
char* removeChar(char input[], char removing, size_t length, bool foreToBack); //removes the the first specified character from a string
int createFile(char* filePath); //creates a file if it doesn't exist; if it does, clears it out
bool checkFile(char* filePath, int desiredLines); //checks if a file exists with a certain number of lines. 0 for any.
int checkFile(char* filePath, int desiredLines); //checks if a file exists with a certain number of lines. 0 for any.
int appendLine(char* filePath, char* stuff); //appends a line to a file
char* readLine(char* filePath, int lineNum, char** output); //reads a certain line from a file

Expand Down
6 changes: 3 additions & 3 deletions saves/GATEWAY_MAIN.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Stevos
12
20
1
50
{0,0,0,0,0}
31
{2,0,0,2,0}
18 changes: 9 additions & 9 deletions saves/MainAdventure.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
5
786
366
12
5
912
360
{22,5}
{0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
3
414
486
16
8
138
132
{22,-1}
{0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
2 changes: 1 addition & 1 deletion scripts/MainAdventure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{6,3,336,192,48,48,[9/432/336]}
{6,8,96,96,48,48,[3/288/624]} ;Transports the player to a different map with animations on map 8
{1,8,468,324,72,72,The Gateways, they're like magic, don't you think? Whoever is behind this, they're good.} ;Triggers a textbox after Interact is pressed on map 8
{1,12,96,432,144,144,Only one being has learned these spells before... I was almost fried by his power.} ;Triggers a textbox after Interact is pressed on map 12
{1,12,120,456,96,96,Only one has used these spells before... and I was almost fried by his power. Careful.} ;Triggers a textbox after Interact is pressed on map 12
{7,13,288,336,48,48,[576/288]} ;Teleports a player to a location on the same map on map 13
{7,13,576,336,48,48,[288/288]} ;Teleports a player to a location on the same map on map 13
{8,5,240,192,48,288,[-1/1/-1/-1]} ;Opens some doors on map 5
Expand Down

0 comments on commit ccf07b1

Please sign in to comment.