Browse Source

Speicherschwein, Speicherschwein... wer kann das was ein Speicherschwein kann?

feature/2015
Christian Kroll 14 years ago
parent
commit
108cf1321d
  1. 9
      games/breakout/breakout.c
  2. 12
      games/breakout/playfield.c
  3. 1
      games/breakout/playfield.h

9
games/breakout/breakout.c

@ -39,6 +39,13 @@ void borg_breakout_game()
void borg_breakout(uint8_t demomode)
{
// save pointer address just in case that the breakout demo was previously
// running so it can reentered
char (*old_playfield)[NUM_COLS][NUM_ROWS] = playfield;
// new playing field
char my_playfield[NUM_COLS][NUM_ROWS];
playfield = &my_playfield;
uint8_t ignorescore_buffer = ignorescore;
uint16_t cycles = DEMO_CYCLES;
uint8_t level;
@ -99,4 +106,6 @@ void borg_breakout(uint8_t demomode)
}
ignorescore = ignorescore_buffer;
// restore saved pointer
playfield = old_playfield;
}

12
games/breakout/playfield.c

@ -17,7 +17,7 @@
*/
#include "playfield.h"
static enum game_field_t playfield[NUM_COLS][NUM_ROWS];
char (*playfield)[NUM_COLS][NUM_ROWS];
void playfield_set (uint8_t in_x, uint8_t in_y, enum game_field_t in_field)
{
@ -25,15 +25,15 @@ void playfield_set (uint8_t in_x, uint8_t in_y, enum game_field_t in_field)
{
return;
}
playfield[in_x][in_y] = in_field;
(*playfield)[in_x][in_y] = in_field;
}
void brick_damage (uint8_t in_x, uint8_t in_y)
{
if (playfield[in_x][in_y] >= bs || playfield[in_x][in_y] == 0)
if ((*playfield)[in_x][in_y] >= bs || (*playfield)[in_x][in_y] == 0)
return;
playfield[in_x][in_y] -= 1;
(*playfield)[in_x][in_y] -= 1;
score_add (1);
}
@ -53,7 +53,7 @@ uint8_t check_bounce (int8_t in_x, int8_t in_y)
}
/* collisions with real objects */
switch (playfield[abs(in_x)][abs(in_y)])
switch ((*playfield)[abs(in_x)][abs(in_y)])
{
case b2:
case b3:
@ -119,7 +119,7 @@ void playfield_draw ()
{
for (y=0;y<NUM_COLS;y++)
{
draw_single_field (x,y, playfield[x][y]);
draw_single_field (x,y, (*playfield)[x][y]);
}
}
}

1
games/breakout/playfield.h

@ -37,6 +37,7 @@ enum game_field_t
rb /* rebound */
};
extern char (*playfield)[NUM_COLS][NUM_ROWS];
/* @description draw the current field
*/

Loading…
Cancel
Save