1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Rewrite autotiling completely

Autotiling was a mess of functions and if chains and switch statements.
This commit makes autotiling better by assigning each direction to one
bit in a byte, giving each different combination its own value. This
value is then fed into a lookup table to give fine control on which
tiles get placed where.

The lab tileset can now use the single tiles which were before unused
in the autotiler, and the warp zone's background tool now places the
fill used in the main game.
This commit is contained in:
AllyTally 2023-05-23 20:21:53 -03:00 committed by Misa Elizabeth Kai
parent 84a26986e6
commit a37cb4aa5f
2 changed files with 415 additions and 576 deletions

File diff suppressed because it is too large Load diff

View file

@ -6,10 +6,30 @@
#include "Constants.h"
#include "CustomLevels.h"
#include <map>
#include <SDL.h>
#include <string>
#include <vector>
enum EditorTilesets
{
EditorTileset_SPACE_STATION = 0,
EditorTileset_OUTSIDE = 1,
EditorTileset_LAB = 2,
EditorTileset_WARP_ZONE = 3,
EditorTileset_SHIP = 4,
NUM_EditorTilesets
};
struct EditorTilecolInfo
{
const char* foreground_type;
int foreground_base;
const char* background_type;
int background_base;
};
enum EditorTools
{
EditorTool_WALLS,
@ -57,7 +77,6 @@ enum TileTypes
{
TileType_NONSOLID,
TileType_SOLID,
TileType_BACKGROUND,
TileType_SPIKE
};
@ -120,6 +139,9 @@ public:
editorclass(void);
void reset(void);
void register_tileset(EditorTilesets tileset, const char* name);
void register_tilecol(EditorTilesets tileset, int index, const char* foreground_type, int foreground_base, const char* background_type, int background_base);
void register_tool(EditorTools tool, const char* name, const char* keychar, SDL_KeyCode key, bool shift);
void draw_tool(EditorTools tool, int x, int y);
@ -143,25 +165,17 @@ public:
int get_entity_at(int rx, int ry, int xp, int yp);
void set_tile(int x, int y, int t);
int get_tile(int x, int y);
int autotiling_base(int x, int y);
int autotiling_background_base(int x, int y);
bool is_warp_zone_background(int tile);
int autotile(int tile_x, int tile_y);
bool autotile_connector(int x, int y, TileTypes original_type);
EditorTilecolInfo get_tilecol_data(void);
TileTypes get_abs_tile_type(int x, int y, bool wrap);
TileTypes get_tile_type(int x, int y, bool wrap);
bool is_background(int x, int y);
bool backfree(int x, int y);
bool lines_can_pass(int x, int y);
bool free(int x, int y);
int match(int x, int y);
int outsidematch(int x, int y);
int backmatch(int x, int y);
int edgetile(int x, int y);
int outsideedgetile(int x, int y);
int backedgetile(int x, int y);
int labspikedir(int x, int y, int t);
int spikedir(int x, int y);
int get_enemy_tile(int t);
@ -174,6 +188,13 @@ public:
EditorStates state;
EditorSubStates substate;
std::map<std::string, std::vector<int> > autotile_types;
std::map<EditorTilesets, std::map<int, EditorTilecolInfo> > tileset_colors;
const char* tileset_names[NUM_EditorTilesets];
int tileset_min_colour[NUM_EditorTilesets];
int tileset_max_colour[NUM_EditorTilesets];
const char* tool_names[NUM_EditorTools];
const char* tool_key_chars[NUM_EditorTools];
SDL_KeyCode tool_keys[NUM_EditorTools];