feat(template): removed files not directly needed for the template
This commit is contained in:
parent
2b7af06d00
commit
37ec5a7558
Binary file not shown.
Before Width: | Height: | Size: 2.2 MiB |
|
@ -1,12 +1,7 @@
|
||||||
#include "camera.h"
|
|
||||||
#include "program.h"
|
#include "program.h"
|
||||||
#include "player.h"
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void play() {
|
void play() {}
|
||||||
g_camera.fov = 5;
|
|
||||||
SpawnPlayer(ZeroVector);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void tick() {}
|
void tick() {}
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
#include "player.h"
|
|
||||||
#include "debug.h"
|
|
||||||
#include "game_world.h"
|
|
||||||
|
|
||||||
static inline void InternalPlayerInitInput(Player* self)
|
|
||||||
{
|
|
||||||
// HORIZONTAL
|
|
||||||
playerinput_add(self->input, CompositeAxis1D_as_InputAxis(compositeaxis1d_new(KeyBind_as_InputAxis(keybind_new(SDL_SCANCODE_A)), KeyBind_as_InputAxis(keybind_new(SDL_SCANCODE_D)), InputEvent_Float)), (InputDelegateFn)PlayerInputHorizontal);
|
|
||||||
|
|
||||||
// VERTICAL
|
|
||||||
playerinput_add(self->input, CompositeAxis1D_as_InputAxis(compositeaxis1d_new(KeyBind_as_InputAxis(keybind_new(SDL_SCANCODE_S)), KeyBind_as_InputAxis(keybind_new(SDL_SCANCODE_W)), InputEvent_Float)), (InputDelegateFn)PlayerInputVertical);
|
|
||||||
}
|
|
||||||
|
|
||||||
Player* MakePlayer()
|
|
||||||
{
|
|
||||||
Player* self = malloc(sizeof(Player));
|
|
||||||
ASSERT_RETURN(self != NULL, NULL, "Could not allocate enough space for Player instance");
|
|
||||||
|
|
||||||
Spritesheet* walk = spritesheet_load("assets/sprites/player/player_walk.png", IVectorFrom(512));
|
|
||||||
Spritesheet* idle = spritesheet_load("assets/sprites/player/player_walk.png", IVectorFrom(512));
|
|
||||||
|
|
||||||
*self = (Player) {
|
|
||||||
.transform = IdentityTransform,
|
|
||||||
|
|
||||||
.input = playerinput_new(self, -1),
|
|
||||||
.input_direction = ZeroVector,
|
|
||||||
|
|
||||||
.faceDirection = 0,
|
|
||||||
|
|
||||||
.animationStateMachine = NULL,
|
|
||||||
|
|
||||||
.idle = animation_sprite_new(idle, 4.0f),
|
|
||||||
.walk = animation_sprite_new(walk, 4.0f),
|
|
||||||
|
|
||||||
.current_anim = self->idle
|
|
||||||
};
|
|
||||||
|
|
||||||
self->animationStateMachine = state_machine_init(self, PlayerIdle());
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player* SpawnPlayer(Vector location)
|
|
||||||
{
|
|
||||||
Player* self = MakePlayer();
|
|
||||||
self->transform.position = location;
|
|
||||||
game_world_add_entity(Player_as_BehaviourEntity(self));
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerStart(Player* self) { }
|
|
||||||
|
|
||||||
void PlayerUpdate(Player* self, float deltaTime)
|
|
||||||
{
|
|
||||||
state_machine_update(self->animationStateMachine, deltaTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerDestroy(Player* self)
|
|
||||||
{
|
|
||||||
state_machine_destroy(self->animationStateMachine);
|
|
||||||
|
|
||||||
animation_sprite_destroy(self->idle);
|
|
||||||
animation_sprite_destroy(self->walk);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerDraw(Player* self)
|
|
||||||
{
|
|
||||||
animation_sprite_draw(self->current_anim, &self->transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerInputHorizontal(Player* self, InputEvent event) { }
|
|
||||||
|
|
||||||
void PlayerInputVertical(Player* self, InputEvent event) { }
|
|
||||||
|
|
||||||
Transform* PlayerGetTransform(Player* self)
|
|
||||||
{
|
|
||||||
return &self->transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerAnimationExit(Player* self) { }
|
|
||||||
|
|
||||||
void PlayerIdleEnter(Player* self)
|
|
||||||
{
|
|
||||||
self->current_anim = self->idle;
|
|
||||||
animation_sprite_play_from(self->current_anim, 0.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
const State* PlayerIdleUpdate(Player* self, float deltaTime)
|
|
||||||
{
|
|
||||||
return PlayerIdle();
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
#ifndef TOPDOWN_PLAYER_H
|
|
||||||
#define TOPDOWN_PLAYER_H
|
|
||||||
|
|
||||||
#include "animation_sprite.h"
|
|
||||||
#include "behaviour_entity.h"
|
|
||||||
#include "drop.h"
|
|
||||||
#include "player_input.h"
|
|
||||||
#include "state_machine.h"
|
|
||||||
#include "transformable.h"
|
|
||||||
|
|
||||||
typedef struct Player {
|
|
||||||
Transform transform;
|
|
||||||
|
|
||||||
PlayerInput* input;
|
|
||||||
Vector input_direction;
|
|
||||||
|
|
||||||
unsigned short faceDirection;
|
|
||||||
|
|
||||||
StateMachine* animationStateMachine;
|
|
||||||
|
|
||||||
AnimationSprite* idle;
|
|
||||||
AnimationSprite* walk;
|
|
||||||
|
|
||||||
AnimationSprite* current_anim;
|
|
||||||
} Player;
|
|
||||||
|
|
||||||
extern Player* MakePlayer();
|
|
||||||
|
|
||||||
extern Player* SpawnPlayer(Vector location);
|
|
||||||
extern void PlayerUpdate(Player* self, float deltaTime);
|
|
||||||
extern void PlayerStart(Player* self);
|
|
||||||
extern void PlayerDestroy(Player* self);
|
|
||||||
extern void PlayerDraw(Player* self);
|
|
||||||
|
|
||||||
extern void PlayerInputHorizontal(Player* self, InputEvent event);
|
|
||||||
extern void PlayerInputVertical(Player* self, InputEvent event);
|
|
||||||
|
|
||||||
extern Transform* PlayerGetTransform(Player* self);
|
|
||||||
|
|
||||||
impl_Drop_for(Player,
|
|
||||||
PlayerDestroy)
|
|
||||||
|
|
||||||
impl_Transformable_for(Player,
|
|
||||||
PlayerGetTransform)
|
|
||||||
|
|
||||||
impl_BehaviourEntity_for(Player,
|
|
||||||
PlayerStart,
|
|
||||||
PlayerUpdate,
|
|
||||||
SpawnPlayer,
|
|
||||||
PlayerDraw)
|
|
||||||
|
|
||||||
extern void PlayerAnimationExit(Player* player);
|
|
||||||
|
|
||||||
extern void PlayerIdleEnter(Player* player);
|
|
||||||
extern const State* PlayerIdleUpdate(Player* player, float deltaTime);
|
|
||||||
|
|
||||||
DefineState(PlayerIdle, Player,
|
|
||||||
PlayerIdleEnter,
|
|
||||||
PlayerAnimationExit,
|
|
||||||
PlayerIdleUpdate)
|
|
||||||
|
|
||||||
#endif // !TOPDOWN_PLAYER_H
|
|
Loading…
Reference in a new issue