AberLED shield library
Library for the bicolor LED (and TFT screen) shield used in CS12020
Macros | Functions | Variables
main.cpp File Reference
#include "AberLED.h"
#include <EEPROM.h>

Go to the source code of this file.

Macros

#define S_INVALID   -1
 
#define S_INIT   0
 
#define S_INIT2   1
 
#define S_START   2
 
#define S_GAME   3
 
#define S_PAUSE   4
 
#define S_GAMEOVER   13
 
#define BTN_UP   1
 
#define BTN_DOWN   2
 
#define BTN_LEFT   4
 
#define BTN_RIGHT   3
 
#define BTN_STOP   5
 
#define ENT_OBSTACLE   1
 
#define ENT_POWERUP   2
 

Functions

unsigned long getLoopTime ()
 
unsigned long getStateTime ()
 
void addTicks (unsigned long n)
 
void gotoState (int state)
 
void doRender ()
 
void drawScore (int score)
 
void lightPattern (const byte letter[], size_t letter_length, byte x, byte y, char color)
 
void drawChar (char c, byte x, byte y, char color)
 
void eepromScore ()
 
void movePlayer (int i)
 
void controlSpeed ()
 
void doHandleInput ()
 
void doHitObstacle ()
 
void doHitPowerup ()
 
void doGenerateLine ()
 
void moveEntity (byte x, byte y)
 
void doMove ()
 
void initGame ()
 
void doUpdate ()
 
void setup ()
 
void loop ()
 

Variables

const byte MINX = 0
 
const byte MINY = 0
 
const byte MAXX = 7
 
const byte MAXY = 7
 
const int SPEED_CHANGE_TIME = 5
 
const int OBSTACLE_CHANGE_TIME = 5
 
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 }
 
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 }
 
const byte LETTER_1 [] = { 1,0, 1,1, 1,2, 1,3, 1,4 }
 
const byte LETTER_2 [] = { 1,0, 1,2, 1,3, 1,4, 2,0, 2,1, 2,2, 2,4 }
 
const byte LETTER_3 [] = { 1,0, 1,2, 1,4, 2,0, 2,1, 2,2, 2,3, 2,4 }
 
const byte LETTER_4 [] = { 1,0, 1,1, 1,2, 2,2, 2,3, 2,4 }
 
const byte LETTER_5 [] = { 1,0, 1,1, 1,2, 1,4, 2,0, 2,2, 2,3, 2,4 }
 
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 }
 
const byte LETTER_7 [] = { 1,0, 2,0, 2,1, 2,2, 2,3, 2,4 }
 
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 }
 
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 }
 
int g_speed_modif
 
int g_speed
 
int g_speedLevel
 
int g_prePauseSpeed
 
bool g_inclevel
 
bool g_player_pause_blink = false
 
byte g_state = S_INVALID
 
byte g_entities [MAXX+1][MAXY+1]
 
byte g_player
 
byte g_std_speed
 
long g_score
 
unsigned long g_time
 
unsigned long g_loopTime
 
unsigned long g_ticks
 

Macro Definition Documentation

#define BTN_DOWN   2

Definition at line 18 of file main.cpp.

#define BTN_LEFT   4

Definition at line 19 of file main.cpp.

#define BTN_RIGHT   3

Definition at line 20 of file main.cpp.

#define BTN_STOP   5

Definition at line 21 of file main.cpp.

#define BTN_UP   1

Definition at line 17 of file main.cpp.

#define ENT_OBSTACLE   1

Definition at line 24 of file main.cpp.

#define ENT_POWERUP   2

Definition at line 25 of file main.cpp.

#define S_GAME   3

Definition at line 11 of file main.cpp.

#define S_GAMEOVER   13

Definition at line 13 of file main.cpp.

#define S_INIT   0

Definition at line 8 of file main.cpp.

#define S_INIT2   1

Definition at line 9 of file main.cpp.

#define S_INVALID   -1

Definition at line 7 of file main.cpp.

#define S_PAUSE   4

Definition at line 12 of file main.cpp.

#define S_START   2

Definition at line 10 of file main.cpp.

Function Documentation

void addTicks ( unsigned long  n)

Definition at line 160 of file main.cpp.

void controlSpeed ( )

Definition at line 370 of file main.cpp.

void doGenerateLine ( )

Definition at line 383 of file main.cpp.

void doHandleInput ( )

Definition at line 198 of file main.cpp.

void doHitObstacle ( )

Definition at line 466 of file main.cpp.

void doHitPowerup ( )

Definition at line 479 of file main.cpp.

void doMove ( )

Definition at line 423 of file main.cpp.

void doRender ( )

Definition at line 311 of file main.cpp.

void doUpdate ( )

Definition at line 278 of file main.cpp.

void drawChar ( char  c,
byte  x,
byte  y,
char  color 
)

Definition at line 524 of file main.cpp.

void drawScore ( int  score)

Definition at line 490 of file main.cpp.

void eepromScore ( )

Definition at line 562 of file main.cpp.

unsigned long getLoopTime ( )

Definition at line 150 of file main.cpp.

unsigned long getStateTime ( )

Definition at line 156 of file main.cpp.

void gotoState ( int  state)

Definition at line 166 of file main.cpp.

void initGame ( )

Definition at line 173 of file main.cpp.

void lightPattern ( const byte  letter[],
size_t  letter_length,
byte  x,
byte  y,
char  color 
)

Definition at line 515 of file main.cpp.

void loop ( )

Definition at line 133 of file main.cpp.

void moveEntity ( byte  x,
byte  y 
)

Definition at line 434 of file main.cpp.

void movePlayer ( int  i)

Definition at line 402 of file main.cpp.

void setup ( )

Definition at line 114 of file main.cpp.

Variable Documentation

byte g_entities[MAXX+1][MAXY+1]

Definition at line 68 of file main.cpp.

bool g_inclevel

Definition at line 64 of file main.cpp.

unsigned long g_loopTime

Definition at line 75 of file main.cpp.

byte g_player

Definition at line 69 of file main.cpp.

bool g_player_pause_blink = false

Definition at line 65 of file main.cpp.

int g_prePauseSpeed

Definition at line 62 of file main.cpp.

long g_score

Definition at line 72 of file main.cpp.

int g_speed

Definition at line 60 of file main.cpp.

int g_speed_modif

Definition at line 59 of file main.cpp.

int g_speedLevel

Definition at line 61 of file main.cpp.

byte g_state = S_INVALID

Definition at line 67 of file main.cpp.

byte g_std_speed

Definition at line 70 of file main.cpp.

unsigned long g_ticks

Definition at line 76 of file main.cpp.

unsigned long g_time

Definition at line 74 of file main.cpp.

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 }

Definition at line 39 of file main.cpp.

const byte LETTER_1[] = { 1,0, 1,1, 1,2, 1,3, 1,4 }

Definition at line 40 of file main.cpp.

const byte LETTER_2[] = { 1,0, 1,2, 1,3, 1,4, 2,0, 2,1, 2,2, 2,4 }

Definition at line 41 of file main.cpp.

const byte LETTER_3[] = { 1,0, 1,2, 1,4, 2,0, 2,1, 2,2, 2,3, 2,4 }

Definition at line 42 of file main.cpp.

const byte LETTER_4[] = { 1,0, 1,1, 1,2, 2,2, 2,3, 2,4 }

Definition at line 43 of file main.cpp.

const byte LETTER_5[] = { 1,0, 1,1, 1,2, 1,4, 2,0, 2,2, 2,3, 2,4 }

Definition at line 44 of file main.cpp.

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 }

Definition at line 45 of file main.cpp.

const byte LETTER_7[] = { 1,0, 2,0, 2,1, 2,2, 2,3, 2,4 }

Definition at line 46 of file main.cpp.

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 }

Definition at line 47 of file main.cpp.

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 }

Definition at line 48 of file main.cpp.

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 }

Definition at line 38 of file main.cpp.

const byte MAXX = 7

Definition at line 33 of file main.cpp.

const byte MAXY = 7

Definition at line 34 of file main.cpp.

const byte MINX = 0

Definition at line 31 of file main.cpp.

const byte MINY = 0

Definition at line 32 of file main.cpp.

const int OBSTACLE_CHANGE_TIME = 5

Definition at line 36 of file main.cpp.

const int SPEED_CHANGE_TIME = 5

Definition at line 35 of file main.cpp.