2010-01-15 12:19:54 +00:00
|
|
|
#include "level.h"
|
|
|
|
|
|
|
|
/* real level definition */
|
2010-01-15 16:02:31 +00:00
|
|
|
enum game_field_t level_field (uint8_t in_x, uint8_t in_y, uint8_t in_lvl);
|
|
|
|
enum game_field_t level_field (uint8_t in_x, uint8_t in_y, uint8_t in_lvl)
|
2010-01-15 12:19:54 +00:00
|
|
|
{
|
|
|
|
switch (in_lvl)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
/* space for the lower half of the level */
|
2010-01-19 09:55:28 +00:00
|
|
|
if (in_y > (NUM_ROWS / 2))
|
2010-01-15 12:19:54 +00:00
|
|
|
return sp;
|
|
|
|
|
|
|
|
/* type 2 bricks for 1/4th of the field */
|
2010-01-19 09:55:28 +00:00
|
|
|
if (in_y <= (NUM_ROWS / 4))
|
2010-01-15 12:19:54 +00:00
|
|
|
return b2;
|
|
|
|
|
|
|
|
/* fill the rest with type 1 */
|
|
|
|
return b1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
/* add a row of solid bricks right in the middle of the field */
|
|
|
|
if (in_y == (NUM_ROWS / 2) &&
|
2010-01-15 14:42:46 +00:00
|
|
|
(in_x > (NUM_COLS / 4)) && (in_x < (NUM_COLS - (NUM_COLS / 4))))
|
2010-01-15 12:19:54 +00:00
|
|
|
return bs;
|
|
|
|
|
|
|
|
/* intentional fallthrough: the rest of level 3 is like level 2 */
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
/* space for the lower third of the level */
|
2010-01-19 09:55:28 +00:00
|
|
|
if (in_y > (NUM_ROWS / 3))
|
2010-01-15 12:19:54 +00:00
|
|
|
return sp;
|
|
|
|
|
|
|
|
/* type 3 bricks for 1/8th of the field */
|
2010-01-19 09:55:28 +00:00
|
|
|
if (in_y <= (NUM_ROWS / 8))
|
2010-01-15 12:19:54 +00:00
|
|
|
return b3;
|
|
|
|
|
|
|
|
/* type 2 bricks for 1/4th of the field */
|
2010-01-19 09:55:28 +00:00
|
|
|
if (in_y <= (NUM_ROWS / 4))
|
2010-01-15 12:19:54 +00:00
|
|
|
return b2;
|
|
|
|
|
|
|
|
/* fill the rest with type 1 */
|
|
|
|
return b1;
|
|
|
|
|
|
|
|
default: /* random level generation */
|
|
|
|
/* space for the lower half of the level */
|
2010-01-19 09:55:28 +00:00
|
|
|
if (in_y > (NUM_ROWS / 2))
|
2010-01-15 12:19:54 +00:00
|
|
|
return sp;
|
|
|
|
|
2010-01-19 19:44:16 +00:00
|
|
|
return random8() & 0x03; /* fill field with random bricks (and spaces) */
|
2010-01-15 12:19:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void level_init (uint8_t in_levelnum)
|
|
|
|
{
|
|
|
|
uint8_t x,y;
|
|
|
|
|
|
|
|
for (x=0;x<NUM_COLS;x++)
|
|
|
|
{
|
|
|
|
for (y=0;y<NUM_ROWS;y++)
|
|
|
|
{
|
|
|
|
playfield_set (x,y, level_field (x, y, in_levelnum));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|