A retro platform game
git clone git://soophie.de/freezo
diff --git a/assets/background.png b/assets/background.png
index 2fa9e50..0589fd3 100644
Binary files a/assets/background.png and b/assets/background.png differ
diff --git a/include/level.h b/include/level.h
index d6b96ba..2c8aebc 100644
--- a/include/level.h
+++ b/include/level.h
1
@@ -1,6 +1,6 @@2
#pragma once4
-#define LEVELS 35
+#define LEVELS 57
typedef struct Level level_t;9
@@ -9,6 +9,8 @@ typedef enum {10
LEVEL_1,11
LEVEL_2,12
LEVEL_3,13
+ LEVEL_4,14
+ LEVEL_5,15
} level_e;17
#include "game.h"
diff --git a/include/tile.h b/include/tile.h
index cbfc5e8..d97a359 100644
--- a/include/tile.h
+++ b/include/tile.h
1
@@ -22,6 +22,7 @@ typedef enum {2
TILE_BG_BRICK_1,3
TILE_BG_BRICK_2,4
TILE_BG_BRICK_3,5
+ TILE_BG_INFO,6
} tile_e;8
struct Tile {
diff --git a/src/game.c b/src/game.c
index 9edf71d..52cadeb 100644
--- a/src/game.c
+++ b/src/game.c
1
@@ -119,9 +119,11 @@ void game_update(game_t *game) {2
break;3
}4
case STATE_GAME: {5
- if (IsKeyPressed(KEY_ESCAPE)) {6
- game->state = STATE_MENU;7
- game->menu->idx = 0;8
+ if (!game->victory && !game->defeat) {9
+ if (IsKeyPressed(KEY_ESCAPE)) {10
+ game->state = STATE_MENU;11
+ game->menu->idx = 0;12
+ }13
}14
if (game->level != NULL) {15
// defeat
diff --git a/src/level.c b/src/level.c
index ed93ffd..c812a09 100644
--- a/src/level.c
+++ b/src/level.c
1
@@ -9,6 +9,25 @@2
const char *LEVEL_MAP_1 = {3
"........................"4
"........................"5
+ "........................"6
+ "..I....................."7
+ "........................"8
+ "........................"9
+ ".............o.........."10
+ "..................2....."11
+ "........................"12
+ "........................"13
+ ".....3........e....u...."14
+ "............--xxxxxxxx.."15
+ "....p..................."16
+ "..xxxxxxxxxxx..........."17
+ "........................"18
+ "........................"19
+};20
+21
+const char *LEVEL_MAP_2 = {22
+ "........................"23
+ "........................"24
"........k.......O......."25
"..1....................."26
"........................"27
@@ -25,7 +44,7 @@ const char *LEVEL_MAP_1 = {28
"........................"29
};31
-const char *LEVEL_MAP_2 = {32
+const char *LEVEL_MAP_3 = {33
"........................"34
"........................"35
"......3....b............"36
@@ -44,14 +63,33 @@ const char *LEVEL_MAP_2 = {37
"........................"38
};40
-const char *LEVEL_MAP_3 = {41
+const char *LEVEL_MAP_4 = {42
"........................"43
+ "............o..........."44
+ "..1....................."45
+ ".........e.........u...."46
+ "........---.......---..."47
+ "......s................."48
+ "...xxtxxxxxx..-.....3..."49
+ ".....w...b.............."50
+ "...e.w............j....."51
+ "..---x...........ejj...."52
+ "..............xtxxxxxx.."53
+ "...2.....---...w........"54
+ "....p..........w........"55
+ "..xxxxx................."56
"........................"57
- "...b.....1....e...k....."58
- "............-txx-......."59
+ "........................"60
+};61
+62
+const char *LEVEL_MAP_5 = {63
+ "........................"64
+ "........................"65
+ "...b.....1........k....."66
+ ".........z..-txx-......."67
".............w.........."68
"............-w..-......."69
- "........s....w......u..."70
+ ".............w......u..."71
"..x---xxxxxxxtxxx--xxx.."72
"....e........w....e....."73
"...---....2..w--txxx...."74
@@ -63,39 +101,6 @@ const char *LEVEL_MAP_3 = {75
"........................"76
};78
-// const char *LEVEL_MAP_3 = {79
-// "........................................"80
-// "........................................"81
-// "........................................"82
-// "........................................"83
-// "........................................"84
-// "........................................"85
-// "........................................"86
-// "........................................"87
-// "........................................"88
-// "........................................"89
-// "......e..................e...s.........."90
-// "....xxxxx...--...xxxxxxxxxxxxxxxxx......"91
-// "........................................"92
-// "............--.........................."93
-// "....................e..................."94
-// "............--...xxxxxxxxt-............."95
-// ".........................w.............."96
-// "............--...........w-............."97
-// "..............e.......s..w..e..........."98
-// "..........xxxxxxxxxxxxxxxxxxxxxxxt--x..."99
-// ".................................w......"100
-// ".................................w--...."101
-// ".................................w......"102
-// ".................................w--...."103
-// "........................e........w......"104
-// "....................xxtxxxtxx----x--...."105
-// "....p.......e.........w...w............."106
-// "..xxxxx..-----...xxxxxxxxxxxxxxxxxxxxx.."107
-// "........................................"108
-// "........................................"109
-// };110
-111
void level_generate(game_t *game, const char *map, int width, int height) {112
game->player = NULL;113
game->tiles = malloc(sizeof(tile_t) * width * height);114
@@ -161,6 +166,9 @@ void level_generate(game_t *game, const char *map, int width, int height) {115
case '3':116
tile->type = TILE_BG_BRICK_3;117
break;118
+ case 'I':119
+ tile->type = TILE_BG_INFO;120
+ break;121
default:122
break;123
}124
@@ -258,9 +266,18 @@ void level_load(game_t *game, level_e type) {125
level_generate(game, LEVEL_MAP_3, 24, 16);126
level->width = 24;127
level->height = 16;128
- // level_generate(game, LEVEL_MAP_3, 40, 30);129
- // level->width = 40;130
- // level->height = 30;131
+ break;132
+ }133
+ case LEVEL_4: {134
+ level_generate(game, LEVEL_MAP_4, 24, 16);135
+ level->width = 24;136
+ level->height = 16;137
+ break;138
+ }139
+ case LEVEL_5: {140
+ level_generate(game, LEVEL_MAP_5, 24, 16);141
+ level->width = 24;142
+ level->height = 16;143
break;144
}145
}
diff --git a/src/player.c b/src/player.c
index 35cba26..5c07aa0 100644
--- a/src/player.c
+++ b/src/player.c
1
@@ -384,6 +384,10 @@ void player_update(player_t *player, game_t *game) {2
for (int i = 0; i < game->entities_len; i++) {3
entity_t *entity = &game->entities[i];4
if (entity->is_bad) {5
+ // ignore gates6
+ if (entity->type == ENTITY_GATE) {7
+ continue;8
+ }9
// ignore frozen enemies10
if (entity->type == ENTITY_ENEMY && entity->enemy->frozen) {11
continue;
diff --git a/src/tile.c b/src/tile.c
index ec86b51..7f3f453 100644
--- a/src/tile.c
+++ b/src/tile.c
1
@@ -86,6 +86,10 @@ void tile_draw(tile_t *tile, game_t *game) {2
DrawTextureRec(game->assets.background, texture_rect_v(0, 6, 2, 2, TILE_WIDTH, TILE_HEIGHT), tile->pos, WHITE);3
break;4
}5
+ case TILE_BG_INFO: {6
+ DrawTextureRec(game->assets.background, texture_rect_v(12, 0, 10, 6, TILE_WIDTH, TILE_HEIGHT), tile->pos, WHITE);7
+ break;8
+ }9
}10
}