Tuning up values and the JUMP

This commit is contained in:
AnonymusRaccoon
2020-01-06 18:27:50 +01:00
parent 2c6a60f7c1
commit b2b6b94b3e
10 changed files with 25 additions and 25 deletions
-1
View File
@@ -13,7 +13,6 @@ struct gravity_component
{
gc_component base;
int gravity_speed;
int max_speed;
};
extern const struct gravity_component gravity_component;
+2
View File
@@ -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;
-2
View File
@@ -14,8 +14,6 @@ struct walk_action
{
gc_component base;
int acceleration;
int max_acceleration;
int decceleration;
};
extern const struct walk_action walk_action;
+3 -3
View File
@@ -9,10 +9,10 @@
</renderer>
<movable_component />
<controllable_component />
<gravity_component speed="2000" />
<gravity_component force="6250" />
<keyboard_controller left="16" right="3" jump="57" />
<walk_action acceleration="3000" max_acceleration="100" decceleration="100"/>
<jump_action acceleration="25000" counterforce="6000"/>
<walk_action acceleration="3000" />
<jump_action acceleration="17000" counterforce="6000" step_count="7"/>
<collision_component layer="11000000" />
<friction_component value=".5" />
</gc_entity>
+1 -3
View File
@@ -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;
}
+5
View File
@@ -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;
+1 -7
View File
@@ -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
};
+10 -5
View File
@@ -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;
+2 -3
View File
@@ -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;