Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SnakeEngine.cpp@26:a596dce2f938, 2020-04-05 (annotated)
- Committer:
- JoeShotton
- Date:
- Sun Apr 05 21:15:07 2020 +0000
- Revision:
- 26:a596dce2f938
collision detection implemented and added to SnakeEngine source and header files
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| JoeShotton | 26:a596dce2f938 | 1 | |
| JoeShotton | 26:a596dce2f938 | 2 | bool collision(int state, int x, int y,) { |
| JoeShotton | 26:a596dce2f938 | 3 | if ((lcd.getPixel(x, y) == 1 && ((state == 1) || (state == 4))) || (lcd.getPixel(x+1, y+1) == 1 && ((state == 2) || (state == 3)))) { |
| JoeShotton | 26:a596dce2f938 | 4 | // checks infront of head to see if pixel is set |
| JoeShotton | 26:a596dce2f938 | 5 | // due to the size of the head, there is an offset for the check for North and Eastward directions |
| JoeShotton | 26:a596dce2f938 | 6 | pad.led(1,0.9); |
| JoeShotton | 26:a596dce2f938 | 7 | return true; |
| JoeShotton | 26:a596dce2f938 | 8 | } else { |
| JoeShotton | 26:a596dce2f938 | 9 | pad.led(1,0.0); |
| JoeShotton | 26:a596dce2f938 | 10 | return = false; |
| JoeShotton | 26:a596dce2f938 | 11 | } |
| JoeShotton | 26:a596dce2f938 | 12 | } |