diff --git a/include/components/gravity_component.h b/include/components/gravity_component.h index 932126a..96f2d42 100644 --- a/include/components/gravity_component.h +++ b/include/components/gravity_component.h @@ -13,7 +13,6 @@ struct gravity_component { gc_component base; int gravity_speed; - int max_speed; }; extern const struct gravity_component gravity_component; \ No newline at end of file diff --git a/include/components/jump_action.h b/include/components/jump_action.h index 142bbfa..2e2782c 100644 --- a/include/components/jump_action.h +++ b/include/components/jump_action.h @@ -16,6 +16,8 @@ struct jump_action int acceleration; int counterforce; bool contered; + int step; + int step_count; }; extern const struct jump_action jump_action; \ No newline at end of file diff --git a/include/components/walk_action.h b/include/components/walk_action.h index e934c30..21540bb 100644 --- a/include/components/walk_action.h +++ b/include/components/walk_action.h @@ -14,8 +14,6 @@ struct walk_action { gc_component base; int acceleration; - int max_acceleration; - int decceleration; }; extern const struct walk_action walk_action; \ No newline at end of file diff --git a/lib/gamacon b/lib/gamacon index e383fe3..c534d3c 160000 --- a/lib/gamacon +++ b/lib/gamacon @@ -1 +1 @@ -Subproject commit e383fe3fb254ad9cdf71292119cdf004b40762ba +Subproject commit c534d3c190fc80a02c781404c25e20ced31bd6a0 diff --git a/prefabs/player.gcprefab b/prefabs/player.gcprefab index af52eff..637bcce 100644 --- a/prefabs/player.gcprefab +++ b/prefabs/player.gcprefab @@ -9,10 +9,10 @@ - + - - + + diff --git a/src/components/gravity_component.c b/src/components/gravity_component.c index 3b7aab6..db8a7a2 100644 --- a/src/components/gravity_component.c +++ b/src/components/gravity_component.c @@ -16,15 +16,13 @@ static void ctr(void *component, va_list args) struct gravity_component *cmp = (struct gravity_component *)component; cmp->gravity_speed = va_arg(args, int); - cmp->max_speed = va_arg(args, int); } static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n) { struct gravity_component *cmp = (struct gravity_component *)component; - cmp->gravity_speed = xml_getintprop(n, "speed"); - cmp->max_speed = xml_getintprop(n, "max_speed"); + cmp->gravity_speed = xml_getintprop(n, "force"); (void)scene; (void)entity; } diff --git a/src/components/jump_component.c b/src/components/jump_component.c index 0f71e58..e788436 100644 --- a/src/components/jump_component.c +++ b/src/components/jump_component.c @@ -17,6 +17,9 @@ static void ctr(void *component, va_list args) struct jump_action *cmp = (struct jump_action *)component; cmp->acceleration = va_arg(args, int); + cmp->counterforce = va_arg(args, int); + cmp->step_count = va_arg(args, int); + cmp->step = 0; cmp->contered = false; } @@ -26,6 +29,8 @@ static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n) cmp->acceleration = xml_getintprop(n, "acceleration"); cmp->counterforce = xml_getintprop(n, "counterforce"); + cmp->step_count = xml_getintprop(n, "step_count"); + cmp->step = 0; cmp->contered = false; (void)scene; (void)entity; diff --git a/src/components/walk_component.c b/src/components/walk_component.c index 28d202e..ba4bccc 100644 --- a/src/components/walk_component.c +++ b/src/components/walk_component.c @@ -17,8 +17,6 @@ static void ctr(void *component, va_list args) struct walk_action *cmp = (struct walk_action *)component; cmp->acceleration = va_arg(args, int); - cmp->max_acceleration = va_arg(args, int); - cmp->decceleration = va_arg(args, int); } static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n) @@ -26,8 +24,6 @@ static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n) struct walk_action *cmp = (struct walk_action *)component; cmp->acceleration = xml_getintprop(n, "acceleration"); - cmp->max_acceleration = xml_getintprop(n, "max_acceleration"); - cmp->decceleration = xml_getintprop(n, "decceleration"); (void)scene; (void)entity; } @@ -59,7 +55,5 @@ const struct walk_action walk_action = { serialize: &serialize, destroy: &component_destroy }, - acceleration: 0, - max_acceleration: 0, - decceleration: 0 + acceleration: 0 }; \ No newline at end of file diff --git a/src/systems/jump_system.c b/src/systems/jump_system.c index 50a3038..774e702 100644 --- a/src/systems/jump_system.c +++ b/src/systems/jump_system.c @@ -25,13 +25,18 @@ gc_entity *entity, float dtime) struct movable_component *mov = GETCMP(movable_component); struct jump_action *jump = GETCMP(jump_action); - if (col->distance_down == 0) { - mov->acceleration.y += con->jumping * jump->acceleration; + if (col->distance_down == 0 && con->jumping) { + mov->acceleration.y += jump->acceleration; jump->contered = false; - } else if (!jump->contered && mov->acceleration.y > 0 && !con->jumping) { + jump->step = jump->step_count; + } else if (!jump->contered && mov->velocity.y > 0 && !con->jumping) { jump->contered = true; - if (mov->acceleration.y > 0) - mov->acceleration.y -= MIN(jump->counterforce, mov->acceleration.y); + jump->step = 0; + } + + if (jump->step > 0) { + mov->acceleration.y += jump->acceleration; + jump->step--; } (void)system; (void)dtime; diff --git a/src/systems/walk_system.c b/src/systems/walk_system.c index 88014e7..4bcd82c 100644 --- a/src/systems/walk_system.c +++ b/src/systems/walk_system.c @@ -22,12 +22,11 @@ gc_entity *entity, float dtime) struct controllable_component *con = GETCMP(controllable_component); struct movable_component *mov = GETCMP(movable_component); struct walk_action *walk = GETCMP(walk_action); - gc_vector2 *acc = &mov->acceleration; if (con->moving_left) - acc->x -= walk->acceleration; + mov->acceleration.x -= walk->acceleration; if (con->moving_right) - acc->x += walk->acceleration; + mov->acceleration.x += walk->acceleration; (void)system; (void)dtime; (void)engine;