36 printf(
"Level: %d",
level+1);
40 printf(
"Lives: %d",
lives);
44 printf(
"Score: %04d$",
score);
89 output += (input >> (FIX14_SHIFT-1)) & 0x1;
105 const unsigned char top = 238, bottom = 95, slash =
'/', backSlash =
'\\';
118 printf(
"%c%c%c%c",slash,top,top,backSlash);
120 printf(
"%c%c%c%c",backSlash,bottom,bottom,slash);
124 unsigned char i, j, brickStyle;
125 for (i=0;i<brick->
height;i++) {
127 for (j=0;j<brick->
width;j++) {
130 else if (brick->
lives == 1)
132 else if (brick->
lives == 2)
134 else if (brick->
lives == 3)
136 else if (brick->
lives == 4)
140 printf(
"%c",brickStyle);
146 unsigned char i, j, dontDeflectX = 0, dontDeflectY = 0, deflectedX = 0, deflectedY = 0;
153 if (!bricks[i][j].
lives)
156 if (y-1 == bricks[i][j].y+bricks[i][j].height-1 || y+ball.
height-1 == bricks[i][j].
y-1 || x+ball.
width-1 == bricks[i][j].
x-1 || x-1 == bricks[i][j].
x+bricks[i][j].
width-1)
160 if (y <= bricks[i][j].y+bricks[i][j].height-1 && y+ball.
height-1 >= bricks[i][j].
y && x+ball.
width-1 >= bricks[i][j].
x && x <= bricks[i][j].
x+bricks[i][j].
width-1) {
167 if (y <= bricks[i][j].y+bricks[i][j].height-1 && y+ball.
height-1 >= bricks[i][j].
y) {
169 if (x+ball.
width-1 == bricks[i][j].
x || x+ball.
width-2 == bricks[i][j].
x || x == bricks[i][j].
x+bricks[i][j].
width-1 || x == bricks[i][j].
x+bricks[i][j].
width-2) {
170 if (y+ball.
height-1 >= bricks[i][j].
y && y <= bricks[i][j].
y) {
171 if (i > 0 && bricks[i-1][j].lives) {
177 if (y <= bricks[i][j].y+bricks[i][j].height-1 && y+ball.
height-1 >= bricks[i][j].
y+bricks[i][j].
height-1) {
178 if (i+1 < BRICK_TABLE_HEIGHT && bricks[i+1][j].lives) {
184 }
else if (y >= bricks[i][j].y && y+ball.
height-1 <= bricks[i][j].
y+bricks[i][j].
height-1)
187 if (y+ball.
height-1 >= bricks[i][j].
y && y <= bricks[i][j].
y) {
188 if (ball.
vector.
y & 0x80000000) {
194 if (y <= bricks[i][j].y+bricks[i][j].height-1 && y+ball.
height-1 >= bricks[i][j].
y+bricks[i][j].
height-1) {
197 if (!(ball.
vector.
y & 0x80000000)) {
215 if (x+ball.
width-1 == bricks[i][j].
x || x+ball.
width-2 == bricks[i][j].
x || x == bricks[i][j].
x+bricks[i][j].
width-1 || x == bricks[i][j].
x+bricks[i][j].
width-2) {
217 if ((y+ball.
height-1 >= bricks[i][j].
y && y <= bricks[i][j].
y) || (y <= bricks[i][j].
y+bricks[i][j].
height-1 && y+ball.
height-1 >= bricks[i][j].
y+bricks[i][j].
height-1)) {
218 if (x+ball.
width-1 == bricks[i][j].
x || x+ball.
width-2 == bricks[i][j].
x) {
219 if (j > 0 && bricks[i][j-1].lives) {
225 if (x == bricks[i][j].x+bricks[i][j].width-1 || x == bricks[i][j].x+bricks[i][j].width-2) {
226 if (j+1 < BRICK_TABLE_WIDTH && bricks[i][j+1].lives) {
234 if (x+ball.
width-1 == bricks[i][j].
x || x+ball.
width-2 == bricks[i][j].
x) {
235 if (ball.
vector.
x & 0x80000000) {
241 if (x == bricks[i][j].x+bricks[i][j].width-1 || x == bricks[i][j].x+bricks[i][j].width-2) {
242 if (!(ball.
vector.
x & 0x80000000)) {
249 if (y != bricks[i][j].y) {
250 if (y < bricks[i][j].y) {
251 if (!(ball.
vector.
y & 0x80000000) && !(i > 0 && bricks[i-1][j].
lives)) {
257 if (ball.
vector.
y & 0x80000000 && !(i+1 < BRICK_TABLE_HEIGHT && bricks[i+1][j].
lives)) {
275 bricks[i][j].
lives--;
283 angle = (int)(
millis() & 0x7) - 3;
292 if (dontDeflectX && dontDeflectY) {
308 if (x <= x1 || x+ball.width >=
x2) {
312 if ((y <=
y1) || (y+ball.
height-1 == striker.
y && x+ball.
width > striker.
x && x < striker.
x+striker.
width)) {
313 if (y+ball.
height-1 == striker.
y) {
317 distance = x+ball.
width-1 - striker.
x;
336 if (((ball.
vector.
y >> 12) & 0x7) == 0) {
346 if (ball.
vector.
x & 0x80000000)
364 if (x ==
x1+1 || x+ball.
width ==
x2-1 || y ==
y1+1 || (y+ball.
height-1 == striker.
y-1 && x+ball.
width > striker.
x && x < striker.
x+striker.
width))
384 const unsigned char strikerStyle = 223;
389 for (i=0;i<striker.
width;i++)
390 printf(
"%c",strikerStyle);
408 if ((
int)striker.
x + dir <=
x1)
410 else if (striker.
x+striker.
width-1 + dir >=
x2)
420 for (; absDir > 0; absDir--)
432 void initStriker(
unsigned char x,
unsigned y,
unsigned char width) {
433 unsigned char i, dAngle, strikerZones;
440 striker.
x = x - width/2;
442 striker.
width = width;
448 for (i = 1; i <= strikerZones; i++) {
465 bricks[i][j].
width = 14;
470 bricks[i][j].
x =
x1+6 + (bricks[i][j].
width+1)*j;
471 bricks[i][j].
y =
y1+3 + (bricks[i][j].
height+1)*i;
472 if (bricks[i][j].
lives || clear)
496 startAngle = (
millis() & 0x7F) - 192;
541 for (i=0;i<striker.
width;i++)
578 void initReflexBall(
unsigned char newX1,
unsigned char newY1,
unsigned char newX2,
unsigned char newY2,
char style) {
579 unsigned char leftTop, rightTop, leftBot, rightBot, verSide, horSide, leftCross, rightCross;