Add new map "empty", Increase game speed

This commit is contained in:
jonny_jr9 2023-12-04 23:12:33 +01:00
parent cf92191177
commit 3c0f837daa
3 changed files with 21 additions and 4 deletions

View File

@ -38,6 +38,7 @@ void gameInit()
//load default map if no map loaded yet
if (!game.mapIsLoaded){
loadMapByName("default");
//loadMapByName("empty");
//loadMapByName("intermediate");
}

View File

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
while (game.gameState != EXIT)
{
processInputEvent();
SDL_Delay(600);
SDL_Delay(300);
processInputEvent();
runGameCycle();
}

View File

@ -28,7 +28,7 @@ void renderGameToArray(int mapFrame[MAX_MAP_SIZE][MAX_MAP_SIZE], map_t map, snak
{
mapFrame[snake.tail[i][1]][snake.tail[i][0]] = 5;
}
// copy food
// copy food
mapFrame[game.foodY][game.foodX] = 6;
// copy snake head (last element -> head overwrites previous elements)
mapFrame[snake.headY][snake.headX] = 4;
@ -185,6 +185,22 @@ static const map_t map_default = {
.color = "blue"}},
.portalCount = 1};
static const map_t map_empty = {
.width = 20,
.height = 10,
.name = "empty",
.collisions = {},
.collisionCount = 0,
.portals = {
{.posX = 5,
.posY = 8,
.targetX = 7,
.targetY = 1,
.color = "blue"}},
.portalCount = 1};
static const map_t map_intermediate = {
.width = 15,
.height = 15,
@ -205,5 +221,5 @@ static const map_t map_intermediate = {
.portalCount = 2};
// global variables for accessing the stored maps
const map_t *storedMaps[16] = {&map_default, &map_intermediate};
const int storedMapsCount = 2;
const map_t *storedMaps[16] = {&map_default, &map_empty, &map_intermediate};
const int storedMapsCount = 3;