Spring 2014, ECE 4180 project, Georgia Institute of Technolgoy. This is the autonomous driver program for the Robotics Cat and Mouse program.
Dependencies: IMUfilter ADXL345_I2C mbed ITG3200 USBHost mbed-rtos
GameCode.h@3:0a6e4d139b86, 2014-04-30 (annotated)
- Committer:
- Strikewolf
- Date:
- Wed Apr 30 12:25:47 2014 +0000
- Revision:
- 3:0a6e4d139b86
- Parent:
- 1:dacf7db790f6
Final product before demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Strikewolf | 1:dacf7db790f6 | 1 | #define THRESHOLD 100 |
Strikewolf | 1:dacf7db790f6 | 2 | |
Strikewolf | 1:dacf7db790f6 | 3 | Serial pc(USBTX, USBRX); |
Strikewolf | 1:dacf7db790f6 | 4 | |
Strikewolf | 3:0a6e4d139b86 | 5 | void stop(); |
Strikewolf | 3:0a6e4d139b86 | 6 | |
Strikewolf | 1:dacf7db790f6 | 7 | bool gameOver = false; |
Strikewolf | 1:dacf7db790f6 | 8 | |
Strikewolf | 1:dacf7db790f6 | 9 | bool isGameOver(short x_hum, short y_hum, short x_cpu, short y_cpu) |
Strikewolf | 1:dacf7db790f6 | 10 | { |
Strikewolf | 1:dacf7db790f6 | 11 | if(abs(x_hum - x_cpu) < THRESHOLD && abs(y_hum - y_cpu) < THRESHOLD) { |
Strikewolf | 1:dacf7db790f6 | 12 | return true; |
Strikewolf | 1:dacf7db790f6 | 13 | } else { |
Strikewolf | 1:dacf7db790f6 | 14 | return false; |
Strikewolf | 1:dacf7db790f6 | 15 | } |
Strikewolf | 1:dacf7db790f6 | 16 | } |
Strikewolf | 1:dacf7db790f6 | 17 | |
Strikewolf | 1:dacf7db790f6 | 18 | void endGame() |
Strikewolf | 1:dacf7db790f6 | 19 | { |
Strikewolf | 1:dacf7db790f6 | 20 | pc.printf("GAME OVER\n\r"); |
Strikewolf | 3:0a6e4d139b86 | 21 | stop(); |
Strikewolf | 1:dacf7db790f6 | 22 | exit(1); |
Strikewolf | 1:dacf7db790f6 | 23 | } |