add DrawScaledCharacter(F)

This commit is contained in:
Sebastian Krzyszkowiak 2016-12-06 02:54:31 +01:00
parent bd57582b01
commit ca2f26e9ff
2 changed files with 16 additions and 6 deletions

View file

@ -206,18 +206,26 @@ SYMBOL_EXPORT void SetCharacterPosition(struct Game *game, struct Character *cha
} }
SYMBOL_EXPORT void DrawCharacterF(struct Game *game, struct Character *character, ALLEGRO_COLOR tint, int flags) { SYMBOL_EXPORT void DrawScaledCharacterF(struct Game *game, struct Character *character, ALLEGRO_COLOR tint, float scalex, float scaley, int flags) {
if (character->dead) return; if (character->dead) return;
int spritesheetX = al_get_bitmap_width(character->bitmap)*(character->pos%character->spritesheet->cols); int spritesheetX = al_get_bitmap_width(character->bitmap)*(character->pos%character->spritesheet->cols);
int spritesheetY = al_get_bitmap_height(character->bitmap)*(character->pos/character->spritesheet->cols); int spritesheetY = al_get_bitmap_height(character->bitmap)*(character->pos/character->spritesheet->cols);
al_draw_tinted_scaled_rotated_bitmap_region(character->spritesheet->bitmap, spritesheetX, spritesheetY, al_get_bitmap_width(character->bitmap), al_get_bitmap_height(character->bitmap), tint, al_get_bitmap_width(character->bitmap)/2, al_get_bitmap_height(character->bitmap)/2, character->x*game->viewport.width + al_get_bitmap_width(character->bitmap)/2, character->y*game->viewport.height + al_get_bitmap_height(character->bitmap)/2, 1, 1, character->angle, flags); al_draw_tinted_scaled_rotated_bitmap_region(character->spritesheet->bitmap, spritesheetX, spritesheetY, al_get_bitmap_width(character->bitmap), al_get_bitmap_height(character->bitmap), tint, al_get_bitmap_width(character->bitmap)/2, al_get_bitmap_height(character->bitmap)/2, character->x*game->viewport.width + al_get_bitmap_width(character->bitmap)*scalex/2, character->y*game->viewport.height + al_get_bitmap_height(character->bitmap)*scaley/2, scalex, scaley, character->angle, flags);
}
SYMBOL_EXPORT void DrawCharacterF(struct Game *game, struct Character *character, ALLEGRO_COLOR tint, int flags) {
DrawScaledCharacterF(game, character, tint, 1, 1, flags);
}
SYMBOL_EXPORT void DrawScaledCharacter(struct Game *game, struct Character *character, ALLEGRO_COLOR tint, float scalex, float scaley, int flags) {
if (character->dead) return;
int spritesheetX = al_get_bitmap_width(character->bitmap)*(character->pos%character->spritesheet->cols);
int spritesheetY = al_get_bitmap_height(character->bitmap)*(character->pos/character->spritesheet->cols);
al_draw_tinted_scaled_rotated_bitmap_region(character->spritesheet->bitmap, spritesheetX, spritesheetY, al_get_bitmap_width(character->bitmap), al_get_bitmap_height(character->bitmap), tint, al_get_bitmap_width(character->bitmap)/2, al_get_bitmap_height(character->bitmap)/2, (int)(character->x*game->viewport.width + al_get_bitmap_width(character->bitmap)*scalex/2), (int)(character->y*game->viewport.height + al_get_bitmap_height(character->bitmap)*scaley/2), scalex, scaley, character->angle, flags);
} }
SYMBOL_EXPORT void DrawCharacter(struct Game *game, struct Character *character, ALLEGRO_COLOR tint, int flags) { SYMBOL_EXPORT void DrawCharacter(struct Game *game, struct Character *character, ALLEGRO_COLOR tint, int flags) {
if (character->dead) return; DrawScaledCharacter(game, character, tint, 1, 1, flags);
int spritesheetX = al_get_bitmap_width(character->bitmap)*(character->pos%character->spritesheet->cols);
int spritesheetY = al_get_bitmap_height(character->bitmap)*(character->pos/character->spritesheet->cols);
al_draw_tinted_scaled_rotated_bitmap_region(character->spritesheet->bitmap, spritesheetX, spritesheetY, al_get_bitmap_width(character->bitmap), al_get_bitmap_height(character->bitmap), tint, al_get_bitmap_width(character->bitmap)/2, al_get_bitmap_height(character->bitmap)/2, (int)(character->x*game->viewport.width + al_get_bitmap_width(character->bitmap)/2), (int)(character->y*game->viewport.height + al_get_bitmap_height(character->bitmap)/2), 1, 1, character->angle, flags);
} }
SYMBOL_EXPORT int GetCharacterX(struct Game *game, struct Character *character) { SYMBOL_EXPORT int GetCharacterX(struct Game *game, struct Character *character) {

View file

@ -65,6 +65,8 @@ void RegisterSpritesheet(struct Game *game, struct Character *character, char* n
void DrawCharacterF(struct Game *game, struct Character *character, ALLEGRO_COLOR tilt, int flags); void DrawCharacterF(struct Game *game, struct Character *character, ALLEGRO_COLOR tilt, int flags);
void DrawCharacter(struct Game *game, struct Character *character, ALLEGRO_COLOR tilt, int flags); void DrawCharacter(struct Game *game, struct Character *character, ALLEGRO_COLOR tilt, int flags);
void DrawScaledCharacterF(struct Game *game, struct Character *character, ALLEGRO_COLOR tilt, float scalex, float scaley, int flags);
void DrawScaledCharacter(struct Game *game, struct Character *character, ALLEGRO_COLOR tilt, float scalex, float scaley, int flags);
struct Character* CreateCharacter(struct Game *game, char* name); struct Character* CreateCharacter(struct Game *game, char* name);
void DestroyCharacter(struct Game *game, struct Character *character); void DestroyCharacter(struct Game *game, struct Character *character);