added pushable blocks

This commit is contained in:
Alexandre 2025-03-13 22:03:02 +01:00
parent 1258be1e78
commit 48c39e5c55
7 changed files with 57 additions and 4 deletions

BIN
bin/back

Binary file not shown.

View File

@ -33,6 +33,7 @@ Entities:
[-15.0, 4.0, -10.0, 4.0, 1.0, 5.0, 0.0, 0.0, 255, 255, 255, 1, 0, 2, 0.0, 42.0, 0.0, 0.0, 2.0, 1] [-15.0, 4.0, -10.0, 4.0, 1.0, 5.0, 0.0, 0.0, 255, 255, 255, 1, 0, 2, 0.0, 42.0, 0.0, 0.0, 2.0, 1]
[-10.0, 4.0, -20.0, 5.0, 1.0, 5.0, 0.0, 0.0, 255, 255, 255, 1, 0, 2, 3.0, 0.0, 0.0, 0.0, 0.0, 0] [-10.0, 4.0, -20.0, 5.0, 1.0, 5.0, 0.0, 0.0, 255, 255, 255, 1, 0, 2, 3.0, 0.0, 0.0, 0.0, 0.0, 0]
[-5.0, 3.0, 5.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 10, 0.9, 1.0]
[8.0, 1.0 , 8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 128, 1, 0, 8, 100, 1, 128, 128, 128] [8.0, 1.0 , 8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 128, 1, 0, 8, 100, 1, 128, 128, 128]
[-8.0, 1.0, 8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 6, get over it, 192, 192, 192] [-8.0, 1.0, 8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 6, get over it, 192, 192, 192]

Binary file not shown.

Binary file not shown.

View File

@ -238,6 +238,48 @@ void lava_postStep(double x, double y, double z, double w, double h, double d, d
} }
} }
// metad1 = vx
// metad2 = vy
// metad3 = vz
// metad4 = friction
// metad5 = mass (kg)
void movableCrate_postStep(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, entity* ent, cube_0* ret) {
if(y < -48) {
*(ent->hitpoints) = 0;
} else {
//printf("(%lf %lf %lf)\n", ent->metad1, ent->metad2, ent->metad3);
// --P->
ent->metad2 += -((double)dtime)*(gravity_factor*ent->metad5);
ret->x += dtime*ent->metad1;
if(absf(ent->metad1) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret)) {
ret->x -= dtime*ent->metad1;
ent->metad1 = 0.0;
}
ret->y += dtime*ent->metad2;
if(absf(ent->metad2) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret)) {
ret->y -= dtime*ent->metad2;
ent->metad2 = 0.0;
}
ret->z += dtime*ent->metad3;
if(absf(ent->metad3) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret)) {
ret->z -= dtime*ent->metad3;
ent->metad3 = 0.0;
}
ent->metad1 *= (1.0 - ent->metad4*((double)(dtime)));
ent->metad2 *= (1.0 - ent->metad4*((double)(dtime)));
ent->metad3 *= (1.0 - ent->metad4*((double)(dtime)));
}
}
void movableCrate_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
//printf("(+%lf, +%lf)\n", camvx, camvz);
ent->metad1 = camvx;
ent->metad3 = camvz;
}
void lava_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) { void lava_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
player_hp -= ent->metai1; player_hp -= ent->metai1;
} }

View File

@ -21,7 +21,9 @@ void beating_block(double x, double y, double z, double w, double h, double d, d
void spinning_platform(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, entity* ent, cube_0* ret); void spinning_platform(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, entity* ent, cube_0* ret);
void math_block(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, entity* ent, cube_0* ret); void math_block(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, entity* ent, cube_0* ret);
void lava_postStep(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, entity* ent, cube_0* ret); void lava_postStep(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, entity* ent, cube_0* ret);
void movableCrate_postStep(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, entity* ent, cube_0* ret);
void movableCrate_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
void lava_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret); void lava_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
void active_math(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret); void active_math(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
void update_button(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret); void update_button(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);

View File

@ -125,9 +125,9 @@ void init_ent_generator(int n) {
hashtbl_entities[10].id = 10; hashtbl_entities[10].id = 10;
hashtbl_entities[10].tex = 4; hashtbl_entities[10].tex = 4;
hashtbl_entities[10].tex2 = 4; hashtbl_entities[10].tex2 = 4;
hashtbl_entities[10].name = "E"; hashtbl_entities[10].name = "PushableCrate";
hashtbl_entities[10].updatePos = NULL; hashtbl_entities[10].updatePos = &movableCrate_postStep;
hashtbl_entities[10].onHit = NULL; hashtbl_entities[10].onHit = &movableCrate_onHit;
hashtbl_entities[10].onDeath = NULL; hashtbl_entities[10].onDeath = NULL;
hashtbl_entities[11].id = 11; hashtbl_entities[11].id = 11;
@ -656,7 +656,15 @@ void parse_one_room(int id, char* filename) {
pool[id].area->ents[k]->metad3 = 0.0; pool[id].area->ents[k]->metad3 = 0.0;
pool[id].area->ents[k]->metai1 = 1-stst; pool[id].area->ents[k]->metai1 = 1-stst;
} else if(entry->id == 10) { } else if(entry->id == 10) {
// UNUSED // movable crate
double friction = read_float(ptr);
double mass = read_float(ptr);
pool[id].area->ents[k]->metad1 = 0.0;
pool[id].area->ents[k]->metad2 = 0.0;
pool[id].area->ents[k]->metad3 = 0.0;
pool[id].area->ents[k]->metad4 = friction;
pool[id].area->ents[k]->metad5 = mass;
} else if(entry->id == 11) { } else if(entry->id == 11) {
int freq = read_int(ptr); int freq = read_int(ptr);
double acttime = read_float(ptr); double acttime = read_float(ptr);