Skip to content

Commit

Permalink
Add finalstretch support for custom levels
Browse files Browse the repository at this point in the history
  • Loading branch information
AllyTally committed Aug 25, 2023
1 parent 7b40a05 commit 9b58e99
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 19 deletions.
4 changes: 2 additions & 2 deletions desktop_version/src/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ editorclass::editorclass(void)
register_tilecol(EditorTileset_WARP_ZONE, 3, "basic", 89, "none", 129);
register_tilecol(EditorTileset_WARP_ZONE, 4, "basic", 92, "none", 132);
register_tilecol(EditorTileset_WARP_ZONE, 5, "basic", 95, "none", 135);
register_tilecol(EditorTileset_WARP_ZONE, 6, "basic", 98, "none", 138);
register_tilecol(EditorTileset_WARP_ZONE, 6, "basic", 98, "none", 740);

register_tilecol(EditorTileset_SHIP, 0, "basic", 101, "basic", 741);
register_tilecol(EditorTileset_SHIP, 1, "basic", 104, "basic", 744);
Expand Down Expand Up @@ -3774,7 +3774,7 @@ bool editorclass::is_warp_zone_background(int tile)
return false;
}

return (tile == 120 || tile == 123 || tile == 126 || tile == 129 || tile == 132 || tile == 135 || tile == 138);
return (tile == 120 || tile == 123 || tile == 126 || tile == 129 || tile == 132 || tile == 135 || tile == 138 || tile == 740);
}

int editorclass::autotile(const int x, const int y)
Expand Down
15 changes: 10 additions & 5 deletions desktop_version/src/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2579,11 +2579,10 @@ void Graphics::updatebackground(int t)
else
{
// draw the whole thing for the first time!
backoffset = 0;
clear();
for (int j = 0; j < 15; j++)
{
for (int i = 0; i < 21; i++)
for (int i = 0; i < 22; i++)
{
drawtile2((i * 16) - backoffset - 3, (j * 16), temp + 40);
drawtile2((i * 16) - backoffset + 8 - 3, (j * 16), temp + 41);
Expand Down Expand Up @@ -2622,9 +2621,8 @@ void Graphics::updatebackground(int t)
else
{
// draw the whole thing for the first time!
backoffset = 0;
clear();
for (int j = 0; j < 16; j++)
for (int j = 0; j < 17; j++)
{
for (int i = 0; i < 21; i++)
{
Expand Down Expand Up @@ -2690,7 +2688,14 @@ void Graphics::drawmap(void)
else
#endif
{
tile = map.contents[TILE_IDX(x, y)];
if (map.finalstretch && map.custommode)
{
tile = map.finalat(x, y);
}
else
{
tile = map.contents[TILE_IDX(x, y)];
}
tileset = map.tileset;
}

Expand Down
4 changes: 2 additions & 2 deletions desktop_version/src/Logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void gamelogic(void)
else
{
//Update colour thingy
if (map.finalmode)
if (map.finalmode || map.custommode)
{
if (map.final_colormode)
{
Expand Down Expand Up @@ -1407,7 +1407,7 @@ void gamelogic(void)
}

//Update colour cycling for final level
if (map.finalmode && map.final_colormode)
if ((map.finalmode || map.custommode) && map.final_colormode)
{
map.final_aniframedelay--;
if (map.final_aniframedelay == 0)
Expand Down
29 changes: 19 additions & 10 deletions desktop_version/src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,36 +513,40 @@ void mapclass::changefinalcol(int t)
//change the map to colour t - for the game's final stretch.
//First up, the tiles. This is just a setting:
final_mapcol = t;
const int temp = 6 - t;
graphics.rcol = 6 - t;
graphics.backgrounddrawn = false;
//Next, entities
for (size_t i = 0; i < obj.entities.size(); i++)
{
if (obj.entities[i].type == 1) //something with a movement behavior
{
if (obj.entities[i].animate == 10 || obj.entities[i].animate == 11) //treadmill
{
if(temp<3)
if (graphics.rcol < 3)
{
obj.entities[i].tile = 907 + (temp * 80);
obj.entities[i].tile = 907 + (graphics.rcol * 80);
}
else
{
obj.entities[i].tile = 911 + ((temp-3) * 80);
obj.entities[i].tile = 911 + ((graphics.rcol - 3) * 80);
}
if (obj.entities[i].animate == 10)
{
obj.entities[i].tile += 40;
}
if(obj.entities[i].animate == 10) obj.entities[i].tile += 40;
}
else if (obj.entities[i].isplatform)
{
obj.entities[i].tile = 915+(temp*40);
obj.entities[i].tile = 915 + (graphics.rcol * 40);
}
else //just an enemy
else // just an enemy
{
obj.entities[i].colour = maptiletoenemycol(temp);
obj.entities[i].colour = maptiletoenemycol(graphics.rcol);
}
}
else if (obj.entities[i].type == 2) //disappearing platforms
else if (obj.entities[i].type == 2) // disappearing platforms
{
obj.entities[i].tile = 915+(temp*40);
obj.entities[i].tile = 915 + (graphics.rcol * 40);
}
}
}
Expand Down Expand Up @@ -1788,6 +1792,11 @@ void mapclass::loadlevel(int rx, int ry)
break;
}

if (finalstretch)
{
graphics.rcol = 6 - final_mapcol;
}

setroomname(room->roomname.c_str());
extrarow = 1;
const int* tmap = cl.loadlevel(rx, ry);
Expand Down
17 changes: 17 additions & 0 deletions desktop_version/src/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,23 @@ void scriptclass::run(void)
map.finalmode = true;
map.gotoroom(ss_toi(words[1]), ss_toi(words[2]));
}
else if (words[0] == "finalstretch")
{
if (words[1] == "on")
{
map.finalstretch = true;
map.final_colormode = true;
map.final_mapcol = 0;
map.final_colorframe = 1;
}
else if (words[1] == "off")
{
map.finalstretch = false;
map.final_colormode = false;
map.final_mapcol = 0;
map.final_colorframe = 0;
}
}
else if (words[0] == "rescued")
{
if (words[1] == "red")
Expand Down

0 comments on commit 9b58e99

Please sign in to comment.