first commit
This commit is contained in:
CMakeLists.txtLICENSE
include/cglm
affine-mat.haffine-post.haffine-pre.haffine.haffine2d.happlesimd.hbezier.hbox.hcall.h
call
affine.haffine2d.hbezier.hbox.hcam.h
cam.hcglm.hclipspace
ortho_lh_no.hortho_lh_zo.hortho_rh_no.hortho_rh_zo.hpersp_lh_no.hpersp_lh_zo.hpersp_rh_no.hpersp_rh_zo.hproject_no.hproject_zo.hview_lh_no.hview_lh_zo.hview_rh_no.hview_rh_zo.h
curve.hease.heuler.hfrustum.hio.hivec2.hivec3.hivec4.hmat2.hmat3.hmat4.hplane.hproject.hquat.hray.hsphere.hvec2.hvec3.hvec4.hclipspace
ortho_lh_no.hortho_lh_zo.hortho_rh_no.hortho_rh_zo.hpersp.hpersp_lh_no.hpersp_lh_zo.hpersp_rh_no.hpersp_rh_zo.hproject_no.hproject_zo.hview_lh.hview_lh_no.hview_lh_zo.hview_rh.hview_rh_no.hview_rh_zo.h
color.hcommon.hcurve.hease.heuler.hfrustum.hio.hivec2.hivec3.hivec4.hmat2.hmat3.hmat4.hplane.hproject.hquat.hray.hsimd
sphere.hstruct.hstruct
affine-post.haffine-pre.haffine.haffine2d.hbox.hcam.h
types-struct.htypes.hutil.hvec2-ext.hvec2.hvec3-ext.hvec3.hvec4-ext.hvec4.hversion.hclipspace
ortho_lh_no.hortho_lh_zo.hortho_rh_no.hortho_rh_zo.hpersp_lh_no.hpersp_lh_zo.hpersp_rh_no.hpersp_rh_zo.hproject_no.hproject_zo.hview_lh_no.hview_lh_zo.hview_rh_no.hview_rh_zo.h
color.hcurve.heuler.hfrustum.hio.hmat2.hmat3.hmat4.hplane.hproject.hquat.hsphere.hvec2-ext.hvec2.hvec3-ext.hvec3.hvec4-ext.hvec4.hsrc
COMMON.h
engine
camera.ccamera.hcircle.ccircle.hevent.cevent.hfbo.cfbo.hfile.cfile.hfont.cfont.hfullscreen.cfullscreen.hglew.cglew.hkeyboard.ckeyboard.hmouse.cmouse.hmusic.cmusic.hrbo.crbo.hrectangle.crectangle.hrenderer.crenderer.hsdl.csdl.hshader.cshader.hsound.csound.hsurface.csurface.htexture.ctexture.htick.ctick.htime.ctime.hvao.cvao.hvbo.cvbo.hvector.cvector.hvertexattribute.cvertexattribute.hwindow.cwindow.h
game
GAME_COMMON.h
main.cmain.hecs
ECS_COMMON.h
game.cgame.hcomponent
COMPONENT_COMMON.h
ecs.cecs.hecs_component.cecs_component.hecs_component_list.cecs_component_list.hecs_entity.cecs_entity.hanimation
component_animation.ccomponent_animation.hcomponent_animation_player.ccomponent_animation_player.hcomponent_animation_target.ccomponent_animation_target.h
game
component_collect.ccomponent_collect.hcomponent_collectible.ccomponent_collectible.hcomponent_collide_slow.ccomponent_collide_slow.hcomponent_food.ccomponent_food.hcomponent_game_object.ccomponent_game_object.hcomponent_homing.ccomponent_homing.hcomponent_levitate.ccomponent_levitate.hcomponent_plane_object.ccomponent_plane_object.hcomponent_player_control.ccomponent_player_control.hcomponent_power.ccomponent_power.hcomponent_solid.ccomponent_solid.hcomponent_stage.ccomponent_stage.hcomponent_stamina.ccomponent_stamina.hcomponent_take_food.ccomponent_take_food.hcomponent_threshold.ccomponent_threshold.hcomponent_world_object.ccomponent_world_object.h
physics
component_circle_collider.ccomponent_circle_collider.hcomponent_copy_mouse_position.ccomponent_copy_mouse_position.hcomponent_physics.ccomponent_physics.h
ui
utility
component_counter.ccomponent_counter.hcomponent_delete_on_timer.ccomponent_delete_on_timer.hcomponent_timer.ccomponent_timer.h
visual
component_atlas.ccomponent_atlas.hcomponent_camera_focus.ccomponent_camera_focus.hcomponent_color_change.ccomponent_color_change.hcomponent_color_match.ccomponent_color_match.hcomponent_dialogue.ccomponent_dialogue.hcomponent_drop_shadow.ccomponent_drop_shadow.hcomponent_pulsate.ccomponent_pulsate.hcomponent_rotate.ccomponent_rotate.hcomponent_scale_value.ccomponent_scale_value.hcomponent_text.ccomponent_text.hcomponent_texture_quad.ccomponent_texture_quad.hcomponent_value_text.ccomponent_value_text.h
entity
game
entity_collectible.centity_collectible.hentity_collectible_amulet.centity_collectible_amulet.hentity_collectible_food.centity_collectible_food.hentity_collectible_power.centity_collectible_power.hentity_collectible_rotten_food.centity_collectible_rotten_food.hentity_collectible_stamina.centity_collectible_stamina.hentity_player.centity_player.hentity_smoke.centity_smoke.hentity_smoke_big.centity_smoke_big.hentity_target.centity_target.hentity_trap.centity_trap.h
ui
entity_button.centity_button.hentity_cursor.centity_cursor.hentity_level_select_button.centity_level_select_button.hentity_level_select_button_icon.centity_level_select_button_icon.hentity_logo.centity_logo.hentity_medal.centity_medal.hentity_meter.centity_meter.h
utility
visual
input
render
resource
RESOURCE_COMMON.hresource_font.cresource_font.hresource_music.cresource_music.hresource_shader.cresource_shader.hresource_sound.cresource_sound.hresource_texture.cresource_texture.hresources.cresources.h
state
78
src/game/input/control.c
Normal file
78
src/game/input/control.c
Normal file
@ -0,0 +1,78 @@
|
||||
#include "control.h"
|
||||
|
||||
void
|
||||
control_tick(Control* self, Input* input)
|
||||
{
|
||||
memcpy(&self->previous, &self->current, sizeof(bool) * CONTROL_COUNT);
|
||||
memset(&self->current, '\0', sizeof(bool) * CONTROL_COUNT);
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_UP] || input->keyboard.current[KEYBOARD_KEY_W])
|
||||
self->current[CONTROL_UP] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_LEFT] || input->keyboard.current[KEYBOARD_KEY_A])
|
||||
self->current[CONTROL_LEFT] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_RIGHT] || input->keyboard.current[KEYBOARD_KEY_D])
|
||||
self->current[CONTROL_RIGHT] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_DOWN] || input->keyboard.current[KEYBOARD_KEY_S])
|
||||
self->current[CONTROL_DOWN] = true;
|
||||
|
||||
if (input->mouse.current[MOUSE_BUTTON_LEFT])
|
||||
self->current[CONTROL_ACTION_PRIMARY] = true;
|
||||
|
||||
if (input->mouse.current[MOUSE_BUTTON_RIGHT])
|
||||
self->current[CONTROL_ACTION_SECONDARY] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_SPACE] || input->mouse.current[MOUSE_BUTTON_MIDDLE])
|
||||
self->current[CONTROL_ACTION_TERTIARY] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_1])
|
||||
self->current[CONTROL_INVIGORATE] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_2])
|
||||
self->current[CONTROL_EXTEND] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_3])
|
||||
self->current[CONTROL_FORESIGHT] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_4])
|
||||
self->current[CONTROL_CANCEL] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_5])
|
||||
self->current[CONTROL_MAGNET] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_P])
|
||||
self->current[CONTROL_PAUSE] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_R])
|
||||
self->current[CONTROL_RETRY] = true;
|
||||
|
||||
if (input->keyboard.current[KEYBOARD_KEY_ESCAPE])
|
||||
self->current[CONTROL_ESCAPE] = true;
|
||||
}
|
||||
|
||||
bool
|
||||
control_held(Control* self, ControlType type)
|
||||
{
|
||||
return self->current[type] && self->previous[type];
|
||||
}
|
||||
|
||||
bool
|
||||
control_pressed(Control* self, ControlType type)
|
||||
{
|
||||
return self->current[type] && !self->previous[type];
|
||||
}
|
||||
|
||||
bool
|
||||
control_released(Control* self, ControlType type)
|
||||
{
|
||||
return !self->current[type] && self->previous[type];
|
||||
}
|
||||
|
||||
void
|
||||
control_clear(Control* self)
|
||||
{
|
||||
memset(&self->previous, '\0', sizeof(bool) * CONTROL_COUNT);
|
||||
memset(&self->current, '\0', sizeof(bool) * CONTROL_COUNT);
|
||||
}
|
Reference in New Issue
Block a user