added button panels (triggered when a moving block is on them
This commit is contained in:
parent
dd0aed2334
commit
fef3705d71
|
@ -87,7 +87,10 @@ entities:
|
|||
{ontime,offtime} = double[>0.0]
|
||||
start = {0,1}
|
||||
|
||||
-> 10 UNUSED
|
||||
-> 10 (movable block)
|
||||
[.. friction, mass] with
|
||||
friction = double[>0.0]
|
||||
mass = double[>0.0] (in kg)
|
||||
|
||||
-> 11 (button trigger)
|
||||
[.. freq, dtime] with
|
||||
|
@ -104,4 +107,8 @@ entities:
|
|||
defaultState = {0, 1}
|
||||
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,9 +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]
|
||||
[-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, 6.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, 9.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, 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) {
|
||||
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 == 14 && ent->metai2) ||
|
||||
(ent->entity_type == 12 && xor(buttonSwitch[ent->metai1], ent->metai2))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -289,6 +289,32 @@ 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) {
|
||||
//printf("(+%lf, +%lf)\n", camvx, camvz);
|
||||
updateF_movableCrate(ret, (double)dtime, ent);
|
||||
|
|
|
@ -23,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 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 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 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].onHit = &active_math;
|
||||
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) {
|
||||
|
@ -678,6 +686,7 @@ void parse_one_room(int id, char* filename) {
|
|||
pool[id].area->ents[k]->metai1 = freq;
|
||||
pool[id].area->ents[k]->metad1 = acttime;
|
||||
} else if(entry->id == 12) {
|
||||
// button interface
|
||||
int freq = 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]->metai2 = offstate;
|
||||
} else if(entry->id == 13) {
|
||||
// button block
|
||||
int defaultState = read_int(ptr);
|
||||
double activeTime = read_float(ptr);
|
||||
|
||||
|
@ -702,6 +712,11 @@ void parse_one_room(int id, char* filename) {
|
|||
} else {
|
||||
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 {
|
||||
pool[id].area->ents[k]->metai3 = 0;
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ void updateF_movableCrate(cube_0* cb, double dtime, entity* ent) {
|
|||
(dot3D(vt, normal) <= 0.0 && dot3D(vtdt, normal) >= 0.0) ||
|
||||
(dot3D(vt, normal) >= 0.0 && dot3D(vtdt, normal) <= 0.0)
|
||||
) {
|
||||
printf("%d\n", d);
|
||||
//printf("%d\n", d);
|
||||
switch (d) {
|
||||
case 0:
|
||||
ent->metad1 += camvx; break;
|
||||
|
|
Loading…
Reference in New Issue