ReflexBall Rally
 All Data Structures Files Functions Variables Macros
reflexball.h
Go to the documentation of this file.
1 #ifndef _reflexball_h_
2 #define _reflexball_h_
3 
4 #include "ansi.h"
5 #include "math.h"
6 
7 #define STRIKER_MAX_WIDTH 30 // This has to be even
8 #define STRIKER_MAX_ANGLE 64 // 360 deg = 512
9 #define NLIVES 3
10 #define DEFAULT_DIFFICULTY 40
11 #define UART_MAX_SPEED 20 // If it gets below this value, we will only draw it every second time or if it hits an object, this is because the UART can not send the characters fast enough
12 #define MAX_DIFFICULTY 10 // If speed gets under this value the UART can no longer keep up
13 #define BALL_WIDTH 4 // The modulus of this number should be even
14 #define BALL_HEIGHT 2
15 
16 #define BRICK_TABLE_WIDTH 14
17 #define BRICK_TABLE_HEIGHT 20
18 
19 
20 typedef struct {
21  long x, y; // (x,y) is in the top left corner - these use the 18.14 format
22  unsigned char width, height;
24 } Ball;
25 
26 typedef struct {
27  unsigned char x, y, width;
28 } Striker;
29 
30 typedef struct {
31  unsigned char x, y; // (x,y) is in the top left corner
32  unsigned char lives;
33  unsigned char width, height;
34 } Brick;
35 
36 extern unsigned char divider; // This is the difficulty set in the beginning
37 extern unsigned char strikerWidth; // This is the striker width determent from the selected difficulty
38 extern unsigned char restartGame; // True if the user have won the game
39 
40 // Public
41 void initReflexBall(unsigned char newX1, unsigned char newY1, unsigned char newX2, unsigned char newY2, char style);
42 void startGame();
43 void stopGame();
44 void updateGame();
45 void moveStriker(char dir);
46 
47 // Private
48 void printLevel();
49 void printLives();
50 void printScore();
51 void showScoreLED();
52 void scrollLiveInGameLED();
53 void scrollLevelUp();
54 void scrollAll();
55 void dead();
56 unsigned char getTerminalCoordinate(long input);
57 void gotoxyBall(long x, long y);
58 void clearBigBall(long x, long y);
59 void drawBigBall();
60 void drawBrick(Brick *brick);
61 void checkIteration(unsigned char x, unsigned char y);
62 void setBallPos(unsigned char x, unsigned char y);
63 void iterate();
64 void drawStriker();
65 void ballPosStriker();
66 void initStriker(unsigned char x, unsigned y, unsigned char width);
67 void initBricks(char clear);
68 void initBall();
69 void drawLevel();
70 void levelUp();
71 
72 #endif