Compare commits
5 Commits
8568996914
...
3745b0c6bc
Author | SHA1 | Date | |
---|---|---|---|
3745b0c6bc | |||
b70a86aa33 | |||
bb89100130 | |||
aa75118996 | |||
6b3ba17fc9 |
@ -593,6 +593,7 @@ void TELY_DLL_Init(void *user_data)
|
||||
entity->flags |= FP_GameEntityFlag_Clickable;
|
||||
entity->flags |= FP_GameEntityFlag_MoveByKeyboard;
|
||||
entity->flags |= FP_GameEntityFlag_MoveByMouse;
|
||||
entity->flags |= FP_GameEntityFlag_MoveByGamepad;
|
||||
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
||||
entity->facing_left = true;
|
||||
game->clicked_entity = entity->handle;
|
||||
@ -652,6 +653,7 @@ void TELY_DLL_Init(void *user_data)
|
||||
entity->flags |= FP_GameEntityFlag_Clickable;
|
||||
entity->flags |= FP_GameEntityFlag_MoveByKeyboard;
|
||||
entity->flags |= FP_GameEntityFlag_MoveByMouse;
|
||||
entity->flags |= FP_GameEntityFlag_MoveByGamepad;
|
||||
entity->flags |= FP_GameEntityFlag_MobSpawner;
|
||||
entity->spawn_cap = 1;
|
||||
}
|
||||
@ -697,11 +699,12 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_Renderer *renderer,
|
||||
dir_vector.x = +1.f;
|
||||
|
||||
// NOTE: Gamepad movement input
|
||||
for (uint32_t gamepad = 0; gamepad < MAX_GAMEPADS; gamepad++) {
|
||||
if (input->button_codes[gamepad]) {
|
||||
dir_vector.x += input->left_stick[gamepad].x;
|
||||
dir_vector.y += input->left_stick[gamepad].y;
|
||||
}
|
||||
// NOTE: button_codes 0 should be the first gamepad connected, we can
|
||||
// get this working with other gamepads later
|
||||
uint32_t gamepad = 0;
|
||||
if (input->button_codes[gamepad]) {
|
||||
dir_vector.x += input->left_stick[gamepad].x;
|
||||
dir_vector.y += input->left_stick[gamepad].y;
|
||||
}
|
||||
|
||||
if (dir_vector.x && dir_vector.y) {
|
||||
@ -721,11 +724,11 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_Renderer *renderer,
|
||||
FP_GameEntity *entity = it.entity;
|
||||
entity->alive_time_s += input->delta_s;
|
||||
|
||||
// NOTE: Move entity by keyboard ===========================================================
|
||||
// NOTE: Move entity by keyboard and gamepad ===============================================
|
||||
Dqn_V2 acceleration = {};
|
||||
if (game->clicked_entity == entity->handle &&
|
||||
(entity->action.state == FP_GameEntityState_Run || entity->action.state == FP_GameEntityState_Idle)) {
|
||||
if (entity->flags & FP_GameEntityFlag_MoveByKeyboard) {
|
||||
if (entity->flags & (FP_GameEntityFlag_MoveByKeyboard || FP_GameEntityFlag_MoveByGamepad)) {
|
||||
acceleration = dir_vector * 10000000.f;
|
||||
if (dir_vector.x)
|
||||
entity->facing_left = dir_vector.x < 0.f;
|
||||
@ -914,7 +917,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_Renderer *renderer,
|
||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||
FP_Game_EntityActionReset(action, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, action_to_anim_mapping);
|
||||
} else if (we_are_clicked_entity) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
||||
FP_Game_EntityActionSetState(action, FP_GameEntityState_AttackA);
|
||||
} else if (dir_vector.x || dir_vector.y) {
|
||||
FP_Game_EntityActionSetState(action, FP_GameEntityState_Run);
|
||||
@ -930,7 +934,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_Renderer *renderer,
|
||||
} else if (action_has_finished) {
|
||||
FP_Game_EntityActionSetState(action, FP_GameEntityState_Idle);
|
||||
} else if (!FP_Game_EntityActionHasFailed(action) && we_are_clicked_entity) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
||||
Dqn_f32 t01 = action->timer_s / action->end_at_s;
|
||||
if (t01 > 0.5f)
|
||||
FP_Game_EntityActionSetState(action, FP_GameEntityState_AttackB);
|
||||
@ -948,7 +953,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_Renderer *renderer,
|
||||
} else if (action_has_finished) {
|
||||
FP_Game_EntityActionSetState(action, FP_GameEntityState_Idle);
|
||||
} else if (!FP_Game_EntityActionHasFailed(action) && we_are_clicked_entity) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
||||
Dqn_f32 t01 = action->timer_s / action->end_at_s;
|
||||
if (t01 > 0.5f)
|
||||
FP_Game_EntityActionSetState(action, FP_GameEntityState_AttackC);
|
||||
@ -974,9 +980,11 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_Renderer *renderer,
|
||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||
FP_Game_EntityActionReset(action, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, action_to_anim_mapping);
|
||||
} else if (we_are_clicked_entity) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
||||
FP_Game_EntityActionSetState(action, FP_GameEntityState_AttackA);
|
||||
} else if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_LeftShift)) {
|
||||
} else if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_LeftShift) ||
|
||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_A)) {
|
||||
FP_Game_EntityActionSetState(action, FP_GameEntityState_Dash);
|
||||
}
|
||||
}
|
||||
@ -1361,5 +1369,5 @@ void TELY_DLL_FrameUpdate(void *user_data)
|
||||
}
|
||||
|
||||
TELY_RFui_Flush(rfui, renderer, input, assets);
|
||||
TELY_Audio_MixPlaybackSamples(audio, assets);
|
||||
//TELY_Audio_MixPlaybackSamples(audio, assets);
|
||||
}
|
||||
|
@ -8,10 +8,11 @@ enum FP_GameEntityFlag
|
||||
FP_GameEntityFlag_Clickable = 1 << 0,
|
||||
FP_GameEntityFlag_MoveByKeyboard = 1 << 1,
|
||||
FP_GameEntityFlag_MoveByMouse = 1 << 2,
|
||||
FP_GameEntityFlag_DrawHitBox = 1 << 3,
|
||||
FP_GameEntityFlag_DeriveHitBoxFromChildrenBoundingBox = 1 << 4,
|
||||
FP_GameEntityFlag_NonTraversable = 1 << 5,
|
||||
FP_GameEntityFlag_MobSpawner = 1 << 6,
|
||||
FP_GameEntityFlag_MoveByGamepad = 1 << 3,
|
||||
FP_GameEntityFlag_DrawHitBox = 1 << 4,
|
||||
FP_GameEntityFlag_DeriveHitBoxFromChildrenBoundingBox = 1 << 5,
|
||||
FP_GameEntityFlag_NonTraversable = 1 << 6,
|
||||
FP_GameEntityFlag_MobSpawner = 1 << 7,
|
||||
};
|
||||
|
||||
enum FP_GameShapeType
|
||||
|
Loading…
Reference in New Issue
Block a user