added breakout demo animation

This commit is contained in:
Christian Kroll 2010-04-09 20:41:23 +00:00
parent dae3a805e7
commit 96939cf72d
12 changed files with 115 additions and 17 deletions

View File

@ -25,5 +25,8 @@ ifeq ($(ANIMATION_GAMEOFLIFE),y)
SRC += gameoflife.c SRC += gameoflife.c
endif endif
ifeq ($(ANIMATION_BREAKOUT),y)
SRC += breakout_demo.c
endif
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk

View File

@ -0,0 +1,6 @@
#include "../games/breakout/breakout.h"
void breakout_demo()
{
borg_breakout(1);
}

View File

@ -0,0 +1,6 @@
#ifndef BREAKOUT_DEMO_H_
#define BREAKOUT_DEMO_H_
void breakout_demo();
#endif /* BREAKOUT_DEMO_H_ */

View File

@ -74,6 +74,7 @@ comment "Animations"
dep_bool "Stonefly" ANIMATION_STONEFLY $RANDOM_SUPPORT $GAME_TETRIS_CORE dep_bool "Stonefly" ANIMATION_STONEFLY $RANDOM_SUPPORT $GAME_TETRIS_CORE
dep_bool "Flying Dots" ANIMATION_FLYINGDOTS $RANDOM_SUPPORT dep_bool "Flying Dots" ANIMATION_FLYINGDOTS $RANDOM_SUPPORT
dep_bool "Game of Life" ANIMATION_GAMEOFLIFE $RANDOM_SUPPORT dep_bool "Game of Life" ANIMATION_GAMEOFLIFE $RANDOM_SUPPORT
dep_bool "Breakout Demo" ANIMATION_BREAKOUT $GAME_BREAKOUT
bool "M Herweg" ANIMATION_MHERWEG bool "M Herweg" ANIMATION_MHERWEG
comment "Special Animations" comment "Special Animations"

View File

@ -9,6 +9,7 @@
#include "animations/gameoflife.h" #include "animations/gameoflife.h"
#include "animations/stonefly.h" #include "animations/stonefly.h"
#include "animations/flyingdots.h" #include "animations/flyingdots.h"
#include "animations/breakout_demo.h"
#include "borg_hw/borg_hw.h" #include "borg_hw/borg_hw.h"
#include "can/borg_can.h" #include "can/borg_can.h"
#include "random/prng.h" #include "random/prng.h"
@ -117,8 +118,14 @@ void display_loop(){
break; break;
#endif #endif
#ifdef ANIMATION_MHERWEG #ifdef ANIMATION_BREAKOUT
case 12: case 12:
breakout_demo();
break;
#endif
#ifdef ANIMATION_MHERWEG
case 13:
lines1(); lines1();
dots1(); dots1();
movinglines(); movinglines();

View File

@ -17,7 +17,7 @@
*/ */
#include "common.h" #include "common.h"
static void borg_breakout(); #include "breakout.h"
#ifdef MENU_SUPPORT #ifdef MENU_SUPPORT
//static uint8_t breakout_icon[8] PROGMEM = {0x03, 0x03, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00}; /* our Icon */ //static uint8_t breakout_icon[8] PROGMEM = {0x03, 0x03, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00}; /* our Icon */
@ -25,14 +25,34 @@ static uint8_t breakout_icon[8] PROGMEM = {0x00, 0x18, 0x18, 0x00, 0x00, 0xff, 0
game_descriptor_t breakout_game_descriptor __attribute__((section(".game_descriptors"))) = game_descriptor_t breakout_game_descriptor __attribute__((section(".game_descriptors"))) =
{ {
&borg_breakout, &borg_breakout_game,
breakout_icon breakout_icon
}; };
#endif #endif
void borg_breakout()
void borg_breakout_game()
{ {
uint8_t level = 0; borg_breakout(0);
}
void borg_breakout(uint8_t demomode)
{
uint8_t ignorescore_buffer = ignorescore;
uint16_t cycles = DEMO_CYCLES;
uint8_t level;
if (demomode)
{
level = 4;
ignorescore = 1;
}
else
{
level = 0;
ignorescore = 0;
}
ball_t balls[1]; ball_t balls[1];
/* spawn a ball in the middle bottom of the field, let it move upwards with random speed & direction */ /* spawn a ball in the middle bottom of the field, let it move upwards with random speed & direction */
@ -41,10 +61,15 @@ void borg_breakout()
level_init(level); level_init(level);
rebound_init(); rebound_init();
while (23) while (cycles != 0)
{ {
wait(50); wait(50);
rebound_tick();
if (demomode)
rebound_tick(&balls[0]);
else
rebound_tick(NULL);
ball_think(&(balls[0])); ball_think(&(balls[0]));
playfield_draw(); playfield_draw();
ball_draw(&(balls[0])); ball_draw(&(balls[0]));
@ -63,5 +88,10 @@ void borg_breakout()
level_init(level); level_init(level);
rebound_init(); rebound_init();
} }
if (demomode)
--cycles;
} }
ignorescore = ignorescore_buffer;
} }

28
games/breakout/breakout.h Normal file
View File

@ -0,0 +1,28 @@
/*
* 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)
*
*/
#ifndef BREAKOUT_H_
#define BREAKOUT_H_
#include <stdint.h>
void borg_breakout_game();
void borg_breakout(uint8_t demomode);
#endif /* BREAKOUT_H_ */

View File

@ -30,5 +30,7 @@ static const int8_t rebound_reflection[6][2] =
{ 72, -20} /* offside right */ { 72, -20} /* offside right */
}; };
#define DEMO_CYCLES 1200;
#endif /* CONFIG_H */ #endif /* CONFIG_H */

View File

@ -54,8 +54,19 @@ void rebound_draw ()
printf("rpos: %i\n", rbpos); printf("rpos: %i\n", rbpos);
} }
void rebound_tick() void rebound_tick(ball_t *ball)
{ {
if (ball != NULL)
{
rbpos = (uint8_t) abs(ball->x / 256);
if (rbpos < 0)
rbpos = 0;
if (rbpos > (NUM_COLS - REBOUND_SIZE))
rbpos = NUM_COLS - REBOUND_SIZE;
rebound_draw();
}
else
{
/* directions are inverted (JOYISLEFT means RIGHT) */ /* directions are inverted (JOYISLEFT means RIGHT) */
if (JOYISRIGHT && rbpos) if (JOYISRIGHT && rbpos)
{ {
@ -68,4 +79,5 @@ void rebound_tick()
rbpos++; rbpos++;
rebound_draw(); rebound_draw();
} }
}
} }

View File

@ -20,7 +20,7 @@
#ifndef REBOUND_H #ifndef REBOUND_H
#define REBOUND_H #define REBOUND_H
void rebound_init(); void rebound_init();
void rebound_tick(); void rebound_tick(ball_t *ball);
void rebound_draw(); void rebound_draw();
uint8_t rebound_getpos(); uint8_t rebound_getpos();
void rebound_reflect(ball_t *b, int8_t in_x); void rebound_reflect(ball_t *b, int8_t in_x);

View File

@ -17,8 +17,10 @@
*/ */
#include "score.h" #include "score.h"
static uint16_t score = 0; static uint16_t score = 0;
void score_add (uint8_t in_score) void score_add (uint8_t in_score)
{ {
if (!ignorescore)
score += in_score; score += in_score;
} }

View File

@ -20,6 +20,7 @@
#ifndef SCORE_H #ifndef SCORE_H
#define SCORE_H #define SCORE_H
uint8_t ignorescore;
void score_add(uint8_t); void score_add(uint8_t);
uint16_t score_get(); uint16_t score_get();