nu aber...

This commit is contained in:
soeren 2010-01-21 21:26:30 +00:00
parent ab08ab3fa2
commit 68dee06285
12 changed files with 44 additions and 46 deletions

10
games/breakout/Makefile Normal file
View File

@ -0,0 +1,10 @@
TARGET =
TOPDIR = ../..
include $(TOPDIR)/defaults.mk
ifeq ($(GAME_BREAKOUT),y)
SRC = breakout.c playfield.c rebound.c score.c level.c ball.c messages.c
endif
include $(TOPDIR)/rules.mk

View File

@ -75,6 +75,7 @@ void ball_think (ball_t *b)
ball_die (b);
bounce = check_bounce (proj_x, b->y / 256);
if (bounce & BOUNCE_UNDEF)
bounce = (BOUNCE_X | bounce) & (BOUNCE_X | BOUNCE_Y);
@ -98,7 +99,7 @@ void ball_think (ball_t *b)
#if BOUNCE_SLOWDOWN
if (bounce & BOUNCE_BRICK)
{
if (b->dir_y < -BALL_MINSPEED)
if (b->dir_y < - BALL_MINSPEED)
{
b->dir_y += BOUNCE_SLOWDOWN;
} else if (b->dir_y > BALL_MINSPEED)
@ -106,7 +107,7 @@ void ball_think (ball_t *b)
b->dir_y -= BOUNCE_SLOWDOWN;
}
if (b->dir_x < -BALL_MINSPEED)
if (b->dir_x < - BALL_MINSPEED)
{
b->dir_x += BOUNCE_SLOWDOWN;
} else if (b->dir_y > BALL_MINSPEED)
@ -124,23 +125,18 @@ void ball_think (ball_t *b)
if (b->dir_x > BALL_MAXSPEED)
b->dir_x = BALL_MAXSPEED;
if (b->dir_x < - BALL_MAXSPEED)
b->dir_x = - BALL_MAXSPEED;
if (b->dir_x < -BALL_MAXSPEED)
b->dir_x = -BALL_MAXSPEED;
if (b->dir_y > BALL_MAXSPEED)
b->dir_y = BALL_MAXSPEED;
if (b->dir_y < - BALL_MAXSPEED)
b->dir_y = - BALL_MAXSPEED;
if (b->dir_y < -BALL_MAXSPEED)
b->dir_y = -BALL_MAXSPEED;
b->y += b->dir_y;
b->x += b->dir_x;
if (!b->dir_x || !b->dir_y)
{
printf("Ball stopped!\n");
}
}
void ball_die (ball_t *in_b)

View File

@ -15,13 +15,11 @@
* Author & Copyright (C) 2010: Soeren Heisrath (forename@surename.org)
*
*/
#include "common.h"
#ifndef BALL_H
#define BALL_H
#include <stdint.h>
#include "common.h"
typedef struct
{

View File

@ -16,9 +16,8 @@
*
*/
#include <stdint.h>
#include "common.h"
void borg_breakout();
static void borg_breakout();
#ifdef MENU_SUPPORT
//static uint8_t breakout_icon[8] PROGMEM = {0x03, 0x03, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00}; /* our Icon */
@ -33,7 +32,7 @@ game_descriptor_t breakout_game_descriptor __attribute__((section(".game_descrip
void borg_breakout()
{
uint8_t rungame = 1, num_balls = 1, level = 0;
uint8_t level = 0;
ball_t balls[1];
/* spawn a ball in the middle bottom of the field, let it move upwards with random speed & direction */
@ -57,7 +56,6 @@ void borg_breakout()
if (!level_getscorediff())
{
printf("lvl done\n");
level++;
/* respawn ball at rebound position */
ball_spawn_default (&(balls[0]));

View File

@ -31,12 +31,10 @@
#include "../../menu/menu.h"
#include "../../pixel.h"
#include "config.h"
#include "playfield.h"
#include "ball.h"
#include "playfield.h"
#include "score.h"
#include "level.h"
#include "rebound.h"
#include "messages.h"
#define MAX(a,b) (a > b) ? a : b
#endif /* COMMON_H */

View File

@ -13,18 +13,6 @@
/* rebound size */
#define REBOUND_SIZE 4
/* rebound reflection: values to add to the vector at rebound field n
* note: directions are inverted
*/
static int8_t rebound_reflection[6][2] =
{
{-54,-20}, /* offside */
{-32,-12},
{-16, -8}, /* side ... middle */
{16, -8},
{32, -12},
{54, -20}
};
/* "color" of the rebound */
#define REBOUND_COLOR 2

View File

@ -21,7 +21,7 @@
void print_ballsleft (ball_t *in_b)
{
#ifdef SCROLLTEXT_SUPPORT
uint8_t txt[20];
char txt[20];
snprintf (txt, sizeof(txt), "</#%u balls left", in_b->strength);
scrolltext(txt);
#endif
@ -30,9 +30,8 @@ void print_ballsleft (ball_t *in_b)
void print_score ()
{
#ifdef SCROLLTEXT_SUPPORT
uint8_t txt[32];
char txt[32];
snprintf (txt, sizeof(txt), "</#GAME OVER. Your score: %u", score_get());
scrolltext(txt);
#endif
}

View File

@ -17,6 +17,7 @@
*/
#include "common.h"
#ifndef MESSAGES_H
#define MESSAGES_H

View File

@ -16,7 +16,7 @@
*
*/
#include "common.h"
#include "playfield.h"
static enum game_field_t playfield[NUM_COLS][NUM_ROWS];
void playfield_set (uint8_t in_x, uint8_t in_y, enum game_field_t in_field)
@ -30,8 +30,6 @@ void playfield_set (uint8_t in_x, uint8_t in_y, enum game_field_t in_field)
void brick_damage (uint8_t in_x, uint8_t in_y)
{
enum game_field_t newtype;
if (playfield[in_x][in_y] >= bs || playfield[in_x][in_y] == 0)
return;

View File

@ -16,9 +16,9 @@
*
*/
#include "common.h"
#ifndef PLAYFIELD_H
#define PLAYFIELD_H
#include "common.h"
#define BOUNCE_NONE 0x00
#define BOUNCE_X 0x01

View File

@ -17,6 +17,18 @@
*/
#include "rebound.h"
/* rebound reflection: values to add to the vector at rebound field n
*/
const int8_t rebound_reflection[6][2] =
{
{-54, -20}, /* offside */
{-32, -12}, /* left */
{-16, -8}, /* center */
{ 16, -8},
{ 32, -12},
{ 54, -20}
};
static uint8_t rbpos;
void rebound_reflect (ball_t *b, int8_t in_x)
@ -24,8 +36,6 @@ void rebound_reflect (ball_t *b, int8_t in_x)
uint8_t tmpidx;
tmpidx = (in_x - rbpos) +1;
printf("bounce idx %i\n", tmpidx);
b->dir_x += rebound_reflection[tmpidx][0];
b->dir_y += rebound_reflection[tmpidx][1];

View File

@ -15,11 +15,13 @@
* Author & Copyright (C) 2010: Soeren Heisrath (forename@surename.org)
*
*/
#include "common.h"
#ifndef REBOUND_H
#define REBOUND_H
#include "common.h"
void rebound_init();
void rebound_tick();
uint8_t rebound_getpos ();
void rebound_reflect (ball_t *b, int8_t in_x);
#endif
void rebound_draw();
uint8_t rebound_getpos();
void rebound_reflect(ball_t *b, int8_t in_x);
#endif /* REBOUND_H */