forked from ricklon/tiltspirit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtiltspirit.ino
79 lines (66 loc) · 1.88 KB
/
tiltspirit.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//************************************************************************
//*
//* I made a small tilt game for Arduiuno called "TIlt Spirit"
//*
//* It uses an Teensy or Arduino Leonardo with a 3 pin tilt sensor that
//* triggers at 45 degrees, and displays the game on an standard 2x16 LCD screen.
//*
//************************************************************************
//* Edit History
//************************************************************************
//* Nov 1, 2012 <ROA> Wrote Tilt Spirit game
//* Nov 2, 2012 <MLS> Code review
//************************************************************************
#include <LiquidCrystal.h>
#include "Hardware.h"
#include "Game.h"
//************************************************************************
void setup()
{
pinMode(TILT_PINA, INPUT_PULLUP);
pinMode(TILT_PINB, INPUT_PULLUP);
tiltAState = digitalRead(TILT_PINA);
tiltBState = digitalRead(TILT_PINB);
//Enable the LCD layout information
lcd.begin(WIDTH, HEIGHT);
lcd.createChar(0, squiGhost1L);
lcd.createChar(1, squiGhost1R);
lcd.createChar(2, squiGhost2L);
lcd.createChar(3, squiGhost2R);
lcd.createChar(4, squiGhost3L);
lcd.createChar(5, squiGhost3R);
}
//************************************************************************
//* The game status loop
//************************************************************************
//Note: shake to start
void loop()
{
switch (gameState)
{
case GAME_TITLE:
gameState = gameTitle();
break;
case GAME_INTRO:
gameState = gameIntro();
break;
case GAME_INSTR:
gameState = gameInstr();
break;
case GAME_START:
gameState = gameStart();
break;
case GAME_PLAY:
gameState = gamePlay();
break;
case GAME_DEATH:
gameState = gameDeath();
break;
case GAME_WIN:
gameState = gameWin();
break;
case GAME_RESTART:
gameState = gameRestart();
break;
}
}