Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add finalstretch support for custom levels #997

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions desktop_version/src/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,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 @@ -3769,7 +3769,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 @@ -2688,7 +2686,14 @@ void Graphics::drawmap(void)
}
else
{
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
34 changes: 24 additions & 10 deletions desktop_version/src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,44 @@ 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 (custommode)
{
obj.entities[i].tile = 907 + (temp * 80);
obj.entities[i].tile = 568 + (graphics.rcol * 12);
}
else if (graphics.rcol < 3)
{
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 += custommode ? 4 : 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 = custommode ? 564 + (graphics.rcol * 12) : 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 = custommode ? 564 + (graphics.rcol * 12) : 915 + (graphics.rcol * 40);
}
}
}
Expand Down Expand Up @@ -1949,6 +1957,12 @@ void mapclass::loadlevel(int rx, int ry)
}
}

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

//do the appear/remove roomname here
break;
}
Expand Down
25 changes: 25 additions & 0 deletions desktop_version/src/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,31 @@ 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_colorframe = 1;

graphics.foregrounddrawn = false;
map.final_colorframedelay = 40;

int temp = 1 + (int)(fRandom() * 5);
if (temp == 0) temp = 6;
map.changefinalcol(temp);
}
else if (words[1] == "off")
{
map.finalstretch = false;
map.final_colormode = false;
map.final_mapcol = 0;
map.final_colorframe = 0;
graphics.foregrounddrawn = false;
map.changefinalcol(0);
}
}
else if (words[0] == "rescued")
{
if (words[1] == "red")
Expand Down