diff options
| -rw-r--r-- | src/all.c | 13 | ||||
| -rw-r--r-- | src/levels.c | 157 | 
2 files changed, 162 insertions, 8 deletions
| @@ -325,7 +325,6 @@ static DrawList *render(State *state, UI *ui, Arena *a) {  				for (int y = 0; y < 2; y++) {  					drawList->els[drawList->len++] = (DrawElement) {  						.x = BUTTON_SIZE / 2 + x * (BUTTON_SIZE / 2), -						// .y = (BUTTON_SIZE / 2 + y * (BUTTON_SIZE / 2) + BUTTON_SPACING * (cellCount % 2 + 1)) * (cellCount + 1), // TODO - padding  						.y = BUTTON_SIZE / 2 + i * (BUTTON_SIZE + BUTTON_SPACING) + y * (BUTTON_SIZE / 2),  						.w = BUTTON_SIZE / 2,  						.h = BUTTON_SIZE / 2, @@ -344,12 +343,11 @@ static void restart_level(Game* game) {  	xmemcpy(&game->state.grid, &levels[level].grid, sizeof(game->state.grid));  	game->state.goalx = levels[level].goalx;  	game->state.goaly = levels[level].goaly; -	game->state.playing = 0; +	game->state.playing = 1;  	xmemcpy(&game->state.placeableCells, &levels[level].placeableCells, sizeof(game->state.placeableCells));  }  static void update(Game *game, uint64_t now, Arena a) { -	// TODO - offset some more because of right black bar, dependent on ui size and window size?  	const int offset_width = game->ui.width - GRID_OFFSET_X;  	switch (game->input) { @@ -399,9 +397,12 @@ static void update(Game *game, uint64_t now, Arena a) {  							restart_level(game);  							break;  						case BUTTON_CONTINUE: -							// TODO - get size of levels array -							if (!game->state.levelComplete || game->state.currentLevel + 1 >= 2) +							if ( +								!game->state.levelComplete || +								game->state.currentLevel + 1 >= sizeof(levels) / sizeof(levels[0]) +							) {  								break; +							}  							game->state.levelComplete = 0;  							game->state.currentLevel++;  							restart_level(game); @@ -466,7 +467,7 @@ int main(int argc, char **argv) {  	};  	Game *game = new(&a, 1, Game); -	game->state.currentLevel = 0; +	game->state.currentLevel = 5;  	restart_level(game);  	game->ui = (UI) {  		.width = 640, diff --git a/src/levels.c b/src/levels.c index 21c3503..f0254d4 100644 --- a/src/levels.c +++ b/src/levels.c @@ -6,11 +6,18 @@  #define _ EMPTY,  #define B BLACK,  #define O BLUE, +#define R RED, +#define r YELLOW, +#define RL RED_LEFT, +#define RR RED_RIGHT, +#define RU RED_UP, +#define RD RED_DOWN,  static Level levels[] = {  	{  		.grid = { +			// level 1  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ -			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  RU _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ @@ -33,6 +40,34 @@ static Level levels[] = {  		},  	},  	{ +		// level 2 +		.grid = { +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  O  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _  _  B +			_  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +		}, +		.goalx = 18, +		.goaly = 10, +		.placeableCells = { +			RED, +			RED, +		}, +	}, +	{ +		// level 3  		.grid = {  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ @@ -45,7 +80,7 @@ static Level levels[] = {  			_  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _  _  B -			_  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  B  B  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ @@ -58,9 +93,127 @@ static Level levels[] = {  			RED,  		},  	}, +	{ +		// level 4 +		.grid = { +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  B  B  B  B  B  B  B  B  B  B  B  _  _  _  _  _  _  _ +			_  _  B  _  B  O  _  _  _  _  _  O  B  _  _  _  _  _  _  _ +			_  _  _  _  B  _  _  _  _  _  B  B  B  _  _  _  _  _  _  _ +			_  _  _  _  B  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _ +			_  _  _  _  B  _  _  _  _  _  _  B  _  _  _  _  _  _  _  _ +			_  _  _  _  _  B  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  B  _  _  _  _  O  B  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _ +		}, +		.goalx = 10, +		.goaly = 13, +		.placeableCells = { +			RED, +		}, +	}, +	{ +		// level 5 +		.grid = { +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  R  B  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  r  B  _  _  _  _  _  _ +			_  _  _  _  r  RD _  _  _  _  _  _  _  _  B  _  _  _  _  _ +			_  _  _  _  B  B  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  RU _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _ +			_  _  R  r  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _ +			_  _  B  B  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  B  _  _  _  RU _  _  _  _  B  _  _ +			_  _  _  _  _  _  _  _  B  _  _  _  _  B  _  _  _  _  _  _ +			_  _  _  _  _  _  O  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +		}, +		.goalx = 16, +		.goaly = 10, +		.placeableCells = { +			RED, +		}, +	}, +	{ +		// level 6 +		.grid = { +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  RU _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  B  _  _  _  _  O  B  _  _  _  _  _  _  _  _ +			_  _  _  _  _  B  _  _  _  _  O  B  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +		}, +		.goalx = 6, +		.goaly = 11, +		.placeableCells = { +			RED, +			RED_UP, +			RED_DOWN, +			RED_LEFT, +			RED_RIGHT, +		}, +	}, +	{ +		// level 7 +		.grid = { +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  RU _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  B  _  _  _  _  O  B  _  _  _  _  _  _  _  _ +			_  _  _  _  _  B  _  _  _  _  O  B  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  B  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +			_  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _ +		}, +		.goalx = 6, +		.goaly = 11, +		.placeableCells = { +			RED, +			RED_UP, +			RED_DOWN, +			RED_LEFT, +			RED_RIGHT, +		}, +	},  };  #undef _  #undef B  #undef O +#undef R +#undef r +#undef RR +#undef RL +#undef RU +#undef RD  #endif // INCLUDE_LEVELS_C | 
