1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-02 11:03:32 +02:00
Commit Graph

111 Commits

Author SHA1 Message Date
Misa
1d669dffeb Interpolate "- Press ENTER to Teleport -" prompt
This is only really noticeable in slowmode, but if you're playing in
slowmode it'll be pretty smooth.
2020-06-19 09:05:48 -04:00
Misa
f53ed222d3 Interpolate activity zone prompt fading in and out
To make it real smooth, just in case it was noticeable that it only
updated at 1000/34 FPS before (well, except in slowmode, it's really
noticeable THERE).

Also this removes the re-typing out of (game.act_fade/10.0f) for every
single R, G, and B in gamerender().
2020-06-19 09:05:48 -04:00
Misa
b53d2ae53f Remove i/j/k attributes from classes that don't need them
The only class that actually needs its i/j/k kept is scriptclass,
because some custom levels rely on it for creating custom activity
zones. So I haven't touched that.

Other than that, there's no chance that anything important relies on
i/j/k in any other class. For that to be the case, it would have to use
i/j/k without initializing it beforehand, and that can simply be
detected by removing the attribute from the header file and seeing where
the compiler complains. And the compiler complains only about cases
where it's initialized first. (Note that due to this check, I *haven't*
removed Graphics's `m` as it precisely does exactly this, using it
without initializing it first.)

Interestingly enough, otherlevelclass and towerclass have unused i/k
variables for whatever reason.
2020-06-14 14:37:29 -04:00
Misa
93a67bd357 Add Game::inspecial()
It's a function marked for inline that's just a simple shorthand,
because I don't want to type all of those conditionals out.
2020-06-14 07:24:28 -04:00
AllyTally
d740205138 Don't initialize game.gametimer in the header file
That's a C++ thing apparently.
2020-06-12 19:11:48 -04:00
AllyTally
eb52657c23 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)
2020-06-12 19:11:48 -04:00
Misa
2d07090a6b Move returning to editor to end of frame
This fixes horizontal and vertical warp backgrounds not resetting, and
also a bunch of other 1-frame glitches, most noticeably cutscene bars
and fadeouts.

This adds a new variable shouldreturntoeditor to Game to signal whether
or not it should return to editor at the end of the frame.
2020-05-09 16:40:01 -04:00
Misa
51971fa84c Abstract returning-to-editor code to Game::returntoeditor()
This way I can easily move it around without moving around a bunch of
lines of code.
2020-05-09 16:40:01 -04:00
Misa
fc2f269548 Move returning to lab to separate variables
Again, what I've done here is removed the over-reliance on Terry's State
Machine to return to the lab, and just moved it into separate variables
instead. This means that returning to the lab is ALMOST entirely
self-contained in MAPMODE, except there's a quick jaunt over to GAMEMODE
to run a script because you can only run scripts in GAMEMODE.
2020-05-08 08:34:46 -04:00
Misa
17e7c6983b Move fading to menu to separate variables
Alright, so what I've done here is made exiting to the menu entirely
separate from Terry's State Machine, and thus it can now take place
entirely within MAPMODE instead of having to go back to GAMEMODE. Also,
it's faster by 15 frames since we don't need to wait for the map screen
to go back down.
2020-05-08 08:34:46 -04:00
Misa
69aeac2410 Move return to lab code to Game::returntolab()
Again, I'll keep gamestate 96 and 97 for compatibility reasons, but
ultimately we shouldn't be using gamestates to return to the lab.
2020-05-08 08:34:46 -04:00
Misa
b59e5a8346 Move script.hardreset() to after quit to menu
This cleans up a whole lot of kludge variables, because this aggressive
hardreset() right as ACTION is pressed doesn't do anyone any favors.

This aggressive hardreset() was probably here because of the whole fact
that exiting to the menu uses Terry's State Machine, to minimize the
chances of interruption, but it actually causes more issues and allows
towers to interrupt the fadeout. And we should fix the root cause (the
usage of the state machine) instead of patching together some kludge.
2020-05-08 08:34:46 -04:00
Misa
6ac41e112c Move quit to menu to Game::quittomenu()
I don't want the quit code to only be in the state machine, but I'll
keep the gamestate around for compatibility reasons (there are custom
levels that directly use gamestate 80 to quit to the menu).
2020-05-08 08:34:46 -04:00
Misa
0787475e63 Remove unused variable 'pause' from Game
Looks like this variable is never used anywhere.
2020-05-08 08:34:46 -04:00
Misa
e92a21cf8a Fix exiting No Death Mode being one menu too far back
I want exiting No Death Mode to go back to the "play modes" menu, not to
the "start game" menu, because it's too far back. Also do the same if
you either die or complete No Death Mode.

Also I initialized Game::wasinintermission, probably a good thing to
initialize variables.
2020-04-27 15:41:07 -04:00
Misa
197c7caf08 Add and use Game::save_exists()
This is simply a shorthand for telesummary != "" || quicksummary != "",
to make it easier and less error-prone to negate. This improves
readability.
2020-04-26 17:20:16 -04:00
Misa
833bbdbbef Add function Game::anything_unlocked()
This will be a useful shorthand to ask "do we have the Secret Lab, or
any Time Trial, or Intermission replays, or No Death Mode, or Flip Mode
unlocked?"
2020-04-26 17:20:16 -04:00
Misa
9fca3e111f Improve quit-to-menu menu handling
This stabilizes the code that handles the menu that you land on if you
press Esc and quit to the menu.

Instead of using Game::returnmenu(), we now use the new function
Game::returntomenu() to clearly express intent that we want to return to
a specific menu. So I've added another kludge variable
Game::wasinintermission for the was-in-intermission case.

Also, I made it so that if you didn't have a main game telesave or
quicksave, you just get brought back to the main menu. Because you
shouldn't be able to go to the play menu without a quicksave or
telesave.
2020-04-26 08:15:30 -04:00
Misa
536184f394 Add function Game::returntomenu()
When exiting from a game-gamestate which may have been entered through a
varying amount of menus, the solution is to not use Game::returnmenu(),
and to instead have a way to go back to a certain given menu.
2020-04-26 08:15:30 -04:00
Misa
9db96f004b Remove Game::globalsound
It looks like this variable was originally intended to keep track of th
volume of the game, but then it was used as a boolean in main.cpp to
make sure the game didn't call Mix_Volume() and Mix_VolumeMusic() every
frame.

However, it is now a problem, because I put the music mute handling code
in the very branch that game.globalsound protects against, but since
game.globalsound is here, if I mute the music, then mute the whole game,
then unmute the music, and then unmute the whole game, sound effects
will no longer be muted but the music will still be muted, until I mute
and unmute the whole game again. This is annoying and inconsistent, so
I'm removing this check from the 'if (!game.muted)' branch.

Plus, given that the Mix_VolumeMusic() and Mix_Volume() calls happen
every frame if the game is muted anyways, it doesn't seem to be a
problem to call these every frame.
2020-04-19 20:51:35 -04:00
Misa
c176127529 Remove useless attributes m_globalVol, set/getGlobalSound from Game
These do basically nothing. The only time they're used is
getGlobalSound() in an if-statement in main.cpp, but all that
if-conditional does is call setGlobalSound() anyway, which is something
that doesn't really have any side effects. So I'm removing these vars to
simplify the code.
2020-04-19 20:51:35 -04:00
Misa
43b1b71da1 Add being able to mute the music by pressing N
This is for people who want to use their own soundtrack while playing
the game, but who don't want to mute the sound effects as well.

This feature was added to VCE, but it was added in the strangest way. It
was made an option in "game options" instead of being a keybind, and I
don't know why.
2020-04-19 20:51:35 -04:00
Misa
b02c4aac78 Fix going to wrong menu upon quit
The problem was, if you were in a time trial and quit, it wouldn't go
back to selecting your current time trial. But also if you were in a
custom level and quit, you would still be on the playerworlds menu.

The problem was twofold: first, I simply wasn't doing the custommode
check. But secondly, I couldn't use map.custommode directly, because
whenever you quit the game aggressively hardreset()s everything
immediately when you press ACTION.

There's probably a good reason for that aggressive hardreset(), so I
won't touch that hardreset() in any way. Instead, I had to introduce two
kludge variables wasintimetrial and wasincustommode to Game, and use
those to do the check proper.
2020-04-17 15:41:48 -04:00
Misa
637a9d5665 Remove now-unused variable Game::previousmenuname
This used to be used for Menu::youwannaquit, but now it uses the same
stack frame system as everything else, so it's gone unused now.
2020-04-17 15:41:48 -04:00
Misa
bf4427c75a Add function Game::returnmenu()
It simply goes to the previous menu stack frame.
2020-04-17 15:41:48 -04:00
Misa
de0205e09b Push a stack frame when Game::createmenu() is called
Unless it's the main menu, or unless it's not the same menu. Whether or
not the menu is the same is left up to the caller, because some menus
could be the same but use different names, so we can't simply
automatically check that the names are different and assume that they
aren't the same menu.
2020-04-17 15:41:48 -04:00
Misa
58b9941d73 Add vector of MenuStackFrame menustack to Game
We need a stack to put our stack frames inside.
2020-04-17 15:41:48 -04:00
Misa
13d2d6b623 Add struct MenuStackFrame
This will be pushed onto a stack when going to a different menu so the
game can dynamically keep track of which menu option got you to which
menu.
2020-04-17 15:41:48 -04:00
Misa
503b3f1692 Move temp int off of Game
This temp variable isn't used anywhere else, and even if it was it's set
to something every time it's used, so there's no risk of this commit
breaking any backwards compatibility.
2020-04-17 15:41:48 -04:00
Misa
7b233a0e69 Rename Menu::setslowdown2 to Menu::setslowdown
Now that setslowdown1 has been removed it's no longer necessary to have
a 2 on the end of setslowdown2.
2020-04-17 15:41:48 -04:00
Misa
1c2cee48a7 Remove unused menu setslowdown1
Looks like it was a remnant from the Flash days, and the "delete your
saves if you want to use slowdown" was a bit too mean so it stopped
being a thing in the C++ version.
2020-04-17 15:41:48 -04:00
Misa
ceb8d3f3d8 Remove unused variable Game::menuselection
I presume it was meant to have the text of the currently-selected menu
option inside it, before the code switched over to using the indice of
the currently-selected menu instead? Would've been more error-prone to
use the text name directly.
2020-04-17 15:41:48 -04:00
Misa
e8a07f9c3d Convert menu names to be an enum instead of being stringly-typed
Stringly-typed things are bad, because if you make a typo when typing
out a string, it's not caught at compile-time. And in the case of this
menu system, you'd have to do an excessive amount of testing to uncover
any bugs caused by a typo. Why do that when you can just use an enum and
catch compile-time errors instead?

Also, you can't use switch-case statements on stringly-typed variables.

So every menu name is now in the enum Menu::MenuName, but you can simply
refer to a menu name by just prefixing it with Menu::.

Unfortunately, I've had to change the "continue" menu name to be
"continuemenu", because "continue" is a keyword in C and C++. Also, it
looks like "timetrialcomplete4" is an unused menu name, even though it
was referenced in Render.cpp.
2020-04-17 15:41:48 -04:00
Misa
511de0c5c1 Refactor menu creation code
Firstly, menu options are no longer ad-hoc objects, and are added by
using Game::option() (this is the biggest change). This removes the
vector Game::menuoptionsactive, and Game::menuoptions is now a vector of
MenuOption instead of std::string.

Secondly, the manual tracker variable of the amount of menu options,
Game::nummenuoptions, has been removed, in favor of using vectors
properly and using Game::menuoptions::size().

As a result, a lot of copy-pasted code has been removed from
Game::createmenu(), mostly due to having to have different versions of
menus depending on whether or not we have certain defines, or having an
mmmmmm.vvv file inside the VVVVVV directory. In the old days, you
couldn't just add or remove a menu option conveniently, you had to
shuffle around the position of every other menu option too, which
resulted in lots of copy-pasted code. But now this copy-pasted code has
been de-duplicated, at least in Game::createmenu().
2020-04-17 15:41:48 -04:00
Misa
a0d2be6362 Add Game::option()
This simply adds a menu option to the list of menu options, and is neat
and tidy and not messy.
2020-04-17 15:41:48 -04:00
Misa
c5db440318 Add struct MenuOption
This fully represents an actual menu option object, instead of having
both attributes of a menu option go off and be in separate vectors.
2020-04-17 15:41:48 -04:00
Misa
a37715abb6 Put trinkets() and crewmates() declaration on their own lines
Done to improve readability.
2020-04-09 19:20:31 -04:00
Misa
588a49dbc8 Remove useless variable game.timerStartTime
It sometimes gets set to SDL_GetTicks(), but without being checked or
actually used, it's useless and does nothing.
2020-04-09 19:20:31 -04:00
Misa
6428a14244 Declare game.teleport as a bool instead of an int
This should affect nothing, but it's a bit confusing to have it declared
an int. Everywhere in the code treats it as a bool anyway.
2020-04-09 19:20:31 -04:00
Misa
c5803863bf Remove unused variables temp_unlock and temp_unlocknotify
Have no idea why they're here, so removing them.
2020-04-09 19:20:31 -04:00
Misa
1110d46c8b Remove unused stat_* variables
Looks like all variables other than stat_trinkets are unused.
2020-04-09 19:20:31 -04:00
Misa
317eece28d Remove useless variable game.coins
It kept getting set to 0 and getting incremented sometimes, but without
it ever actually getting checked, it's a useless variable.
2020-04-09 19:20:31 -04:00
Misa
756c409d1d Remove unused variable game.trinkencollect
Don't know why it's here. Looks like a typo of 'trinketcollect' maybe?
2020-04-09 19:20:31 -04:00
Misa
c077e51fb4 Don't use separate variable for number of collected crewmates
Same as previous commit, except for crewmates in custom levels instead.
2020-04-09 19:20:31 -04:00
Misa
9510c3c871 Don't use separate variable for number of collected trinkets
game.trinkets is supposed to be correlated with obj.collect, however why
not just count obj.collect directly?

This turns game.trinkets into a function, game.trinkets(), which will
directly count the number of collected trinkets and return it. This will
fix a few corner cases where the number of trinkets can desync with the
actual collection statuses of trinkets.

In order to keep save compatibility with previous versions of VVVVVV,
the game will still write the <trinkets> variable. However, it will not
read the <trinkets> variable from a save file.
2020-04-09 19:20:31 -04:00
leo60228
94b2ebd55c
Implement command-line playtesting (#163) 2020-04-09 15:03:24 -04:00
Misa
134510d26a Remove remnants of screen recording stuff
Most of the code was already commented out, and those comments were
removed in earlier commits, but this removes all recording variables
from Game and simplifies the game-gamestate handling in main.cpp a
little bit.
2020-04-03 10:40:50 -04:00
Misa
f7ff076074 Move tempstring off of Graphics, Game, and UtilityClass
Unlike, say, the scriptclass i/j/k stuff, these tempstrings are only
purely visual, and there's no known glitches to manipulate them anyway.
Thus I think it's safe to make this cleanup.
2020-04-03 10:40:50 -04:00
Misa
ff449a2c3a Remove game.test and game.teststring
It looks like this may have been used earlier in development, judging
from the name, obviously, but right now it seems like it's used as an
error message if a main game level is asked for an invalid room (well,
only two of them - the Lab and Warp Zone). It should probably be
formalized into an error system, if we want to keep teststring, and also
people would never see it anyway because I don't think there's a
reliable and consistent way to trigger loading a non-existent room.

I have seen someone manage to load a non-existent Warp Zone room only
one time, but even then this teststring didn't pop up. So this
teststring doesn't even trigger in the right circumstances.

Also, when it does pop up, as far as I can tell it will stay onscreen,
which is kinda annoying. So I'm just removing this ancient relic from
the code.
2020-04-03 10:40:50 -04:00
Misa
88c16cdae8 Fix mixed indentation in Game.cpp and Game.h
This removes all indentation that suddenly switches in the middle of a
function. Most particularly egregious offenses are the ones made by the
person who has 2-wide tabs, but keeps tabbing up to make each
indentation level match up with the 4-wide spaces, so to them (and only
them) it will look just fine, but since by default tabstop is 8-wide,
their lines are pushed off all the way to the right.
2020-04-03 10:40:50 -04:00
Misa
606c740b4f Remove useless variable Game::quickcookieexists
Even though it keeps getting set to true and false everywhere, it never
once gets checked. So it's a variable that does nothing.
2020-04-03 10:40:50 -04:00
Misa
340f57762d Remove useless variable Game::telecookieexists
Although it keeps getting set to true and false in various places, it
never once gets checked, essentially deeming it a variable that's used
but does nothing.
2020-04-03 10:40:50 -04:00
Misa
9cec63bcf7 Remove unused variable Game::sfpsmode
This variable does absolutely nothing, so I'm removing it.
2020-04-03 10:40:50 -04:00
Misa
66b3c32899 Remove useless function Game::telegotoship()
This function does absolutely nothing. It is, however, called once in
gamecompletelogic2(), making it technically used.
2020-04-03 10:40:50 -04:00
Misa
0e561f23f8 Remove global args from Game
I've decided to call dwgfx/game/map/obj/key/help/music the "global args".
Because they're essentially global variables that are being passed
around in args.

This commit removes global args from all functions on the Game class,
and deals with updating the callsites of said functions accordingly. It
also renames all usages of 'dwgfx' in Game.cpp to 'graphics', since the
global variable is called 'graphics' now.

Interesting to note, I was removing the class defines from Game.h, but
it turns out that Graphics.h depends on the mapclass and entityclass
defines from Game.h. And also Graphics.h spelled mapclass wrong (it
forgot the "class") so I just decided to use that existing line instead.
This is only temporary and after all is said and done, at the end of
this pull request those class defines will be gone.
2020-04-03 10:40:50 -04:00
Matt Penny
df1c1303bf
Use dynamic credits lists for main menu credits screens (and add GitHub contributors) (#160)
Also added GitHub contributors to the credits on the main menu
(previously they were only present in the credits at the end of the
game)
2020-02-11 23:45:58 -05:00
Info Teddy
5a316d65e6 Allow using help/graphics/music/game/key/map/obj everywhere
This commit makes `help`, `graphics`, `music`, `game`, `key`, `map`, and
`obj` essentially static global objects that can be used everywhere.
This is useful in case we ever need to add a new function in the future,
so we don't have to bother with passing a new argument in which means we
have to pass a new argument in to the function that calls that function
which means having to pass a new argument into the function that calls
THAT function, etc. which is a real headache when working on fan mods of
the source code.

Note that this changes NONE of the existing function signatures, it
merely just makes those variables accessible everywhere in the same way
`script` and `ed` are.

Also note that some classes had to be initialized after the filesystem
was initialized, but C++ would keep initializing them before the
filesystem got initialized, because I *had* to put them at the top of
`main.cpp`, or else they wouldn't be global variables.

The only way to work around this was to use entityclass's initialization
style (which I'm pretty sure entityclass of all things doesn't need to
be initialized this way), where you actually initialize the class in an
`init()` function, and so then you do `graphics.init()` after the
filesystem initialization, AFTER doing `Graphics graphics` up at the
top.

I've had to do this for `graphics` (but only because its child
GraphicsResources `grphx` needs to be initialized this way), `music`,
and `game`. I don't think this will affect anything. Other than that,
`help`, `key`, and `map` are still using the C++-intended method of
having ClassName::ClassName() functions.
2020-01-29 07:58:23 -05:00
Info Teddy
47ebbf15ab Don't redraw H/V warp BG if gotorooming to same room in customs
This has two benefits:
 (1) The game uses less resources when it is asked to gotoroom to the
     same room because it is no longer redrawing the warp background
     every single frame, which is very wasteful.
 (2) The warp background no longer freezes or flickers if the player is
     standing inside a gotoroom script box (which calls gotoroom every
     frame or every other frame, because every time the gotoroom happens
     the script box gets reloaded).
2020-01-27 14:46:11 -08:00
Ethan Lee
2aa4aa5f8a Integrate dynamic list sizes for credited patrons, add CONTRIBUTORS to credits
(Also added myself to the credits, only took 6 years to not be lazy about it)
2020-01-16 20:14:56 -05:00
Info Teddy
c2ac1dc7d2 Add an accessibility option to toggle the fake loading screen (#63) 2020-01-12 20:45:44 -05:00
Ethan Lee
f7c0321b71 Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00