1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00
VVVVVV/desktop_version/src/Map.h

208 lines
4 KiB
C
Raw Normal View History

2020-01-01 21:29:24 +01:00
#ifndef MAPGAME_H
#define MAPGAME_H
#include <vector>
#include <string>
#include "Finalclass.h"
#include "Labclass.h"
#include "Otherlevel.h"
#include "Spacestation2.h"
#include "Tower.h"
#include "TowerBG.h"
#include "WarpClass.h"
2020-01-01 21:29:24 +01:00
struct Roomtext
{
int x, y;
const char* text;
bool rtl;
};
enum RoomnameType
{
RoomnameType_STATIC,
RoomnameType_GLITCH,
RoomnameType_TRANSFORM
};
struct Roomname
{
int x;
int y;
bool loop;
int flag;
RoomnameType type;
std::vector<std::string> text;
int progress;
int delay;
};
2020-01-01 21:29:24 +01:00
class mapclass
{
public:
mapclass(void);
void destroy(void);
2020-01-01 21:29:24 +01:00
int getwidth(void);
int getheight(void);
2020-01-01 21:29:24 +01:00
int intpol(int a, int b, float c);
void setteleporter(int x, int y);
2020-01-01 21:29:24 +01:00
void settrinket(int x, int y);
2020-01-01 21:29:24 +01:00
void setroomname(const char* name);
void resetmap(void);
2020-01-01 21:29:24 +01:00
void fullmap(void);
void updateroomnames(void);
void initmapdata(void);
void initcustommapdata(void);
2020-01-01 21:29:24 +01:00
void roomnamechange(int x, int y, const char** lines, size_t size);
void roomnameglitch(int x, int y, const char* name, const char* glitch);
2020-01-01 21:29:24 +01:00
int finalat(int x, int y);
int maptiletoenemycol(int t);
void changefinalcol(int t);
2020-01-01 21:29:24 +01:00
void setcol(TowerBG& bg_obj, const int r1, const int g1, const int b1 , const int r2, const int g2, const int b2, const int c);
void updatebgobj(TowerBG& bg_obj);
2020-01-01 21:29:24 +01:00
2021-04-23 03:47:07 +02:00
void setbgobjlerp(TowerBG& bg_obj);
void updatetowerglow(TowerBG& bg_obj);
2020-01-01 21:29:24 +01:00
void nexttowercolour(void);
bool nexttowercolour_set;
2020-01-01 21:29:24 +01:00
void settowercolour(int t);
bool towerspikecollide(int x, int y);
2020-01-01 21:29:24 +01:00
bool collide(int x, int y, bool invincible);
2020-01-01 21:29:24 +01:00
void settile(int xp, int yp, int t);
int area(int _rx, int _ry);
void exploretower(void);
2020-01-01 21:29:24 +01:00
void hideship(void);
2020-01-01 21:29:24 +01:00
void showship(void);
2020-01-01 21:29:24 +01:00
void resetplayer(const bool player_died);
void resetplayer(void);
2020-01-01 21:29:24 +01:00
void warpto(int rx, int ry , int t, int tx, int ty);
2020-01-01 21:29:24 +01:00
void gotoroom(int rx, int ry);
2020-01-01 21:29:24 +01:00
void spawncompanion(void);
const char* currentarea(int roomx, int roomy);
2020-01-01 21:29:24 +01:00
void loadlevel(int rx, int ry);
2020-01-01 21:29:24 +01:00
void twoframedelayfix(void);
2020-01-01 21:29:24 +01:00
int roomdeaths[20 * 20];
int roomdeathsfinal[20 * 20];
static const int areamap[20 * 20];
int contents[40 * 30];
bool explored[20 * 20];
2020-01-01 21:29:24 +01:00
bool isexplored(const int rx, const int ry);
void setexplored(const int rx, const int ry, const bool status);
bool revealmap;
2020-01-01 21:29:24 +01:00
int background;
int rcol;
int tileset;
bool warpx;
bool warpy;
const char* roomname;
bool roomname_special;
bool roomnameset;
const char* hiddenname;
2020-01-01 21:29:24 +01:00
std::vector<Roomname> specialroomnames;
2020-01-01 21:29:24 +01:00
//Special tower stuff
bool towermode;
int ypos;
int oldypos;
2020-01-01 21:29:24 +01:00
int cameramode;
int cameraseek, cameraseekframe;
int resumedelay;
bool minitowermode;
int colstatedelay;
2020-01-01 21:29:24 +01:00
int colsuperstate;
int spikeleveltop, spikelevelbottom;
int oldspikeleveltop, oldspikelevelbottom;
2020-01-01 21:29:24 +01:00
//final level navigation
bool finalmode;
bool finalstretch;
//Variables for playing custom levels
bool custommode;
bool custommodeforreal;
int custommmxoff, custommmyoff, custommmxsize, custommmysize;
int customzoom;
bool customshowmm;
//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<SDL_Point> teleporters;
std::vector<SDL_Point> shinytrinkets;
2020-01-01 21:29:24 +01:00
bool showteleporters, showtargets, showtrinkets;
//Roomtext
bool roomtexton;
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-03-01 03:26:12 +01:00
std::vector<Roomtext> roomtext;
2020-01-01 21:29:24 +01:00
//Levels
otherlevelclass otherlevel;
spacestation2class spacestation2;
labclass lablevel;
finalclass finallevel;
warpclass warplevel;
towerclass tower;
int extrarow;
//Accessibility options
bool invincibility;
//Map cursor
int cursorstate, cursordelay;
};
#ifndef MAP_DEFINITION
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 08:35:03 +01:00
extern mapclass map;
#endif
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 08:35:03 +01:00
2020-01-01 21:29:24 +01:00
#endif /* MAPGAME_H */