Skip to content

Commit 9b58e99

Browse files
committed
Add finalstretch support for custom levels
1 parent 7b40a05 commit 9b58e99

File tree

5 files changed

+50
-19
lines changed

5 files changed

+50
-19
lines changed

desktop_version/src/Editor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ editorclass::editorclass(void)
279279
register_tilecol(EditorTileset_WARP_ZONE, 3, "basic", 89, "none", 129);
280280
register_tilecol(EditorTileset_WARP_ZONE, 4, "basic", 92, "none", 132);
281281
register_tilecol(EditorTileset_WARP_ZONE, 5, "basic", 95, "none", 135);
282-
register_tilecol(EditorTileset_WARP_ZONE, 6, "basic", 98, "none", 138);
282+
register_tilecol(EditorTileset_WARP_ZONE, 6, "basic", 98, "none", 740);
283283

284284
register_tilecol(EditorTileset_SHIP, 0, "basic", 101, "basic", 741);
285285
register_tilecol(EditorTileset_SHIP, 1, "basic", 104, "basic", 744);
@@ -3774,7 +3774,7 @@ bool editorclass::is_warp_zone_background(int tile)
37743774
return false;
37753775
}
37763776

3777-
return (tile == 120 || tile == 123 || tile == 126 || tile == 129 || tile == 132 || tile == 135 || tile == 138);
3777+
return (tile == 120 || tile == 123 || tile == 126 || tile == 129 || tile == 132 || tile == 135 || tile == 138 || tile == 740);
37783778
}
37793779

37803780
int editorclass::autotile(const int x, const int y)

desktop_version/src/Graphics.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,11 +2579,10 @@ void Graphics::updatebackground(int t)
25792579
else
25802580
{
25812581
// draw the whole thing for the first time!
2582-
backoffset = 0;
25832582
clear();
25842583
for (int j = 0; j < 15; j++)
25852584
{
2586-
for (int i = 0; i < 21; i++)
2585+
for (int i = 0; i < 22; i++)
25872586
{
25882587
drawtile2((i * 16) - backoffset - 3, (j * 16), temp + 40);
25892588
drawtile2((i * 16) - backoffset + 8 - 3, (j * 16), temp + 41);
@@ -2622,9 +2621,8 @@ void Graphics::updatebackground(int t)
26222621
else
26232622
{
26242623
// draw the whole thing for the first time!
2625-
backoffset = 0;
26262624
clear();
2627-
for (int j = 0; j < 16; j++)
2625+
for (int j = 0; j < 17; j++)
26282626
{
26292627
for (int i = 0; i < 21; i++)
26302628
{
@@ -2690,7 +2688,14 @@ void Graphics::drawmap(void)
26902688
else
26912689
#endif
26922690
{
2693-
tile = map.contents[TILE_IDX(x, y)];
2691+
if (map.finalstretch && map.custommode)
2692+
{
2693+
tile = map.finalat(x, y);
2694+
}
2695+
else
2696+
{
2697+
tile = map.contents[TILE_IDX(x, y)];
2698+
}
26942699
tileset = map.tileset;
26952700
}
26962701

desktop_version/src/Logic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ void gamelogic(void)
502502
else
503503
{
504504
//Update colour thingy
505-
if (map.finalmode)
505+
if (map.finalmode || map.custommode)
506506
{
507507
if (map.final_colormode)
508508
{
@@ -1407,7 +1407,7 @@ void gamelogic(void)
14071407
}
14081408

14091409
//Update colour cycling for final level
1410-
if (map.finalmode && map.final_colormode)
1410+
if ((map.finalmode || map.custommode) && map.final_colormode)
14111411
{
14121412
map.final_aniframedelay--;
14131413
if (map.final_aniframedelay == 0)

desktop_version/src/Map.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -513,36 +513,40 @@ void mapclass::changefinalcol(int t)
513513
//change the map to colour t - for the game's final stretch.
514514
//First up, the tiles. This is just a setting:
515515
final_mapcol = t;
516-
const int temp = 6 - t;
516+
graphics.rcol = 6 - t;
517+
graphics.backgrounddrawn = false;
517518
//Next, entities
518519
for (size_t i = 0; i < obj.entities.size(); i++)
519520
{
520521
if (obj.entities[i].type == 1) //something with a movement behavior
521522
{
522523
if (obj.entities[i].animate == 10 || obj.entities[i].animate == 11) //treadmill
523524
{
524-
if(temp<3)
525+
if (graphics.rcol < 3)
525526
{
526-
obj.entities[i].tile = 907 + (temp * 80);
527+
obj.entities[i].tile = 907 + (graphics.rcol * 80);
527528
}
528529
else
529530
{
530-
obj.entities[i].tile = 911 + ((temp-3) * 80);
531+
obj.entities[i].tile = 911 + ((graphics.rcol - 3) * 80);
532+
}
533+
if (obj.entities[i].animate == 10)
534+
{
535+
obj.entities[i].tile += 40;
531536
}
532-
if(obj.entities[i].animate == 10) obj.entities[i].tile += 40;
533537
}
534538
else if (obj.entities[i].isplatform)
535539
{
536-
obj.entities[i].tile = 915+(temp*40);
540+
obj.entities[i].tile = 915 + (graphics.rcol * 40);
537541
}
538-
else //just an enemy
542+
else // just an enemy
539543
{
540-
obj.entities[i].colour = maptiletoenemycol(temp);
544+
obj.entities[i].colour = maptiletoenemycol(graphics.rcol);
541545
}
542546
}
543-
else if (obj.entities[i].type == 2) //disappearing platforms
547+
else if (obj.entities[i].type == 2) // disappearing platforms
544548
{
545-
obj.entities[i].tile = 915+(temp*40);
549+
obj.entities[i].tile = 915 + (graphics.rcol * 40);
546550
}
547551
}
548552
}
@@ -1788,6 +1792,11 @@ void mapclass::loadlevel(int rx, int ry)
17881792
break;
17891793
}
17901794

1795+
if (finalstretch)
1796+
{
1797+
graphics.rcol = 6 - final_mapcol;
1798+
}
1799+
17911800
setroomname(room->roomname.c_str());
17921801
extrarow = 1;
17931802
const int* tmap = cl.loadlevel(rx, ry);

desktop_version/src/Script.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,23 @@ void scriptclass::run(void)
14331433
map.finalmode = true;
14341434
map.gotoroom(ss_toi(words[1]), ss_toi(words[2]));
14351435
}
1436+
else if (words[0] == "finalstretch")
1437+
{
1438+
if (words[1] == "on")
1439+
{
1440+
map.finalstretch = true;
1441+
map.final_colormode = true;
1442+
map.final_mapcol = 0;
1443+
map.final_colorframe = 1;
1444+
}
1445+
else if (words[1] == "off")
1446+
{
1447+
map.finalstretch = false;
1448+
map.final_colormode = false;
1449+
map.final_mapcol = 0;
1450+
map.final_colorframe = 0;
1451+
}
1452+
}
14361453
else if (words[0] == "rescued")
14371454
{
14381455
if (words[1] == "red")

0 commit comments

Comments
 (0)