mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
add IsOnCharacter helper function
This commit is contained in:
parent
40cdf33bb8
commit
2e1a7e73fd
2 changed files with 9 additions and 0 deletions
|
@ -231,3 +231,10 @@ SYMBOL_EXPORT int GetCharacterY(struct Game *game, struct Character *character)
|
||||||
SYMBOL_EXPORT float GetCharacterAngle(struct Game *game, struct Character *character) {
|
SYMBOL_EXPORT float GetCharacterAngle(struct Game *game, struct Character *character) {
|
||||||
return character->angle;
|
return character->angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SYMBOL_EXPORT bool IsOnCharacter(struct Game *game, struct Character *character, int x, int y) {
|
||||||
|
int x1 = GetCharacterX(game, character), y1 = GetCharacterY(game, character);
|
||||||
|
int x2 = x1 + al_get_bitmap_width(character->bitmap), y2 = y1 + al_get_bitmap_height(character->bitmap);
|
||||||
|
|
||||||
|
return ((x >= x1) && (x <= x2) && (y >= y1) && (y <= y2));
|
||||||
|
}
|
||||||
|
|
|
@ -82,4 +82,6 @@ int GetCharacterX(struct Game *game, struct Character *character);
|
||||||
int GetCharacterY(struct Game *game, struct Character *character);
|
int GetCharacterY(struct Game *game, struct Character *character);
|
||||||
float GetCharacterAngle(struct Game *game, struct Character *character);
|
float GetCharacterAngle(struct Game *game, struct Character *character);
|
||||||
|
|
||||||
|
bool IsOnCharacter(struct Game *game, struct Character *character, int x, int y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue