mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight difference however--you can choose whether you have them or not in the editor's settings menu. They're off by default, and this is saved to the save file. Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3 frames. The max is 100, where if it tries to add more, the oldest one gets removed. When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up. [Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
This commit is contained in:
@@ -383,6 +383,8 @@ void editorclass::reset()
|
||||
script.customscripts.clear();
|
||||
|
||||
returneditoralpha = 0;
|
||||
|
||||
ghosts.clear();
|
||||
}
|
||||
|
||||
void editorclass::gethooks()
|
||||
@@ -2238,6 +2240,13 @@ void editormenurender(int tr, int tg, int tb)
|
||||
{
|
||||
case Menu::ed_settings:
|
||||
graphics.bigprint( -1, 75, "Map Settings", tr, tg, tb, true);
|
||||
if (game.currentmenuoption == 3)
|
||||
{
|
||||
if (!game.ghostsenabled)
|
||||
graphics.Print(2, 230, "Editor ghost trail is OFF", tr/2, tg/2, tb/2);
|
||||
else
|
||||
graphics.Print(2, 230, "Editor ghost trail is ON", tr, tg, tb);
|
||||
}
|
||||
break;
|
||||
case Menu::ed_desc:
|
||||
if(ed.titlemod)
|
||||
@@ -2801,6 +2810,36 @@ void editorrender()
|
||||
}
|
||||
}
|
||||
|
||||
//Draw ghosts (spooky!)
|
||||
if (game.ghostsenabled) {
|
||||
SDL_FillRect(graphics.ghostbuffer, NULL, SDL_MapRGBA(graphics.ghostbuffer->format, 0, 0, 0, 0));
|
||||
for (int i = 0; i < (int)ed.ghosts.size(); i++) {
|
||||
if (i <= ed.currentghosts) { // We don't want all of them to show up at once :)
|
||||
if (ed.ghosts[i].rx != ed.levx || ed.ghosts[i].ry != ed.levy)
|
||||
continue;
|
||||
point tpoint;
|
||||
tpoint.x = ed.ghosts[i].x;
|
||||
tpoint.y = ed.ghosts[i].y;
|
||||
graphics.setcol(ed.ghosts[i].col);
|
||||
Uint32 alpha = graphics.ct.colour & graphics.backBuffer->format->Amask;
|
||||
Uint32 therest = graphics.ct.colour & 0x00FFFFFF;
|
||||
alpha = (3 * (alpha >> 24) / 4) << 24;
|
||||
graphics.ct.colour = therest | alpha;
|
||||
SDL_Rect drawRect = graphics.sprites_rect;
|
||||
drawRect.x += tpoint.x;
|
||||
drawRect.y += tpoint.y;
|
||||
BlitSurfaceColoured(graphics.sprites[ed.ghosts[i].frame],NULL, graphics.ghostbuffer, &drawRect, graphics.ct);
|
||||
}
|
||||
}
|
||||
if (ed.currentghosts + 1 < (int)ed.ghosts.size()) {
|
||||
ed.currentghosts++;
|
||||
if (ed.zmod) ed.currentghosts++;
|
||||
} else {
|
||||
ed.currentghosts = (int)ed.ghosts.size() - 1;
|
||||
}
|
||||
SDL_BlitSurface(graphics.ghostbuffer, NULL, graphics.backBuffer, &graphics.bg_rect);
|
||||
}
|
||||
|
||||
//Draw Cursor
|
||||
switch(ed.drawmode)
|
||||
{
|
||||
@@ -3573,6 +3612,10 @@ void editormenuactionpress()
|
||||
if(ed.levmusic>0) music.play(ed.levmusic);
|
||||
break;
|
||||
case 3:
|
||||
music.playef(11);
|
||||
game.ghostsenabled = !game.ghostsenabled;
|
||||
break;
|
||||
case 4:
|
||||
//Load level
|
||||
ed.settingsmod=false;
|
||||
graphics.backgrounddrawn=false;
|
||||
@@ -3586,7 +3629,7 @@ void editormenuactionpress()
|
||||
game.mapheld=true;
|
||||
graphics.backgrounddrawn=false;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
//Save level
|
||||
ed.settingsmod=false;
|
||||
graphics.backgrounddrawn=false;
|
||||
@@ -3600,7 +3643,7 @@ void editormenuactionpress()
|
||||
game.mapheld=true;
|
||||
graphics.backgrounddrawn=false;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
music.playef(11);
|
||||
game.createmenu(Menu::ed_quit);
|
||||
map.nexttowercolour();
|
||||
@@ -4442,6 +4485,7 @@ void editorinput()
|
||||
}
|
||||
else
|
||||
{
|
||||
ed.currentghosts = 0;
|
||||
if(startpoint==0)
|
||||
{
|
||||
//Checkpoint spawn
|
||||
|
||||
Reference in New Issue
Block a user