AberLED shield library
Library for the bicolor LED (and TFT screen) shield used in CS12020
main.cpp
Go to the documentation of this file.
1 #include "AberLED.h"
2 #include <EEPROM.h>
3 
4 //#define DEBUG
5 
6 //defining states
7 #define S_INVALID -1
8 #define S_INIT 0
9 #define S_INIT2 1
10 #define S_START 2
11 #define S_GAME 3
12 #define S_PAUSE 4
13 #define S_GAMEOVER 13
14 
15 
16 //defining buttons
17 #define BTN_UP 1
18 #define BTN_DOWN 2
19 #define BTN_LEFT 4
20 #define BTN_RIGHT 3
21 #define BTN_STOP 5
22 
23 //define entities
24 #define ENT_OBSTACLE 1
25 #define ENT_POWERUP 2
26 
27 
28 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
29 //Constants (changeable here)://
30 ////////////////////////////////
31 const byte MINX = 0;
32 const byte MINY = 0;
33 const byte MAXX = 7;
34 const byte MAXY = 7;
35 const int SPEED_CHANGE_TIME = 5;
36 const int OBSTACLE_CHANGE_TIME = 5;
37 
38 const byte LETTER_START [] = {2,1, 2,2, 5,1, 5,2, 1,4, 1,5, 2,6, 3,6, 4,6, 5,6, 6,5, 6,4 }; // x,y, x,y, x,y...
39 const byte LETTER_0 [] = { 0,0, 0,1, 0,2, 0,3, 0,4, 1,0, 1,4, 2,0, 2,1, 2,2, 2,3, 2,4 };
40 const byte LETTER_1 [] = { 1,0, 1,1, 1,2, 1,3, 1,4 };
41 const byte LETTER_2 [] = { 1,0, 1,2, 1,3, 1,4, 2,0, 2,1, 2,2, 2,4 };
42 const byte LETTER_3 [] = { 1,0, 1,2, 1,4, 2,0, 2,1, 2,2, 2,3, 2,4 };
43 const byte LETTER_4 [] = { 1,0, 1,1, 1,2, 2,2, 2,3, 2,4 };
44 const byte LETTER_5 [] = { 1,0, 1,1, 1,2, 1,4, 2,0, 2,2, 2,3, 2,4 };
45 const byte LETTER_6 [] = { 0,0, 0,1, 0,2, 0,3, 0,4, 1,0, 1,2, 1,4, 2,0, 2,2, 2,3, 2,4 };
46 const byte LETTER_7 [] = { 1,0, 2,0, 2,1, 2,2, 2,3, 2,4 };
47 const byte LETTER_8 [] = { 0,0, 0,1, 0,2, 0,3, 0,4, 1,0, 1,2, 1,4, 2,0, 2,1, 2,2, 2,3, 2,4 };
48 const byte LETTER_9 [] = { 0,0, 0,1, 0,2, 0,4, 1,0, 1,2, 1,4, 2,0, 2,1, 2,2, 2,3, 2,4 };
49 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
50  /////////////////////////////////////////////////////
51  // //
52  // MODIFY INITIAL SETTINGS IN initGame() //
53  // ( CAN'T HAVE THEM HERE TO NOT MESS UP GAME ) //
54  // ( OVER BEHAVIOUR OR DUPLICATE ) //
55  // ( THE CODE ) //
56  // //
57  /////////////////////////////////////////////////////
58 
60 int g_speed;
63 
65 bool g_player_pause_blink = false;
66 
68 byte g_entities[MAXX+1][MAXY+1];
69 byte g_player;
71 
72 long g_score;
73 
74 unsigned long g_time;
75 unsigned long g_loopTime;
76 unsigned long g_ticks;
77 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
78 
79 /////////////////////////
80 //Function definitions://
81 /////////////////////////
82 
83 
84 unsigned long getLoopTime();
85 unsigned long getStateTime();
86 void addTicks(unsigned long n);
87 void gotoState(int state);
88 void doRender();
89 void drawScore ( int score);
90 void lightPattern(const byte letter[], size_t letter_length, byte x, byte y, char color);
91 void drawChar(char c, byte x, byte y, char color);
92 void eepromScore();
93 void movePlayer(int i);
94 void controlSpeed();
95 void doHandleInput();
96 void doHitObstacle();
97 void doHitPowerup();
98 void doGenerateLine();
99 void moveEntity(byte x, byte y);
100 void doMove();
101 void initGame();
102 void doUpdate();
103 
104 static uint8_t cols[] = {
105  30,30,30,
106  128,128,128,
107  255,128,0,
108  128,128,255,
109 };
110 
111 
112 //////////////////////SETUP FUNCTION//////////////////////////////////////////////
113 
114 void setup() {
115 // AberLED.begin(AF_TFTDISPLAY, cols);
116  AberLED.begin();
117  AberLED.clear();
118 
119  int x=0;
120  for(int i=0;i<10;i++){
121  x+=analogRead(A4);
122  delay(40);
123  }
124 
125 
126 
127  Serial.begin(115200);
128  for(int i= MINX ; i <= MAXX ; i++){ //see if all LEDs are working properly
129  for(int j= MINY ; j <= MAXY ; j++){
130  AberLED.set (i ,j ,YELLOW) ;
131  }
132  }
133  AberLED.addToText(x);
134  AberLED.swap();
135  delay(1000);
136  AberLED.clear(); //clear the display after the test
137  gotoState(S_INIT);
138  initGame(); //initialise the game
139 }
140 
141 //////////////////////LOOP FUNCTION//////////////////////////////////////////////
142 
143 void loop() {
144  #ifdef DEBUG
145  Serial.println("Main loop stats:\n \t speed: " + String(g_speed) + " | player: " + g_player + " | state: " + g_state + " | state time: " + String(getStateTime()) + " | score: " + g_score);
146  #endif
147  doHandleInput(); // handles input, moves player/(un)pauses game
149  g_loopTime = millis();
150 
151  if (getStateTime() > g_speed){ //updates game timer and the board by moving everything to the left (if S_GAME)
153  doUpdate();
154  Serial.println(g_state);
155  }
156  doRender(); //draws everything and swaps the buffers
157 }
158 
159 //////////////////////TIMER/STATE FUNCTIONS//////////////////////////////////////////////
160 
161 unsigned long getLoopTime(){ //gets time between main loop occurences
162  return (millis() - g_loopTime);
163 }
164 
165 
166 
167 unsigned long getStateTime(){ //gets game time between ticks
168  return (millis() - g_time);
169 }
170 
171 void addTicks(unsigned long n){ //sets total time since start of the game (excluding pause state)
172  if (g_state == S_GAME){
173  g_ticks += n;
174  }
175 }
176 
177 void gotoState(int state){ //changes game state
178  g_state = state;
179  g_time = millis();
180 }
181 
182 //////////////////////INITGAME FUNCTION//////////////////////////////////////////////
183 
184 void initGame(){
185  g_player = 0;
186  g_speed = 250; //how often the game moves in ms
187  g_speed_modif = 50; //speed modifier in ms, just in case somebody would want to edit it
188  g_time = millis(); //last 'tick' time
189  g_score = 0; //reset the score
190  g_loopTime = millis(); //last player move 'tick' time
191  gotoState(S_START); //change state from invalid to "START"
192  g_std_speed = g_speed; //store initial speed (used in collisions/gameover)
193  g_player_pause_blink = false; //for blinking animation when the game is paused
194  g_ticks = 0; //resets the main timer
195  g_speedLevel = 0;
196  for (byte x = MINX; x <= MAXX; x++){ //zeroes the array containing entities
197  for (byte y = MINY; y <= MAXY; y++){
198  g_entities[x][y] = 0;
199  }
200  }
201  #ifdef DEBUG
202  Serial.println("--GAME INITIALISED--");
203  #endif
204 }
205 
206 
207 //////////////////////DOHANDLEINPUT FUNCTION//////////////////////////////////////////////
208 
209 void doHandleInput(){ //gets the button pressed and moves player/(un)pauses game accordingly
210  bool pressed = false;
211  byte addr = 0;
212  String temp_score;
213  switch (g_state){
214 
215  case S_PAUSE:
216  case S_GAME:
217  for (int i = 1; i <= 5; i++){
218  if (AberLED.getButtonDown(i)){
219  switch(i){
220  case BTN_UP :
221  movePlayer(-1);
222  pressed = true;
223  break;
224  case BTN_DOWN :
225  movePlayer(1);
226  pressed = true;
227  break;
228  case BTN_STOP :
229  if (g_state == S_PAUSE){
230  gotoState(S_GAME);
232  } else { //Game paused/resumed using BTN_STOP or resumed if any other button is pressed
233  gotoState(S_PAUSE); //and go back to old speed when I resume the game
235  g_speed = 600;
236  }
237  break;
238  default:
239  break;
240  }
241  }
242  }
243  if (pressed && g_state == S_PAUSE){
244  gotoState(S_GAME);
246  }
247  break;
248 
249  case S_GAMEOVER: //I made game save the score to EEPROM when BTN_RIGHT was pressed in GAMEOVER state (if debug was defined) to put a first
250  if (AberLED.getButtonDown(BTN_STOP)){ //value there and for testing purposes, before I implemented it to happen automatically
251  gotoState(S_INIT2);
252  Serial.println("TOTAL SCORE: " + String(g_score+1));
253  } else if (AberLED.getButtonDown(BTN_RIGHT)){
254  #ifdef DEBUG
255  addr = 0;
256  temp_score = String(g_score);
257  while (temp_score.length() < 4){
258  temp_score = '0' + temp_score;
259  }
260  for (int i = 0; i < temp_score.length(); i ++){
261  EEPROM.write(addr, (temp_score[i]));
262  Serial.println("--EEPROM WRITE: " + String(temp_score[i]) + " AT " + String(addr));
263  addr++;
264  }
265  #endif
266  }
267  break;
268 
269  case S_INIT2: //restarts the game and all its values when button 5 is pressed at the "top score" stage
271  gotoState(S_INIT);
272  initGame();
273  }
274  break;
275 
276  case S_START: //removes the welcome screen and proceeds to the game when button 5 is pressed
278  gotoState(S_GAME);
279  }
280  break;
281  default:
282  Serial.println("[001] WARNING! INVALID GAME STATE DETECTED: "+ String(g_state) + " !");
283  break;
284  }
285 }
286 
287 //////////////////////DOUPTDATE FUNCTION//////////////////////////////////////////////
288 
289 void doUpdate(){
290  switch (g_state){
291 
292  break;
293  case S_INIT:
294  initGame(); //shouldn't happen since void setup() initialises the game, but...
295  break;
296  case S_INIT2:
297  eepromScore();
298  break;
299  case S_PAUSE:
301  g_player_pause_blink = false;
302  } else {
303  g_player_pause_blink = true;
304  }
305  case S_GAMEOVER:
306  case S_START: //doRender() handles gameover and start screens since its just static image
307  break;
308  case S_GAME:
309  doMove();
310  doGenerateLine();
311  controlSpeed();
312  g_score ++;
313  break;
314  default:
315  Serial.println("[001] WARNING! INVALID GAME STATE DETECTED: "+ String(g_state) + " !");
316  break;
317  }
318 }
319 
320 //////////////////////RENDERING FUNCTION//////////////////////////////////////////////
321 
322 void doRender(){ //draws stuff
323  String highscore = "";
324  char character;
325  byte addr = 0;
326  String temp_score = "";
327  AberLED.clear();
328 
329  AberLED.clearText();
330  AberLED.addToText("State: ");
332 
333 /*
334  char foo[16];
335  sprintf(foo,"ST %d", g_state);
336  AberLED.writeText(foo);
337 */
338  switch (g_state){
339 
340 
341  case S_PAUSE : //S_PAUSE cascades to S_GAME so I don't have to repeat the code and can use if statement for differences
342  case S_GAME :
343 
344  for (byte x = MINX; x <= MAXX; x++){ //draw powerups/obstacles
345  for (byte y = MINY; y <= MAXY; y++){
346  if (g_entities[x][y] == ENT_POWERUP){
347  AberLED.set(x,y, YELLOW);
348  } else if ( g_entities[x][y] == ENT_OBSTACLE){
349  AberLED.set(x,y, RED);
350  }
351  }
352  }
353  if (g_state == S_PAUSE){
354  if (g_player_pause_blink){ //draw the player, make it blinking if the game's paused
355  AberLED.set(0, g_player, GREEN);
356  }
357  } else {
358  AberLED.set(0, g_player, GREEN);
359  }
360  break;
361 
362  case S_GAMEOVER : //drawScore if the game is over
364  break;
365 
366 
367  case S_INIT2 : //S_INIT2 is the state between S_GAMEOVER and S_START and shows the highscore from EEPROM
369  break;
370 
371 
372  case S_START : //Draws the smiley face as the start screen
373  lightPattern(LETTER_START, sizeof(LETTER_START) / sizeof(LETTER_START[0]), MINX, MINY, RED); //I explained how I learned to measure length of an array at the lightPattern() function itself
374  break;
375 
376  default:
377  Serial.println("[001] WARNING! INVALID GAME STATE DETECTED: "+ String(g_state) + " !");
378  break;
379  }
380  AberLED.swap();
381 }
382 
383 //////////////////////SPEED CHANGING OVBER TIME FUNCTION//////////////////////////////////////////////
384 
386  if (g_speedLevel < g_ticks / (SPEED_CHANGE_TIME * 1000)){ //we change speed every SPEED_CHANGE_TIME seconds
387  #ifdef DEBUG
388  Serial.println(".ControlSpeed(): speedlevel: " + String(g_speedLevel) + " | time / 20000: " + String(g_ticks / 20000) + " | speed: " + String(g_speed));
389  #endif
391  g_speed -= g_speed_modif / 2; //same value as powerup but makes it go faster
392  }
393 }
394 
395 
396 //////////////////////LINE GENERATING FUNCTION//////////////////////////////////////////////
397 
398 void doGenerateLine(){ //generates a new line with obstacles/powerups
399  byte chancePower = 25; //set chance for getting a powerup x/100
400  byte chanceAny = 10; //set chance for getting anything x/100
401  chanceAny += g_ticks / (OBSTACLE_CHANGE_TIME * 1000); //increases chance of getting anything by 1 every OBSTACLE_MODIFIER_TIME seconds (increasing chance of getting an obstacle at the same time)
402  for (int i = MINY; i <= MAXY; i++){
403  byte generator = random(100); //two random generators, one for an entity, second one for entity type (obstacle/powerup)
404  byte generator2 = random(100);
405  if (generator <= chanceAny){ //if we get anything
406  if (generator2 <= chancePower){ //check if it's a powerup
408  } else { //if not, place an obstacle
410  }
411  }
412  }
413 }
414 
415 //////////////////////MOVEPLAYER FUNCTION//////////////////////////////////////////////
416 
417 void movePlayer(int i){ //change coordinates depending on 'i' (which is how many units we go down/up)
418  bool pMoved = false;
419  if (i > 0 && g_player < MAXY ){ //moving up, considering upper border
420  g_player += i;
421  pMoved = true;
422  } else if ( i < 0 && g_player > MINY){ //moving down, considering bottom border
423  g_player += i;
424  pMoved = true;
425  }
426  if (pMoved){ //if we actually moved, check if there was also an obstacle/powerup (since we can move faster than obstacles/PUps)
428  doHitObstacle();
429  } else if (g_entities[MINX][g_player] == ENT_POWERUP){
430  doHitPowerup();
431  }
432  }
433 }
434 
435 //////////////////////DOMOVE FUNCTION//////////////////////////////////////////////
436 
437 
438 void doMove(){ //moves entities on the board (except player)
439  for (byte x = MINX; x <= MAXX; x++){
440  for (byte y = MINY; y <= MAXY; y++){
441  moveEntity(x, y);
442  }
443  }
444 }
445 
446 
447 //////////////////////MOVE ENTITY FUNCTION//////////////////////////////////////////////
448 
449 void moveEntity(byte x, byte y){ //moves an obstacle/PUp left each tick (this way of implementation allows us to add different kinds
450  byte ent_type = g_entities[x][y]; // of entities as we go. I used to have two separate functions for PUps and obstacles but merged them into this one)
451  switch (g_entities[x][y]){
452  case 0 : break; //if there's no ent at given coordinates, skip
453  case ENT_POWERUP:
454  case ENT_OBSTACLE:
455  if ( x == 0 ){
456 
457  } else if ( x == MINX+1 && g_player == y ){ //if there's an ent at the coordinates we're checking do the following
458  switch (ent_type){
459  case ENT_OBSTACLE:
460  doHitObstacle(); //if ent "bumps" on player, do the hitting function
461  break;
462  case ENT_POWERUP:
463  doHitPowerup();
464  break;
465  default:
466  break;
467  }
468  } else {
469  g_entities[x-1][y] = g_entities[x][y]; //if ent wasn't removed due to collision or going out of bounds, make a new ent on the left
470  }
471  g_entities[x][y] = 0; //remove old ent
472  break;
473  default:
474  Serial.println("[003] WARNING! WRONG ENT STATE AT (" + String(x) + " , " + String(y) + ") !");
475  break;
476  }
477 }
478 
479 //////////////////////HITTING/COLLISION FUNCTIONS//////////////////////////////////////////////
480 
481 void doHitObstacle(){ //hits obstacle, self-explanatory
482  if (g_speed > 0){ // can't go below 0
483  g_speed -= g_speed_modif; // by default -50
484  }
485  if (g_speed <= 0){ //if last reduction made us go to 0 or below 0, change game state to Game Over
487  g_speed = 0;
488  Serial.println("TOTAL SCORE: " + String(g_score+1));
489  }
490 }
491 
492 
493 
494 void doHitPowerup(){ //hits powerup
495  if (g_speed < g_std_speed) { //can't go higher than initial speed
496  g_speed += g_speed_modif / 2 ; //by default: 50 / 2 = 25
497  } else {
498  g_speed = g_std_speed; //in case g_speed isn't dividable by 25 (let's say 251 for some reason), just make it back to standard (default: 250)
499  }
500 }
501 
502 
503 //////////////////////DRAWING NUMBERS FUNCTIONS//////////////////////////////////////////////
504 
505 void drawScore ( int score){ //draws the score on the display. Since it's too small to show more than 2 numbers at once
506  byte place = 0; //without making them look very ugly, I decided to reduce available scores to 3 ranges, so:
507  char color; //red will show full score from 0 to 99,
508  String stringScore; //yellow will show first two characters of the score from 100 to 999 and
509  if (score >= 1000) { //green will show first two characters of the score from 1000 to 9999
510  color = GREEN;
511  stringScore = String(score / 100); //I was thinking of just making the score go slower and slower over time, but I don't think 99 numbers
512  } else if (score >= 100){ //are enough to represent any reasonable and easily comparable scores (since the difference between 98 and 99 would be
513  color = YELLOW; //MUCH higher than for example the difference between 40 and 60)
514  stringScore = String(score / 10);
515  } else if (score < 10){
516  color = RED;
517  stringScore = "0" + String(score / 10);
518  } else {
519  color = RED;
520  stringScore = String(score);
521  }
522 
523  for (byte i = MINX; i <= ((stringScore.length()+1) * 3); i += 4){ //draws the numbers neatly
524  drawChar(stringScore[place], i, MINY+1, color);
525  place++;
526  }
527 }
528 
529 
530 void lightPattern(const byte letter[], size_t letter_length, byte x, byte y, char color){ //http://stackoverflow.com/questions/37538/how-do-i-determine-the-size-of-my-array-in-c
531  for (int i = 0; i < letter_length; i += 2){ //that's where I learned how to measure length of an array (Mark Harrison's post, rated best answer)
532  AberLED.set(letter[i] + x, letter[i+1] + y, color); //code might not be the same and it was just the idea, but I thought I should leave it here
533  #ifdef DEBUG //I use for loop to light up different LEDs which coordinates I get from arrays at the top
534  Serial.println("#DRAWLETTER: (" + String(i) + ", " + String(i+1) + ")");
535  #endif */
536  }
537 }
538 
539 void drawChar(char c, byte x, byte y, char color){ //This function draws characters at given position (so I could put a number in the corner if
540  switch(c){ //I wanted to, but I have to remember that letters are made of 3x4 boxes and consider that
541  case '0': //if I were to put one after another)
542  lightPattern(LETTER_0, sizeof(LETTER_0) / sizeof(LETTER_0[0]), x, y, color);
543  break;
544  case '1':
545  lightPattern(LETTER_1, sizeof(LETTER_1) / sizeof(LETTER_1[0]), x, y, color);
546  break;
547  case '2':
548  lightPattern(LETTER_2, sizeof(LETTER_2) / sizeof(LETTER_2[0]), x, y, color);
549  break;
550  case '3':
551  lightPattern(LETTER_3, sizeof(LETTER_3) / sizeof(LETTER_3[0]), x, y, color);
552  break;
553  case '4':
554  lightPattern(LETTER_4, sizeof(LETTER_4) / sizeof(LETTER_4[0]), x, y, color);
555  break;
556  case '5':
557  lightPattern(LETTER_5, sizeof(LETTER_5) / sizeof(LETTER_5[0]), x, y, color);
558  break;
559  case '6':
560  lightPattern(LETTER_6, sizeof(LETTER_6) / sizeof(LETTER_6[0]), x, y, color);
561  break;
562  case '7':
563  lightPattern(LETTER_7, sizeof(LETTER_7) / sizeof(LETTER_7[0]), x, y, color);
564  break;
565  case '8':
566  lightPattern(LETTER_8, sizeof(LETTER_8) / sizeof(LETTER_8[0]), x, y, color);
567  break;
568  case '9':
569  lightPattern(LETTER_9, sizeof(LETTER_9) / sizeof(LETTER_9[0]), x, y, color);
570  break;
571  default:
572  break;
573  }
574 }
575 //////////////////////READING/WRITING HIGHSCORE FROM/TO EEPROM//////////////////////////////////////////////
576 
577 void eepromScore(){
578  String highscore = "";
579  char character;
580  byte addr = 0;
581  String temp_score = "";
582  for (int i = 0; i < 4; i ++){ //read characters representing score from EEPROM
583  character = EEPROM.read(addr);
584  highscore = highscore + String(character);
585  #ifdef DEBUG
586  Serial.println("--EEPROMREAD: " + String(character) + " AT " + String(addr));
587  #endif
588  addr++;
589  }
590  if (highscore.toInt() < g_score){ //check if new score is higher than the old highscore and if true, replace the value in EEPROM
591  addr = 0;
592  temp_score = String(g_score);
593  while (temp_score.length() < 4){ //Add 0s to the beginning of the score so it's always first 4 bytes from EEPROM, no matter how long the number is
594  temp_score = '0' + temp_score;
595  }
596  for (int i = 0; i < temp_score.length(); i ++){ //at first I treated score as a number and tried to make the loop divide it by 10 to put numbers in separate
597  EEPROM.write(addr, (temp_score[i])); //places, but then I realised it's easier to treat them as a string here
598  Serial.println("--EEPROM WRITE: " + String(temp_score[i]) + " AT " + String(addr));
599  addr++;
600  }
601  }
602  //#ifdef DEBUG
603  Serial.println(".EEPROMFUNC: highscore:" + String(highscore.toInt()) + " | g_score: " + String(g_score));
604  //#endif
605  g_score = highscore.toInt();
606 }
607 
608 
609 
610 
611 
612 
void clear()
Set all pixels in the back buffer to black.
Definition: AberLED.cpp:356
int g_speed
Definition: main.cpp:60
unsigned long g_loopTime
Definition: main.cpp:75
void drawChar(char c, byte x, byte y, char color)
Definition: main.cpp:539
void doMove()
Definition: main.cpp:438
#define S_GAMEOVER
Definition: main.cpp:13
#define S_INIT
Definition: main.cpp:8
int g_speed_modif
Definition: main.cpp:59
#define BTN_RIGHT
Definition: main.cpp:20
void begin(AberLEDFlags flags=AF_TFTDISPLAY, uint8_t *colourMap=NULL)
Initialises all pin modes, clears the buffers, starts the interrupt and begins to output data to the ...
Definition: AberLED.cpp:158
void drawScore(int score)
Definition: main.cpp:505
unsigned long getLoopTime()
Definition: main.cpp:161
void loop()
Definition: main.cpp:143
#define BTN_STOP
Definition: main.cpp:21
const byte LETTER_6[]
Definition: main.cpp:45
const byte LETTER_3[]
Definition: main.cpp:42
const int OBSTACLE_CHANGE_TIME
Definition: main.cpp:36
int getButtonDown(unsigned char c)
Return nonzero if the button has been pressed since the last swap(). It&#39;s better to use the UP...
Definition: AberLED.cpp:326
byte g_player
Definition: main.cpp:69
#define S_START
Definition: main.cpp:10
bool g_inclevel
Definition: main.cpp:64
#define S_GAME
Definition: main.cpp:11
byte g_std_speed
Definition: main.cpp:70
void movePlayer(int i)
Definition: main.cpp:417
#define S_INVALID
Definition: main.cpp:7
void setup()
Definition: main.cpp:114
AberLEDClass AberLED
this is the single instance of the LED class - for documentation see AberLEDClass.
Definition: AberLED.cpp:76
#define ENT_OBSTACLE
Definition: main.cpp:24
void clearText()
clear the string which is written to the text area on a TFT display.
Definition: AberLED.cpp:291
void doHandleInput()
Definition: main.cpp:209
long g_score
Definition: main.cpp:72
int g_speedLevel
Definition: main.cpp:61
const byte LETTER_1[]
Definition: main.cpp:40
void controlSpeed()
Definition: main.cpp:385
const byte LETTER_2[]
Definition: main.cpp:41
#define S_INIT2
Definition: main.cpp:9
The declaration for the AberLED class. Many implementation details are inside the AberLED implementat...
const byte LETTER_0[]
Definition: main.cpp:39
#define ENT_POWERUP
Definition: main.cpp:25
void addTicks(unsigned long n)
Definition: main.cpp:171
unsigned long g_ticks
Definition: main.cpp:76
unsigned long g_time
Definition: main.cpp:74
const int SPEED_CHANGE_TIME
Definition: main.cpp:35
#define S_PAUSE
Definition: main.cpp:12
const byte LETTER_4[]
Definition: main.cpp:43
int g_prePauseSpeed
Definition: main.cpp:62
byte g_entities[MAXX+1][MAXY+1]
Definition: main.cpp:68
unsigned long getStateTime()
Definition: main.cpp:167
const byte MAXY
Definition: main.cpp:34
void eepromScore()
Definition: main.cpp:577
void doHitObstacle()
Definition: main.cpp:481
#define GREEN
the green colour for pixels, used in set()
Definition: AberLED.h:23
byte g_state
Definition: main.cpp:67
#define YELLOW
the yellow colour for pixels, used in set()
Definition: AberLED.h:27
const byte LETTER_8[]
Definition: main.cpp:47
#define RED
the red colour for pixels, used in set()
Definition: AberLED.h:25
const byte MAXX
Definition: main.cpp:33
const byte LETTER_9[]
Definition: main.cpp:48
void initGame()
Definition: main.cpp:184
void moveEntity(byte x, byte y)
Definition: main.cpp:449
#define BTN_UP
Definition: main.cpp:17
void addToText(const char *s)
Append a string to the text area on a TFT display. Does nothing if the display is not a TFT display...
Definition: AberLED.cpp:300
const byte LETTER_START[]
Definition: main.cpp:38
void swap()
Call this code to finish drawing operations. It swaps the back and front buffer, so that the newly wr...
Definition: AberLED.cpp:259
const byte LETTER_5[]
Definition: main.cpp:44
const byte LETTER_7[]
Definition: main.cpp:46
void gotoState(int state)
Definition: main.cpp:177
void doUpdate()
Definition: main.cpp:289
void doGenerateLine()
Definition: main.cpp:398
#define BTN_DOWN
Definition: main.cpp:18
void lightPattern(const byte letter[], size_t letter_length, byte x, byte y, char color)
Definition: main.cpp:530
void doRender()
Definition: main.cpp:322
void set(int x, int y, unsigned char col)
This sets the given pixel in the back buffer to the given value. The pixel values are 0 (off)...
Definition: AberLED.cpp:341
bool g_player_pause_blink
Definition: main.cpp:65
const byte MINY
Definition: main.cpp:32
void doHitPowerup()
Definition: main.cpp:494
const byte MINX
Definition: main.cpp:31