Last active
December 19, 2015 12:39
-
-
Save Orpheon/5956802 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
| bool collides_with_wallmask(Character *character, Bitmask *map) | |
| { | |
| bool collided = false; | |
| for (int w=0; w<character->width; w++) | |
| { | |
| for (int h=0; h<character->height; h++) | |
| { | |
| printf("\nRound:\n%i, %i", (int)character->x + w, (int)character->y - h); | |
| printf("\n%i, %i", w, h); | |
| printf("\n%i, %i\n", map->width, map->height); | |
| fflush(stdout); | |
| // Check for every pixel in character, is there wallmask there? | |
| if (map->mask[(int)character->x + w][(int)character->y - h]) | |
| { | |
| collided = true; | |
| break; | |
| } | |
| } | |
| if (collided) | |
| { | |
| break; | |
| } | |
| } | |
| return collided; | |
| } | |
| ------------------ | |
| Output: | |
| ------------------ | |
| Round: | |
| 1589, 227 | |
| 0, 0 | |
| 4146, 1200 | |
| Round: | |
| 1590, 227 | |
| 1, 0 | |
| 4146, 1200 | |
| Round: | |
| 0, 0 | |
| 0, 0 | |
| 0, 1083757568 | |
| 9056 Segmentation fault (core dumped) ./bin/executable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment