1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 14:38:30 +02:00
VVVVVV/desktop_version/src/Map.h
Misa a4d7fc017c 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.
2020-02-29 23:02:52 -05:00

185 lines
3.9 KiB
C++

#ifndef MAPGAME_H
#define MAPGAME_H
#include "Tower.h"
#include "WarpClass.h"
#include "Finalclass.h"
#include "Labclass.h"
#include "Spacestation2.h"
#include "Otherlevel.h"
#include "Entity.h"
#include "Graphics.h"
#include <vector>
#include "Music.h"
#include "editor.h"
#if !defined(NO_CUSTOM_LEVELS)
extern editorclass ed;
#endif
class mapclass
{
public:
mapclass();
int RGB(int red,int green,int blue);
int intpol(int a, int b, float c);
void setteleporter(int t, int x, int y);
void settrinket(int t, int x, int y);
void resetmap();
void resetnames();
void transformname(int t);
std::string getglitchname(int x, int y);
void initmapdata();
int finalat(int x, int y);
int maptiletoenemycol(int t);
void changefinalcol(int t, entityclass& obj, Game& game);
void setcol(const int r1, const int g1, const int b1 , const int r2, const int g2, const int b2, const int c);
void updatetowerglow();
void nexttowercolour();
void settowercolour(int t);
bool spikecollide(int x, int y);
bool collide(int x, int y);
void fillareamap(std::vector<std::string>& tmap);
void settile(int xp, int yp, int t);
void fillcontent(std::vector<std::string>& tmap);
int area(int _rx, int _ry);
void exploretower();
void hideship();
void showship();
void resetplayer(Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music);
void warpto(int rx, int ry , int t, int tx, int ty, Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music);
void gotoroom(int rx, int ry, Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music);
std::string currentarea(int t);
void loadlevel(int rx, int ry, Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music);
std::vector <int> roomdeaths;
std::vector <int> roomdeathsfinal;
std::vector <int> areamap;
std::vector <int> contents;
std::vector <int> explored;
std::vector <int> vmult;
std::vector <std::string> tmap;
int temp;
int temp2;
int j;
int background;
int rcol;
int tileset;
bool warpx;
bool warpy;
std::string roomname;
//Special tower stuff
bool towermode;
float ypos;
int bypos;
int cameramode;
int cameraseek, cameraseekframe;
int resumedelay;
bool minitowermode;
int scrolldir;
//This is the old colour cycle
int r, g,b;
int check, cmode;
int towercol;
int colstate, colstatedelay;
int colsuperstate;
int spikeleveltop, spikelevelbottom;
bool tdrawback;
int bscroll;
//final level navigation
int finalx;
int finaly;
bool finalmode;
bool finalstretch;
//Variables for playing custom levels
bool custommode;
bool custommodeforreal;
int customx, customy;
int customwidth, customheight;
int customtrinkets;
int customcrewmates;
int custommmxoff, custommmyoff, custommmxsize, custommmysize;
int customzoom;
bool customshowmm;
std::vector<std::string> specialnames;
int glitchmode;
int glitchdelay;
std::string glitchname;
//final level colour cycling stuff
bool final_colormode;
int final_mapcol;
int final_aniframe;
int final_aniframedelay;
int final_colorframe, final_colorframedelay;
//Teleporters and Trinkets on the map
std::vector<point> teleporters;
std::vector<point> shinytrinkets;
int numteleporters, numshinytrinkets;
bool showteleporters, showtargets, showtrinkets;
//Roomtext
bool roomtexton;
std::vector<Roomtext> roomtext;
//Levels
otherlevelclass otherlevel;
spacestation2class spacestation2;
labclass lablevel;
finalclass finallevel;
warpclass warplevel;
towerclass tower;
int extrarow;
//Accessibility options
bool invincibility;
//Map cursor
int cursorstate, cursordelay;
};
extern mapclass map;
#endif /* MAPGAME_H */