Refactor roomtext to not use ad-hoc objects / separate length trackers

This refactors the roomtext code to (1) not use ad-hoc objects and (2)
not use a separate length-tracking variable to keep track of the actual
amount of roomtext in a room.

What I mean by ad-hoc object is, instead of formally creating a
fully-fledged struct or class and storing one vector containing that
object, this game instead hacks together an object by storing each
attribute of an object in different vectors.

In the case of roomtext, instead of making a Roomtext object that has
attributes 'x', 'y', and 'text', the 'text' attribute of each is stored
in the vector 'roomtext', the 'x' attribute of each is stored in the
vector 'roomtextx', and the 'y' attribute of each is stored in the
vector 'roomtexty'. It's only an object in the sense that you can grab
the attributes of each roomtext by using the same index across all three
vectors.

This makes it somewhat annoying to maintain and deal with, like when I
wanted add sub-tile positions to roomtext in VVVVVV: Community Edition.
Instead of being able to add attributes to an already-existing
formalized Roomtext object, I would instead have to add two more
vectors, which is inelegant. Or I could refactor the whole system, which
is what I decided to do instead.

Furthermore, this removes the separate length-tracking variable
'roomtextnumlines', which makes the code much more easy to maintain and
deal with, as the amount of roomtext is naturally tracked by C++ instead
of us having to keep track of the actual amount of roomtext manually.
This commit is contained in:
Misa
2020-02-29 18:26:12 -08:00
committed by Ethan Lee
parent f7e71bd668
commit a4d7fc017c
5 changed files with 26 additions and 58 deletions

View File

@@ -160,10 +160,8 @@ public:
bool showteleporters, showtargets, showtrinkets;
//Roomtext
int roomtextx[100], roomtexty[100];
bool roomtexton;
std::vector<std::string> roomtext;
int roomtextnumlines;
std::vector<Roomtext> roomtext;
//Levels
otherlevelclass otherlevel;