2010-01-29 01:34:24 +00:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
* Place - Suite 330, Boston, MA 02111-1307 USA.
|
|
|
|
*
|
|
|
|
* Author & Copyright (C) 2010: Soeren Heisrath (forename@surename.org)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
2010-04-09 20:41:23 +00:00
|
|
|
#include "breakout.h"
|
2010-01-29 01:34:24 +00:00
|
|
|
|
|
|
|
#ifdef MENU_SUPPORT
|
|
|
|
//static uint8_t breakout_icon[8] PROGMEM = {0x03, 0x03, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00}; /* our Icon */
|
2011-09-04 01:08:13 +00:00
|
|
|
static const uint8_t breakout_icon[8] PROGMEM = {0x00, 0x18, 0x18, 0x00, 0x00, 0xff, 0xff, 0x00}; /* our Icon */
|
2010-01-29 01:34:24 +00:00
|
|
|
|
|
|
|
game_descriptor_t breakout_game_descriptor __attribute__((section(".game_descriptors"))) =
|
|
|
|
{
|
2010-04-09 20:41:23 +00:00
|
|
|
&borg_breakout_game,
|
2010-01-29 01:34:24 +00:00
|
|
|
breakout_icon
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2010-04-09 20:41:23 +00:00
|
|
|
|
|
|
|
void borg_breakout_game()
|
2010-01-29 01:34:24 +00:00
|
|
|
{
|
2010-04-09 20:41:23 +00:00
|
|
|
borg_breakout(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void borg_breakout(uint8_t demomode)
|
|
|
|
{
|
2011-02-25 04:31:34 +00:00
|
|
|
game_field_t my_playfield[NUM_COLS][NUM_ROWS];
|
2010-12-20 22:52:39 +00:00
|
|
|
playfield = &my_playfield;
|
|
|
|
|
2010-04-09 20:41:23 +00:00
|
|
|
uint16_t cycles = DEMO_CYCLES;
|
2010-12-21 13:15:32 +00:00
|
|
|
uint8_t level = demomode ? random8() % 5 : 0;
|
2010-01-29 01:34:24 +00:00
|
|
|
ball_t balls[1];
|
|
|
|
|
2012-11-25 14:30:53 +00:00
|
|
|
score_reset();
|
2010-01-29 01:34:24 +00:00
|
|
|
/* spawn a ball in the middle bottom of the field, let it move upwards with random speed & direction */
|
|
|
|
ball_spawn_default(&(balls[0]));
|
|
|
|
balls[0].strength = START_LIFES;
|
|
|
|
level_init(level);
|
2011-01-30 22:47:44 +00:00
|
|
|
uint8_t tick_divider = 1;
|
2010-01-29 01:34:24 +00:00
|
|
|
rebound_init();
|
|
|
|
|
2010-04-09 20:41:23 +00:00
|
|
|
while (cycles != 0)
|
2010-01-29 01:34:24 +00:00
|
|
|
{
|
2010-08-22 03:11:49 +00:00
|
|
|
wait(25);
|
2010-04-09 20:41:23 +00:00
|
|
|
|
2011-01-30 22:47:44 +00:00
|
|
|
if (tick_divider || JOYISFIRE)
|
2010-08-22 03:11:49 +00:00
|
|
|
rebound_tick(demomode ? &balls[0] : NULL);
|
2010-01-29 01:34:24 +00:00
|
|
|
|
2011-01-30 22:47:44 +00:00
|
|
|
if (tick_divider)
|
2010-01-29 01:34:24 +00:00
|
|
|
{
|
2010-08-22 03:11:49 +00:00
|
|
|
ball_think(&(balls[0]));
|
|
|
|
playfield_draw();
|
|
|
|
ball_draw(&(balls[0]));
|
|
|
|
if (!balls[0].strength)
|
|
|
|
{
|
|
|
|
print_score();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!level_getscorediff())
|
|
|
|
{
|
|
|
|
level++;
|
|
|
|
/* respawn ball at rebound position */
|
|
|
|
ball_spawn_default (&(balls[0]));
|
|
|
|
balls[0].strength++;
|
|
|
|
level_init(level);
|
|
|
|
rebound_init();
|
|
|
|
}
|
2010-01-29 01:34:24 +00:00
|
|
|
}
|
2010-04-09 20:41:23 +00:00
|
|
|
|
|
|
|
if (demomode)
|
|
|
|
--cycles;
|
2010-08-22 03:11:49 +00:00
|
|
|
|
|
|
|
// alternate the value of the tick divider
|
|
|
|
tick_divider = tick_divider ? 0 : 1;
|
2010-01-29 01:34:24 +00:00
|
|
|
}
|
|
|
|
}
|