feat: added animation events to animation_sprite
This commit is contained in:
parent
a63cfdd2b0
commit
f67f95fd6a
5 changed files with 102 additions and 63 deletions
|
|
@ -75,9 +75,9 @@ Enemy* MakeEnemy() {
|
|||
sprite_set_origin(self->sprite, MakeVector(0.45f, 0.925f));
|
||||
|
||||
// load and configure animations
|
||||
self->idleAnim = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Idle.png", IVectorFrom(512)), 1.5f, LoopMode_Loop);
|
||||
self->walkAnim = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Walk.png", IVectorFrom(512)), 1.5f, LoopMode_Loop);
|
||||
self->hurtAnim = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Hurt.png", IVectorFrom(512)), 5.f, LoopMode_Stop);
|
||||
self->idleAnim = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Idle.png", IVectorFrom(512)), 1.5f, LoopMode_Loop, NULL, 0);
|
||||
self->walkAnim = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Walk.png", IVectorFrom(512)), 1.5f, LoopMode_Loop, NULL, 0);
|
||||
self->hurtAnim = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Hurt.png", IVectorFrom(512)), 5.f, LoopMode_Stop, NULL, 0);
|
||||
self->behaviour = state_machine_init(self, EnemyIdle());
|
||||
|
||||
return self;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ Player* MakePlayer() {
|
|||
.slide = NULL,
|
||||
|
||||
.animationStateMachine = NULL,
|
||||
.boxes = malloc(sizeof(Hurtbox) * 3),
|
||||
|
||||
.pushInputTimer = 0.f,
|
||||
.inputLog = list_from_type(PlayerInputFrame),
|
||||
|
|
@ -117,15 +118,15 @@ Player* MakePlayer() {
|
|||
sprite_set_origin(self->sprite, MakeVector(0.45f, 0.925f));
|
||||
|
||||
// load and configure animations
|
||||
self->idle = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Idle.png", IVectorFrom(512)), 1.5f, LoopMode_Loop);
|
||||
self->walk = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Walk.png", IVectorFrom(512)), 5.f, LoopMode_Loop);
|
||||
self->jump = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Jumping.png", IVectorFrom(512)), 1.f, LoopMode_Stop);
|
||||
self->jab_a = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Jab_A.png", IVectorFrom(512)), 10.f, LoopMode_Stop);
|
||||
self->jab_b = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Jab_B.png", IVectorFrom(512)), 10.f, LoopMode_Stop);
|
||||
self->kick_a = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Kick_A.png", IVectorFrom(512)), 12.f, LoopMode_Stop);
|
||||
self->slash = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Slash.png", IVectorFrom(512)), 12.f, LoopMode_Stop);
|
||||
self->air_heavy = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Air_Heavy.png", IVectorFrom(512)), 10.f, LoopMode_Stop);
|
||||
self->slide = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Slide.png", IVectorFrom(512)), 1.f, LoopMode_Loop);
|
||||
self->idle = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Idle.png", IVectorFrom(512)), 1.5f, LoopMode_Loop, NULL, 0);
|
||||
self->walk = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Walk.png", IVectorFrom(512)), 5.f, LoopMode_Loop, NULL, 0);
|
||||
self->jump = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Jumping.png", IVectorFrom(512)), 1.f, LoopMode_Stop, NULL, 0);
|
||||
self->jab_a = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Jab_A.png", IVectorFrom(512)), 10.f, LoopMode_Stop, NULL, 0);
|
||||
self->jab_b = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Jab_B.png", IVectorFrom(512)), 10.f, LoopMode_Stop, NULL, 0);
|
||||
self->kick_a = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Kick_A.png", IVectorFrom(512)), 12.f, LoopMode_Stop, NULL, 0);
|
||||
self->slash = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Slash.png", IVectorFrom(512)), 12.f, LoopMode_Stop, NULL, 0);
|
||||
self->air_heavy = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Air_Heavy.png", IVectorFrom(512)), 10.f, LoopMode_Stop, NULL, 0);
|
||||
self->slide = animation_sprite_new(self->sprite, spritesheet_load("assets/Player_Slide.png", IVectorFrom(512)), 1.f, LoopMode_Loop, NULL, 0);
|
||||
|
||||
self->animationStateMachine = state_machine_init(self, PlayerIdle());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef FIGHT_PLAYER_H
|
||||
#define FIGHT_PLAYER_H
|
||||
|
||||
#include "Hurtbox.h"
|
||||
#include "dictionary.h"
|
||||
#include "state_machine.h"
|
||||
#include "mirror.h"
|
||||
|
|
@ -56,9 +57,9 @@ typedef struct Player {
|
|||
AnimationSprite* slide;
|
||||
|
||||
StateMachine* animationStateMachine;
|
||||
Hurtbox *boxes;
|
||||
|
||||
AnimationSprite* currentAnimation;
|
||||
|
||||
float pushInputTimer;
|
||||
List inputLog;
|
||||
PlayerInputFrame nextInputFrame;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue