Skip to content

Commit

Permalink
player input speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondra Voves committed May 26, 2019
1 parent 0da1034 commit 7745430
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions examples/develop/src/components/c_player_input.inl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

typedef struct player_input_component {
float move;
float move_speed;
ce_vec2_t shoot_dir;
} player_input_component;

Expand Down Expand Up @@ -44,6 +45,10 @@ static const ce_cdb_prop_def_t0 player_input_component_prop[] = {
.name = "move",
.type = CE_CDB_TYPE_FLOAT,
},
{
.name = "move_speed",
.type = CE_CDB_TYPE_FLOAT,
},
{
.name = "shoot_dir",
.type = CE_CDB_TYPE_SUBOBJECT,
Expand Down
6 changes: 6 additions & 0 deletions examples/develop/src/content/ceong/pad.entity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ components:
cdb_uid: 0xfab273448e38044e
cdb_type: player_input
move: 0.000000
move_speed: 15000.000000
shoot_dir:
cdb_uid: 0x719961fd4c6882e9
cdb_type: vec2_t
x: 0.000000
y: 0.000000
0x505912ebe0a8d032:
cdb_uid: 0x505912ebe0a8d032
cdb_type: pad
Expand Down
2 changes: 1 addition & 1 deletion examples/develop/src/systems/s_player_move.inl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void player_move_foreach_components(struct ct_world_t0 world,
player_input_component *pi_o = &player_inputs[i];
velocity_component *speed_o = &speds[i];

speed_o->velocity.y = pi_o->move * 15000 * dt;
speed_o->velocity.y = pi_o->move * pi_o->move_speed * dt;

ct_ecs_a0->component_changed(world, ent[i], VELOCITY_COMPONENT);
}
Expand Down

0 comments on commit 7745430

Please sign in to comment.