Compare commits
2 Commits
48c39e5c55
...
fef3705d71
Author | SHA1 | Date |
---|---|---|
|
fef3705d71 | |
|
dd0aed2334 |
|
@ -87,7 +87,10 @@ entities:
|
||||||
{ontime,offtime} = double[>0.0]
|
{ontime,offtime} = double[>0.0]
|
||||||
start = {0,1}
|
start = {0,1}
|
||||||
|
|
||||||
-> 10 UNUSED
|
-> 10 (movable block)
|
||||||
|
[.. friction, mass] with
|
||||||
|
friction = double[>0.0]
|
||||||
|
mass = double[>0.0] (in kg)
|
||||||
|
|
||||||
-> 11 (button trigger)
|
-> 11 (button trigger)
|
||||||
[.. freq, dtime] with
|
[.. freq, dtime] with
|
||||||
|
@ -104,4 +107,8 @@ entities:
|
||||||
defaultState = {0, 1}
|
defaultState = {0, 1}
|
||||||
dtime = double([>0.0] for time-limited press, or use -1.0 if no deactivation)
|
dtime = double([>0.0] for time-limited press, or use -1.0 if no deactivation)
|
||||||
|
|
||||||
|
-> 14 (movable object-related button)
|
||||||
|
[.. freq] with
|
||||||
|
freq = int[0 - 15]
|
||||||
|
|
||||||
```
|
```
|
|
@ -33,7 +33,13 @@ 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]
|
[-5.0, 3.0, 5.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 10, 0.98, 1.0]
|
||||||
|
[-5.0, 6.0, 5.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 10, 0.98, 1.0]
|
||||||
|
[-5.0, 9.0, 5.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 10, 0.98, 1.0]
|
||||||
|
|
||||||
|
[0.0, 0.0, 0.0, 2.0, 0.2, 2.0, 0.0, 0.0, 255, 255, 0, 1, 0, 14, 10]
|
||||||
|
|
||||||
|
[4.0, 0.0, 0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 128, 128, 1, 0, 12, 10, 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]
|
||||||
|
|
BIN
obj/display.o
BIN
obj/display.o
Binary file not shown.
BIN
obj/entities.o
BIN
obj/entities.o
Binary file not shown.
BIN
obj/generation.o
BIN
obj/generation.o
Binary file not shown.
BIN
obj/move.o
BIN
obj/move.o
Binary file not shown.
|
@ -176,8 +176,9 @@ void gl_resetTexture() {
|
||||||
|
|
||||||
bool is_button_block_on(entity* ent) {
|
bool is_button_block_on(entity* ent) {
|
||||||
return (
|
return (
|
||||||
(ent->entity_type != 11 && ent->entity_type != 12) ||
|
(ent->entity_type != 11 && ent->entity_type != 12 && ent->entity_type != 14) ||
|
||||||
(ent->entity_type == 11 && buttonSwitch[ent->metai1]) ||
|
(ent->entity_type == 11 && buttonSwitch[ent->metai1]) ||
|
||||||
|
(ent->entity_type == 14 && ent->metai2) ||
|
||||||
(ent->entity_type == 12 && xor(buttonSwitch[ent->metai1], ent->metai2))
|
(ent->entity_type == 12 && xor(buttonSwitch[ent->metai1], ent->metai2))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,21 @@ bool is_colliding_with_tp(cube_0* cb) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_colliding_with_ent_sp(cube_0* cb, int allowed) {
|
||||||
|
for(int k = 0; k < current_room->ent_len; k++) {
|
||||||
|
for(int d = 0; d < 8; d++) {
|
||||||
|
if(
|
||||||
|
current_room->ents[k]->entity_type == allowed &&
|
||||||
|
(cb->x != current_room->ents[k]->pos->x || cb->y != current_room->ents[k]->pos->y || cb->z != current_room->ents[k]->pos->z) &&
|
||||||
|
distance_pt_cube_0_3d(cb->x+cb->w*(d%2==0), cb->y+cb->h*((d/2)%2==0), cb->z+cb->d*((d/4)%2==0), current_room->ents[k]->pos) <= 0.01
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------------------------------------------------ //
|
// ------------------------------------------------------------------------------------------------------------------------------------------------ //
|
||||||
|
|
||||||
static double choffx, choffz;
|
static double choffx, choffz;
|
||||||
|
@ -253,17 +268,17 @@ void movableCrate_postStep(double x, double y, double z, double w, double h, dou
|
||||||
ent->metad2 += -((double)dtime)*(gravity_factor*ent->metad5);
|
ent->metad2 += -((double)dtime)*(gravity_factor*ent->metad5);
|
||||||
|
|
||||||
ret->x += dtime*ent->metad1;
|
ret->x += dtime*ent->metad1;
|
||||||
if(absf(ent->metad1) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret)) {
|
if(absf(ent->metad1) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10)) {
|
||||||
ret->x -= dtime*ent->metad1;
|
ret->x -= dtime*ent->metad1;
|
||||||
ent->metad1 = 0.0;
|
ent->metad1 = 0.0;
|
||||||
}
|
}
|
||||||
ret->y += dtime*ent->metad2;
|
ret->y += dtime*ent->metad2;
|
||||||
if(absf(ent->metad2) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret)) {
|
if(absf(ent->metad2) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10)) {
|
||||||
ret->y -= dtime*ent->metad2;
|
ret->y -= dtime*ent->metad2;
|
||||||
ent->metad2 = 0.0;
|
ent->metad2 = 0.0;
|
||||||
}
|
}
|
||||||
ret->z += dtime*ent->metad3;
|
ret->z += dtime*ent->metad3;
|
||||||
if(absf(ent->metad3) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret)) {
|
if(absf(ent->metad3) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10)) {
|
||||||
ret->z -= dtime*ent->metad3;
|
ret->z -= dtime*ent->metad3;
|
||||||
ent->metad3 = 0.0;
|
ent->metad3 = 0.0;
|
||||||
}
|
}
|
||||||
|
@ -274,10 +289,35 @@ void movableCrate_postStep(double x, double y, double z, double w, double h, dou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// metai1 = button freq
|
||||||
|
// metai2 = is triggered (0/1)
|
||||||
|
void movCrateButton_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) {
|
||||||
|
bool isIn = false;
|
||||||
|
for(int k = 0; k < current_room->ent_len*(1-isIn); k++) {
|
||||||
|
for(int d = 0; d < 8*(1-isIn); d++) {
|
||||||
|
if(
|
||||||
|
current_room->ents[k]->entity_type == 10 &&
|
||||||
|
distance_pt_cube_0_3d(ret->x+ret->w*(d%2==0), ret->y+ret->h*((d/2)%2==0), ret->z+ret->d*((d/4)%2==0), current_room->ents[k]->pos) <= 0.001
|
||||||
|
) {
|
||||||
|
isIn = true;
|
||||||
|
ent->metai2 = 1;
|
||||||
|
if(!buttonSwitch[ent->metai1]) {
|
||||||
|
//printf("In\n");
|
||||||
|
buttonSwitch[ent->metai1] = true;
|
||||||
|
buttonTimes[ent->metai1] = -1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isIn && ent->metai2 != 0) {
|
||||||
|
ent->metai2 = 0;
|
||||||
|
buttonSwitch[ent->metai1] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void movableCrate_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
void movableCrate_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
||||||
//printf("(+%lf, +%lf)\n", camvx, camvz);
|
//printf("(+%lf, +%lf)\n", camvx, camvz);
|
||||||
ent->metad1 = camvx;
|
updateF_movableCrate(ret, (double)dtime, ent);
|
||||||
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) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ extern int build_text_box(char* msg, int red, int green, int blue);
|
||||||
|
|
||||||
bool is_colliding_with_map(cube_0* cb);
|
bool is_colliding_with_map(cube_0* cb);
|
||||||
bool is_colliding_with_tp(cube_0* cb);
|
bool is_colliding_with_tp(cube_0* cb);
|
||||||
|
bool is_colliding_with_ent_sp(cube_0* cb, int allowed);
|
||||||
|
|
||||||
void update_entity(entity* ent, float dtime);
|
void update_entity(entity* ent, float dtime);
|
||||||
void update_entities(float dtime, room* rtd);
|
void update_entities(float dtime, room* rtd);
|
||||||
|
@ -22,6 +23,7 @@ void spinning_platform(double x, double y, double z, double w, double h, double
|
||||||
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_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 movCrateButton_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 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);
|
||||||
|
|
|
@ -153,6 +153,14 @@ void init_ent_generator(int n) {
|
||||||
hashtbl_entities[13].updatePos = &math_block;
|
hashtbl_entities[13].updatePos = &math_block;
|
||||||
hashtbl_entities[13].onHit = &active_math;
|
hashtbl_entities[13].onHit = &active_math;
|
||||||
hashtbl_entities[13].onDeath = NULL;
|
hashtbl_entities[13].onDeath = NULL;
|
||||||
|
|
||||||
|
hashtbl_entities[14].id = 14;
|
||||||
|
hashtbl_entities[14].tex = 10;
|
||||||
|
hashtbl_entities[14].tex2 = 11;
|
||||||
|
hashtbl_entities[14].name = "movableBlockButton";
|
||||||
|
hashtbl_entities[14].updatePos = &movCrateButton_postStep;
|
||||||
|
hashtbl_entities[14].onHit = NULL;
|
||||||
|
hashtbl_entities[14].onDeath = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fct_entry* get_entry(int k0) {
|
fct_entry* get_entry(int k0) {
|
||||||
|
@ -678,6 +686,7 @@ void parse_one_room(int id, char* filename) {
|
||||||
pool[id].area->ents[k]->metai1 = freq;
|
pool[id].area->ents[k]->metai1 = freq;
|
||||||
pool[id].area->ents[k]->metad1 = acttime;
|
pool[id].area->ents[k]->metad1 = acttime;
|
||||||
} else if(entry->id == 12) {
|
} else if(entry->id == 12) {
|
||||||
|
// button interface
|
||||||
int freq = read_int(ptr);
|
int freq = read_int(ptr);
|
||||||
int offstate = read_int(ptr);
|
int offstate = read_int(ptr);
|
||||||
|
|
||||||
|
@ -690,6 +699,7 @@ void parse_one_room(int id, char* filename) {
|
||||||
pool[id].area->ents[k]->metai1 = freq;
|
pool[id].area->ents[k]->metai1 = freq;
|
||||||
pool[id].area->ents[k]->metai2 = offstate;
|
pool[id].area->ents[k]->metai2 = offstate;
|
||||||
} else if(entry->id == 13) {
|
} else if(entry->id == 13) {
|
||||||
|
// button block
|
||||||
int defaultState = read_int(ptr);
|
int defaultState = read_int(ptr);
|
||||||
double activeTime = read_float(ptr);
|
double activeTime = read_float(ptr);
|
||||||
|
|
||||||
|
@ -702,6 +712,11 @@ void parse_one_room(int id, char* filename) {
|
||||||
} else {
|
} else {
|
||||||
pool[id].area->ents[k]->tex2 = 9;
|
pool[id].area->ents[k]->tex2 = 9;
|
||||||
}
|
}
|
||||||
|
} else if(entry->id == 14) {
|
||||||
|
// movable block button
|
||||||
|
int freq = read_int(ptr);
|
||||||
|
|
||||||
|
pool[id].area->ents[k]->metai1 = freq;
|
||||||
} else {
|
} else {
|
||||||
pool[id].area->ents[k]->metai3 = 0;
|
pool[id].area->ents[k]->metai3 = 0;
|
||||||
}
|
}
|
||||||
|
|
55
src/move.c
55
src/move.c
|
@ -237,6 +237,61 @@ void debugMove(cube_0* cb) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateF_movableCrate(cube_0* cb, double dtime, entity* ent) {
|
||||||
|
for(int d = 0; d < 6; d++) {
|
||||||
|
cb->x -= min_dist;
|
||||||
|
cb->y -= min_dist;
|
||||||
|
cb->z -= min_dist;
|
||||||
|
cb->w += 2*min_dist;
|
||||||
|
cb->h += 2*min_dist;
|
||||||
|
cb->d += 2*min_dist;
|
||||||
|
getSF(cb, d);
|
||||||
|
cb->x += min_dist;
|
||||||
|
cb->y += min_dist;
|
||||||
|
cb->z += min_dist;
|
||||||
|
cb->w -= 2*min_dist;
|
||||||
|
cb->h -= 2*min_dist;
|
||||||
|
cb->d -= 2*min_dist;
|
||||||
|
getDirectors();
|
||||||
|
getNormal();
|
||||||
|
if(d==2 || d==5 || d==1) {
|
||||||
|
normal.x *= -1.0;
|
||||||
|
normal.y *= -1.0;
|
||||||
|
normal.z *= -1.0;
|
||||||
|
}
|
||||||
|
//printf("%lf %lf\n", dot3D(normal, directors[0]), dot3D(normal, directors[1]));
|
||||||
|
pt_2d vt = (pt_2d){.x = camx-camvx*dtime - surface[0].x, .y = camy-camvy*dtime - surface[0].y, .z = camz-camvz*dtime - surface[0].z};
|
||||||
|
pt_2d vtdt = (pt_2d){.x = camx - surface[0].x, .y = camy - surface[0].y, .z = camz - surface[0].z};
|
||||||
|
normalize(&vtdt);
|
||||||
|
normalize(&vt);
|
||||||
|
if(
|
||||||
|
(dot3D(vt, normal) <= 0.0 && dot3D(vtdt, normal) >= 0.0) ||
|
||||||
|
(dot3D(vt, normal) >= 0.0 && dot3D(vtdt, normal) <= 0.0)
|
||||||
|
) {
|
||||||
|
//printf("%d\n", d);
|
||||||
|
switch (d) {
|
||||||
|
case 0:
|
||||||
|
ent->metad1 += camvx; break;
|
||||||
|
case 1:
|
||||||
|
ent->metad1 += camvx; break;
|
||||||
|
case 3:
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ent->metad2 += camvy; break;
|
||||||
|
case 4:
|
||||||
|
ent->metad3 += camvz; break;
|
||||||
|
case 5:
|
||||||
|
ent->metad3 += camvz; break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void updateF(cube_0* cb, double dtime, entity* ent) {
|
void updateF(cube_0* cb, double dtime, entity* ent) {
|
||||||
for(int d = 0; d < 6; d++) {
|
for(int d = 0; d < 6; d++) {
|
||||||
cb->x -= min_dist;
|
cb->x -= min_dist;
|
||||||
|
|
|
@ -7,6 +7,7 @@ bool is_colliding(float dtime);
|
||||||
void update_buttons(float dtime);
|
void update_buttons(float dtime);
|
||||||
|
|
||||||
void updateF(cube_0* cb, double dtime, entity* ent);
|
void updateF(cube_0* cb, double dtime, entity* ent);
|
||||||
|
void updateF_movableCrate(cube_0* cb, double dtime, entity* ent);
|
||||||
|
|
||||||
void debugMove(cube_0* cb);
|
void debugMove(cube_0* cb);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue