Skip to content

Commit

Permalink
Fully fixed boss door, maps, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
123outerme committed Jun 24, 2018
1 parent 3e2ae13 commit 288460d
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 35 deletions.
10 changes: 7 additions & 3 deletions SDLGateway.c
Expand Up @@ -1108,18 +1108,22 @@ bool executeScriptAction(script* scriptData, player* player)
{ //-1 = unchanged, 0 = open, 1 = closed
char* data = calloc(99, sizeof(char));
bool oldDoorFlags[4] = {doorFlags[0], doorFlags[1], doorFlags[2], doorFlags[3]};
bool newDoorFlags[4] = {-1, -1, -1, doorFlags[3]};
bool newDoorFlags[4] = {-1, -1, -1, -1};
newDoorFlags[0] = strtol(strtok(strncpy(data, scriptData->data, 99), "[/]"), NULL, 10);
for(int i = 0; i < 3; i++)
for(int i = 0; i < 4; i++)
{
if (i > 0)
newDoorFlags[i] = strtol(strtok(NULL, "[/]"), NULL, 10);
printf("%d/", newDoorFlags[i]);
if (newDoorFlags[i] > -1) //set
doorFlags[i] = newDoorFlags[i];
if (newDoorFlags[i] == -2) //flip
doorFlags[i] = !doorFlags[i];

}
if (oldDoorFlags[0] != doorFlags[0] || oldDoorFlags[1] != doorFlags[1] || oldDoorFlags[2] != doorFlags[2])
printf("\n");
printf("%d/%d/%d/%d\n", oldDoorFlags[0], oldDoorFlags[1], oldDoorFlags[2], oldDoorFlags[3]);
if (oldDoorFlags[0] != doorFlags[0] || oldDoorFlags[1] != doorFlags[1] || oldDoorFlags[2] != doorFlags[2] || oldDoorFlags[3] != doorFlags[3])
Mix_PlayChannel(-1, DOOROPEN_SOUND, 0);
free(data);
}
Expand Down
34 changes: 22 additions & 12 deletions main.c
Expand Up @@ -1106,18 +1106,27 @@ int mainLoop(player* playerSprite)
}
}
}
else
{
script openDoors;
initScript(&openDoors, script_toggle_door, 0, 0, 0, 0, 0, "[-1/-1/-1/0]");
executeScriptAction(&openDoors, playerSprite);
}
checkCollision(playerSprite, collisionData, 1, 1, playerSprite->spr.x, playerSprite->spr.y);
if (collisionData[4] || collisionData[5] || collisionData[6])
if (collisionData[4] || collisionData[5] || collisionData[6] || collisionData[7])
{ //if player spawns on top of door
script openDoors;
if (collisionData[4])
initScript(&openDoors, script_toggle_door, 0, 0, 0, 0, 0, "[0/-1/-1]");
initScript(&openDoors, script_toggle_door, 0, 0, 0, 0, 0, "[0/-1/-1/-1]");

if (collisionData[5])
initScript(&openDoors, script_toggle_door, 0, 0, 0, 0, 0, "[-1/0/-1]");
initScript(&openDoors, script_toggle_door, 0, 0, 0, 0, 0, "[-1/0/-1/-1]");

if (collisionData[6])
initScript(&openDoors, script_toggle_door, 0, 0, 0, 0, 0, "[-1/-1/0]");
initScript(&openDoors, script_toggle_door, 0, 0, 0, 0, 0, "[-1/-1/0/-1]");

if (collisionData[7])
initScript(&openDoors, script_toggle_door, 0, 0, 0, 0, 0, "[-1/-1/-1/0]");

executeScriptAction(&openDoors, playerSprite);
}
Expand Down Expand Up @@ -1353,7 +1362,7 @@ int mainLoop(player* playerSprite)
{
script openDoorScript;
char* data = calloc(99, sizeof(char));
snprintf(data, 99, "[%d/%d/%d]", newDoorFlags[0], newDoorFlags[1], newDoorFlags[2]);
snprintf(data, 99, "[%d/%d/%d/-1]", newDoorFlags[0], newDoorFlags[1], newDoorFlags[2]);
initScript(&openDoorScript, script_toggle_door, 0, 0, 0, 0, 0, data);
executeScriptAction(&openDoorScript, playerSprite);
free(data);
Expand Down Expand Up @@ -1420,10 +1429,10 @@ int mainLoop(player* playerSprite)
}

if (!strncmp(command, "opendoors", 50))
initScript(&exec, script_toggle_door, 0, 0, 0, 0, 0, "[0/0/0]"); //opens all doors
initScript(&exec, script_toggle_door, 0, 0, 0, 0, 0, "[0/0/0/0]"); //opens all doors

if (!strncmp(command, "closedoors", 50))
initScript(&exec, script_toggle_door, 0, 0, 0, 0, 0, "[1/1/1]"); //closes all doors
initScript(&exec, script_toggle_door, 0, 0, 0, 0, 0, "[1/1/1/1]"); //closes all doors

if (!strncmp(command, "hurt", 4))
initScript(&exec, script_player_hurt, 0, 0, 0, 0, 0, strtok(commandCpy, "hurt "));
Expand Down Expand Up @@ -1608,14 +1617,15 @@ int mainLoop(player* playerSprite)
{
bossSprite.spr.type = type_na;
script bossDeadScript;
initScript(&bossDeadScript, script_toggle_door, 0, 0, 0, 0, 0, "[0/0/0]"); //opens all doors
initScript(&bossDeadScript, script_toggle_door, 0, 0, 0, 0, 0, "[0/0/0/0]"); //opens all doors
executeScriptAction(&bossDeadScript, playerSprite);
initScript(&bossDeadScript, script_gain_money, 0, 0, 0, 0, 0, "15"); //boss should probably become money, "dropping" it
executeScriptAction(&bossDeadScript, playerSprite);
initSpark(&theseSparks[7], (SDL_Rect) {playerSprite->spr.x, playerSprite->spr.y, TILE_SIZE, TILE_SIZE}, SPARK_BOSS, 6, 8, 8, framerate / 2, framerate / 4);
sparkFlag = true;
theseSparkFlags[7] = true;
playerSprite->defeatedBosses[playerSprite->nextBossPos++] = playerSprite->mapScreen;

Mix_PlayMusic(MUSIC((musicIndex = 6)), 0); //fanfare
Mix_HookMusicFinished(playOverworldMusic);
}
Expand Down Expand Up @@ -1674,12 +1684,12 @@ int mainLoop(player* playerSprite)

if (drawFPS)
drawText(intToString(framerate, whatever), 0, 0, SCREEN_WIDTH, TILE_SIZE, (SDL_Color){0xFF, 0xFF, 0xFF, 0xFF}, false);

if (animationSpr.x >= 0)
{
drawATile(tilesTexture, animationSpr.tileIndex, animationSpr.x, animationSpr.y, animationSpr.w, animationSpr.h, animationSpr.angle, animationSpr.flip);
}

drawATile(tilesTexture, tileIDArray[(playerSprite->animationCounter > 0)], playerSprite->spr.x, playerSprite->spr.y, playerSprite->spr.w, playerSprite->spr.h, playerSprite->spr.angle, playerSprite->spr.flip);

for(int i = 0; i < enemyCount; i++)
Expand Down Expand Up @@ -1842,8 +1852,8 @@ void drawOverTilemap(SDL_Texture* texture, int anEventmap[][WIDTH_IN_TILES], int
for(int y = startY; y < endY; y++)
for(int x = startX; x < endX; x++)
{
searchIndex = anEventmap[y][x] + 5 - (anEventmap[y][x] > 0); //search index for these tiles is beyond HUD/player slots-> Minus 1 because there's only 1 index for invis tile but two cases right next to each other that need it
if (((searchIndex == 9 || searchIndex == 10 || searchIndex == 11 || searchIndex == 12) && drawDoors[searchIndex < 12 ? searchIndex - 9 : 0] == false) || (searchIndex == 16 || searchIndex == 17 || searchIndex == 18)) //8,9,10,11 are the door indexes
searchIndex = anEventmap[y][x] + 5 - (anEventmap[y][x] > 0); //search index for these tiles is beyond HUD/player slots -> Minus 1 because there's only 1 index for invis tile but two cases right next to each other that need it
if (((searchIndex == 9 || searchIndex == 10 || searchIndex == 11 || searchIndex == 12) && drawDoors[searchIndex < 13 ? searchIndex - 9 : 0] == false) || (searchIndex == 16 || searchIndex == 17 || searchIndex == 18)) //8,9,10,11 are the door indexes <- this may be old
searchIndex = 5; //5 is index for invis tile
drawATile(texture, tileIDArray[searchIndex], x * TILE_SIZE + xOffset, y * TILE_SIZE + yOffset, TILE_SIZE, TILE_SIZE, 0, SDL_FLIP_NONE);
}
Expand Down
6 changes: 3 additions & 3 deletions mainToolchain.c
Expand Up @@ -537,12 +537,12 @@ script* mainMapCreatorLoop(player* playerSprite, int* scriptCount, mapPack worki
eventmap[playerSprite->spr.y / TILE_SIZE][playerSprite->spr.x / TILE_SIZE] = playerSprite->spr.tileIndex;
if (playerSprite->spr.tileIndex > 11 && playerSprite->spr.tileIndex < 15) //enemies
{

if ((playerSprite->spr.tileIndex > 11 && playerSprite->spr.tileIndex < 15) && !(prevTile > 11 && prevTile < 15) && enemyCount < MAX_ENEMIES)
enemyCount++;
printf("There are now %d enemies.\n", enemyCount);
}

if (prevTile > 11 && prevTile < 15)
{
if (!(playerSprite->spr.tileIndex > 11 && playerSprite->spr.tileIndex < 15))
Expand Down Expand Up @@ -1128,7 +1128,7 @@ script mainScriptLoop(mapPack workingPack, script* editScript)
drawATile(workingPack.mapPackTexture, cursor.tileIndex, cursor.x, cursor.y, TILE_SIZE, TILE_SIZE, 0, (cursor.y < TILE_SIZE * 8 ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE));
SDL_RenderPresent(mainRenderer);
}
snprintf(data, 9, "%d/%d/%d", newDoors[0], newDoors[1], newDoors[2]);
snprintf(data, 9, "%d/%d/%d/-1", newDoors[0], newDoors[1], newDoors[2]);
}

if (editScript->action == script_animation)
Expand Down
2 changes: 1 addition & 1 deletion maps/MainMaps.txt
@@ -1,6 +1,6 @@
01080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080A00010801080108010801080108010801080108010800000000010801080000000001080108000000000000000000000000010801080108010801080000000000000000000000000000010800000000000000000000000000000000010801080108000000000000000000000000000000000108000000000000000000000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000000000000000000010800000000000000000000000000000A0001080108000000000000000000000000000000000000010800000000000000000000000000000108010801080000000000000000000000000000000000000108000000000000000000000000000001080108000000000000000000000000000000000000000001080108000000000000000000000000000000000000000000000A000000000000000000000000000108010801080000000000000000000000000000010801080108010801080A000000000000000000010801080108010801080000000001080108010801080108010801080108010801080000000000000108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108
0108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108000000000000000000000000000001080108010801080108010801080108010801080108010801080000000000000000000000000000000000000000010801080108010801080108010801080108010800000000000000000000000001080108010800000000000001080108010801080108010801080108000000000000000000000108010801080108010801080000000001080108010801080108010801080000000000000000010801080000000000000C0001080108000000000000000001080108010801080000000000000000010801080000000000000000000001080108000000000000000001080108010800000000000000000000000000000000000000000000000001080108000000000000010801080108000000000000000000000000000000000000000000000108010801080108000000000108010801080000000000000000000000000000000000000000000000000108010801080000000000000108010800000000000000000000000000000000000000000000000000000000000000000000000001080108000000000000010801080108010801080108010801080000000000000000000000000000010801080108010801080108010801080108010801080108010801080000000000000000000000000108010801080108010801080108010801080108010801080108010800000000000000000000000001080108
010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B0C0B010B010B010900010001000101090109000100010001000101090109010B0C0B010901090109010B01090109000100010001000100010001000100010001000100010001010B010B010900010001000100010001000109010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000109010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0001000100010001000100010001000100010001000100010001000100010001000100010001010B000100010A010001000100010001000100010001000100010001000100010D01000100010001010B0001000100010001000100010001000100010001000100010109000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000109010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001
010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B0D0B010B010B010900010001000101090109000100010001000101090109010B0D0B010901090109010B01090109000100010001000100010001000100010001000100010001010B010B01090001000100010001000100010A010001000100010001000100010001000100010001010B010900010001000100010001000100010001000100010A010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0001000100010001000100010001000100010001000100010001000100010001000100010001010B000100010B010001000100010001000100010001000100010001000100010E01000100010001010B0001000100010001000100010001000100010001000100010109000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B010900010001000100010001000100010A010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001



Expand Down
2 changes: 1 addition & 1 deletion output/map.txt
@@ -1 +1 @@
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B0D0B010B010B010900010001000101090109000100010001000101090109010B0D0B010901090109010B01090109000100010001000100010001000100010001000100010001010B010B01090001000100010001000100010A010001000100010001000100010001000100010001010B010900010001000100010001000100010001000100010A010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0001000100010001000100010001000100010001000100010001000100010001000100010001010B000100010B010001000100010001000100010001000100010001000100010E01000100010001010B0001000100010001000100010001000100010001000100010109000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B010900010001000100010001000100010A010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001
2 changes: 1 addition & 1 deletion saves/GATEWAY_MAIN.txt
@@ -1,5 +1,5 @@
Steve
12
1
115
145
{2,0,0,0,1}
14 changes: 7 additions & 7 deletions saves/MainAdventure.txt
@@ -1,8 +1,8 @@
10
420
414
1
11
474
300
{-1}
522
336
12
2
126
378
{22}
10 changes: 5 additions & 5 deletions saves/testArea.txt
@@ -1,8 +1,8 @@
1
654
282
12
0
360
474
10
-1
-1
-1
{-1,-1}
{0,-1}
4 changes: 2 additions & 2 deletions scripts/MainAdventure.txt
@@ -1,8 +1,8 @@
{6,11,432,336,48,48,[10/432/336]}
{6,10,432,240,48,48,[11/432/432]}
{1,10,96,240,144,96,You saw it too? Yeah, I don't know what brought us here. Some kind of spacetime anomaly?}
{8,22,474,48,198,240,1/0/-1}
{8,22,474,432,198,240,0/1/-1}
{8,22,474,48,198,240,[1/0/-1/-1]}
{8,22,474,432,198,240,[0/1/-1/-1]}
{10,22,528,144,96,96,[48/5](528|444|50|528|144|50)}
{4,22,192,48,192,624,5}
{9,21,576,192,192,240,[576/528/96/96/48/0](960|528|60)<...>}
Expand Down

0 comments on commit 288460d

Please sign in to comment.