Add spikes spawning
Changelog: - Add new tile: spikes - Change bbox of tile of spikes depending on solid tiles positionscene_man
parent
81da536e8e
commit
c27fa632a2
|
@ -14,12 +14,13 @@ enum EntitySpawnSelection {
|
||||||
TOGGLE_TILE = 0,
|
TOGGLE_TILE = 0,
|
||||||
TOGGLE_ONEWAY,
|
TOGGLE_ONEWAY,
|
||||||
TOGGLE_LADDER,
|
TOGGLE_LADDER,
|
||||||
|
TOGGLE_SPIKE,
|
||||||
SPAWN_CRATE,
|
SPAWN_CRATE,
|
||||||
SPAWN_METAL_CRATE,
|
SPAWN_METAL_CRATE,
|
||||||
SPAWN_BOULDER,
|
SPAWN_BOULDER,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_SPAWN_TYPE 6
|
#define MAX_SPAWN_TYPE 7
|
||||||
static unsigned int current_spawn_selection = 0;
|
static unsigned int current_spawn_selection = 0;
|
||||||
|
|
||||||
static inline unsigned int get_tile_idx(int x, int y, const TileGrid_t* tilemap)
|
static inline unsigned int get_tile_idx(int x, int y, const TileGrid_t* tilemap)
|
||||||
|
@ -68,6 +69,13 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
{
|
{
|
||||||
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, ORANGE);
|
DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, ORANGE);
|
||||||
}
|
}
|
||||||
|
else if (tilemap.tiles[i].tile_type == SPIKES)
|
||||||
|
{
|
||||||
|
DrawRectangle(
|
||||||
|
x + tilemap.tiles[i].offset.x, y + tilemap.tiles[i].offset.y,
|
||||||
|
tilemap.tiles[i].size.x, tilemap.tiles[i].size.y, RED
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (tilemap.tiles[i].water_level > 0)
|
if (tilemap.tiles[i].water_level > 0)
|
||||||
{
|
{
|
||||||
|
@ -317,6 +325,17 @@ static void toggle_block_system(Scene_t* scene)
|
||||||
tilemap.tiles[down_tile].solid = (tilemap.tiles[tile_idx].tile_type != LADDER)? ONE_WAY : NOT_SOLID;
|
tilemap.tiles[down_tile].solid = (tilemap.tiles[tile_idx].tile_type != LADDER)? ONE_WAY : NOT_SOLID;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TOGGLE_SPIKE:
|
||||||
|
if (tilemap.tiles[tile_idx].tile_type == SPIKES)
|
||||||
|
{
|
||||||
|
tilemap.tiles[tile_idx].tile_type = EMPTY_TILE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tilemap.tiles[tile_idx].tile_type = SPIKES;
|
||||||
|
}
|
||||||
|
tilemap.tiles[tile_idx].solid = NOT_SOLID;
|
||||||
|
break;
|
||||||
case SPAWN_CRATE:
|
case SPAWN_CRATE:
|
||||||
spawn_crate(scene, tile_idx, false);
|
spawn_crate(scene, tile_idx, false);
|
||||||
break;
|
break;
|
||||||
|
@ -327,6 +346,34 @@ static void toggle_block_system(Scene_t* scene)
|
||||||
spawn_boulder(scene, tile_idx);
|
spawn_boulder(scene, tile_idx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (tilemap.tiles[tile_idx].tile_type == SPIKES)
|
||||||
|
{
|
||||||
|
if (tile_idx - tilemap.width >= 0 && tilemap.tiles[tile_idx-tilemap.width].tile_type == SOLID_TILE)
|
||||||
|
{
|
||||||
|
tilemap.tiles[tile_idx].offset = (Vector2){0,0};
|
||||||
|
tilemap.tiles[tile_idx].size = (Vector2){32,16};
|
||||||
|
}
|
||||||
|
else if (tile_idx % tilemap.width != 0 && tile_idx > 0 && tilemap.tiles[tile_idx-1].tile_type == SOLID_TILE)
|
||||||
|
{
|
||||||
|
tilemap.tiles[tile_idx].offset = (Vector2){0,0};
|
||||||
|
tilemap.tiles[tile_idx].size = (Vector2){16,32};
|
||||||
|
}
|
||||||
|
else if (tile_idx % tilemap.width + 1 != 0 && tile_idx < MAX_N_TILES - 1 && tilemap.tiles[tile_idx+1].tile_type == SOLID_TILE)
|
||||||
|
{
|
||||||
|
tilemap.tiles[tile_idx].offset = (Vector2){16,0};
|
||||||
|
tilemap.tiles[tile_idx].size = (Vector2){16,32};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tilemap.tiles[tile_idx].offset = (Vector2){0,16};
|
||||||
|
tilemap.tiles[tile_idx].size = (Vector2){32,16};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tilemap.tiles[tile_idx].offset = (Vector2){0,0};
|
||||||
|
tilemap.tiles[tile_idx].size = (Vector2){32,32};
|
||||||
|
}
|
||||||
last_tile_idx = tile_idx;
|
last_tile_idx = tile_idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,10 @@ typedef enum TileType {
|
||||||
EMPTY_TILE = 0,
|
EMPTY_TILE = 0,
|
||||||
SOLID_TILE,
|
SOLID_TILE,
|
||||||
ONEWAY_TILE,
|
ONEWAY_TILE,
|
||||||
LADDER
|
LADDER,
|
||||||
|
SPIKES,
|
||||||
} TileType_t;
|
} TileType_t;
|
||||||
#define MAX_TILE_TYPES 4
|
#define MAX_TILE_TYPES 5
|
||||||
typedef enum SolidType
|
typedef enum SolidType
|
||||||
{
|
{
|
||||||
NOT_SOLID = 0,
|
NOT_SOLID = 0,
|
||||||
|
|
Loading…
Reference in New Issue