Joe Shotton / ll16j23s_test_docs
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?

UserRevisionLine numberNew 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 }