diff --git a/SDLGateway.c b/SDLGateway.c index 13149e5..5ee5407 100644 --- a/SDLGateway.c +++ b/SDLGateway.c @@ -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); } diff --git a/main.c b/main.c index 47a599e..3b7a2fc 100644 --- a/main.c +++ b/main.c @@ -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); } @@ -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); @@ -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 ")); @@ -1608,7 +1617,7 @@ 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); @@ -1616,6 +1625,7 @@ int mainLoop(player* playerSprite) sparkFlag = true; theseSparkFlags[7] = true; playerSprite->defeatedBosses[playerSprite->nextBossPos++] = playerSprite->mapScreen; + Mix_PlayMusic(MUSIC((musicIndex = 6)), 0); //fanfare Mix_HookMusicFinished(playOverworldMusic); } @@ -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++) @@ -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); } diff --git a/mainToolchain.c b/mainToolchain.c index 9631e65..c37f18d 100644 --- a/mainToolchain.c +++ b/mainToolchain.c @@ -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)) @@ -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) diff --git a/maps/MainMaps.txt b/maps/MainMaps.txt index 39e9590..6577808 100644 --- a/maps/MainMaps.txt +++ b/maps/MainMaps.txt @@ -1,6 +1,6 @@ 01080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080A00010801080108010801080108010801080108010800000000010801080000000001080108000000000000000000000000010801080108010801080000000000000000000000000000010800000000000000000000000000000000010801080108000000000000000000000000000000000108000000000000000000000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000000000000000000010800000000000000000000000000000A0001080108000000000000000000000000000000000000010800000000000000000000000000000108010801080000000000000000000000000000000000000108000000000000000000000000000001080108000000000000000000000000000000000000000001080108000000000000000000000000000000000000000000000A000000000000000000000000000108010801080000000000000000000000000000010801080108010801080A000000000000000000010801080108010801080000000001080108010801080108010801080108010801080000000000000108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108 0108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108010801080108000000000000000000000000000001080108010801080108010801080108010801080108010801080000000000000000000000000000000000000000010801080108010801080108010801080108010800000000000000000000000001080108010800000000000001080108010801080108010801080108000000000000000000000108010801080108010801080000000001080108010801080108010801080000000000000000010801080000000000000C0001080108000000000000000001080108010801080000000000000000010801080000000000000000000001080108000000000000000001080108010800000000000000000000000000000000000000000000000001080108000000000000010801080108000000000000000000000000000000000000000000000108010801080108000000000108010801080000000000000000000000000000000000000000000000000108010801080000000000000108010800000000000000000000000000000000000000000000000000000000000000000000000001080108000000000000010801080108010801080108010801080000000000000000000000000000010801080108010801080108010801080108010801080108010801080000000000000000000000000108010801080108010801080108010801080108010801080108010800000000000000000000000001080108 -010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B0C0B010B010B010900010001000101090109000100010001000101090109010B0C0B010901090109010B01090109000100010001000100010001000100010001000100010001010B010B010900010001000100010001000109010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000109010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0001000100010001000100010001000100010001000100010001000100010001000100010001010B000100010A010001000100010001000100010001000100010001000100010D01000100010001010B0001000100010001000100010001000100010001000100010109000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000109010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001 +010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B0D0B010B010B010900010001000101090109000100010001000101090109010B0D0B010901090109010B01090109000100010001000100010001000100010001000100010001010B010B01090001000100010001000100010A010001000100010001000100010001000100010001010B010900010001000100010001000100010001000100010A010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0001000100010001000100010001000100010001000100010001000100010001000100010001010B000100010B010001000100010001000100010001000100010001000100010E01000100010001010B0001000100010001000100010001000100010001000100010109000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B010900010001000100010001000100010A010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001 diff --git a/output/map.txt b/output/map.txt index b54e1db..0b2dfa4 100644 --- a/output/map.txt +++ b/output/map.txt @@ -1 +1 @@ -000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B010B0D0B010B010B010900010001000101090109000100010001000101090109010B0D0B010901090109010B01090109000100010001000100010001000100010001000100010001010B010B01090001000100010001000100010A010001000100010001000100010001000100010001010B010900010001000100010001000100010001000100010A010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0001000100010001000100010001000100010001000100010001000100010001000100010001010B000100010B010001000100010001000100010001000100010001000100010E01000100010001010B0001000100010001000100010001000100010001000100010109000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B010900010001000100010001000100010A010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B010B000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001010B0109000100010001000100010001000100010001000100010001000100010001000100010001 diff --git a/saves/GATEWAY_MAIN.txt b/saves/GATEWAY_MAIN.txt index 3c4bfaf..0911236 100644 --- a/saves/GATEWAY_MAIN.txt +++ b/saves/GATEWAY_MAIN.txt @@ -1,5 +1,5 @@ Steve 12 1 -115 +145 {2,0,0,0,1} diff --git a/saves/MainAdventure.txt b/saves/MainAdventure.txt index 3a7c8c2..34d5a53 100644 --- a/saves/MainAdventure.txt +++ b/saves/MainAdventure.txt @@ -1,8 +1,8 @@ 10 -420 -414 -1 -11 -474 -300 -{-1} +522 +336 +12 +2 +126 +378 +{22} diff --git a/saves/testArea.txt b/saves/testArea.txt index 92f339f..fa275e5 100644 --- a/saves/testArea.txt +++ b/saves/testArea.txt @@ -1,8 +1,8 @@ -1 -654 -282 -12 +0 +360 +474 +10 -1 -1 -1 -{-1,-1} +{0,-1} diff --git a/scripts/MainAdventure.txt b/scripts/MainAdventure.txt index bec90d8..73de060 100644 --- a/scripts/MainAdventure.txt +++ b/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)<...>}