Created
April 20, 2015 21:53
-
-
Save triplefox/47d620fc556e3f7da9bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int collide(int data[25], int collision_mapping[3]) { | |
int collision = 0; | |
int i0 = 0; | |
for (i0 = 0; i0 < 25; i0++ ) | |
{ | |
collision += collision_mapping[data[i0]]; | |
} | |
return collision != 0; | |
} | |
int main() | |
{ | |
int collision_mapping[3] = {0,0,1}; /* only collide against data value 2 */ | |
int data0[25] = { | |
0, 1, 1, 1, 0, | |
1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1, | |
0, 1, 1, 1, 0 | |
}; | |
int data1[25] = { | |
0, 2, 2, 2, 0, | |
2, 2, 2, 2, 2, | |
2, 2, 2, 2, 2, | |
2, 2, 2, 2, 2, | |
0, 2, 2, 2, 0 | |
}; | |
int data2[25] = { | |
0, 1, 1, 1, 0, | |
1, 1, 1, 1, 1, | |
1, 1, 2, 1, 1, | |
1, 1, 1, 1, 1, | |
0, 1, 1, 1, 0 | |
}; | |
int collision; | |
printf("%i\n", collide(data0, collision_mapping)); | |
printf("%i\n", collide(data1, collision_mapping)); | |
printf("%i\n", collide(data2, collision_mapping)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment