added spinning lava bars

This commit is contained in:
Alexandre 2025-03-04 23:01:18 +01:00
parent f5c5cafeb7
commit 254744509f
12 changed files with 59 additions and 10 deletions

View File

@ -40,7 +40,13 @@ entities:
-> 0 (coin) -> damage equals the coin's value
-> 1 (non-moving explosive)
-> 2 (seeking explosive)
-> 2 (damaging firebar)
[.. hz_rps, vt_rps, x_offset, y_offset, z_offset dps] with
{hz,vt}_rps = double
hz0, vt_0 = double
{x,y,z}_offset = double // if all is 0.0, the solid will rotate according to its center of mass, this shifts that center
dps = int[>0]
-> 3 (shooting, maybe moving explosive)
[.. proj_speed, shoot_speed, shot_freq, shot_ttl] with
{all} = double[>= 0.0]

BIN
bin/back

Binary file not shown.

View File

@ -6,6 +6,7 @@ Blocks :
[13.0, 0.0, 13.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
Entities:
[0.0, 11.5, 0.0, 1.0, 1.0, 5.0, 0.0, 0.0, 255, 255, 255, 1, 0, 2, 0.0, 3.0, 0.0, 0.0, -2.0, 100]
[-0.5 , 2.0, -0.5 , 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 0 , 5, 0, 0]
[-11.0, 0.0, -1.0 , 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1 , 0, 6, welcome here, 222, 222, 222]
[9.0 , 0.0, -1.0 , 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 128, 1 , 0, 6, collect coins to advance, 222, 222, 111]

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
res/minecraft_lava.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -211,6 +211,24 @@ void math_block(double x, double y, double z, double w, double h, double d, doub
}
}
// metad1 = hz_speed (// to y)
// metad2 = vt_speed (// to x)
// metad7 = norm of HZ deviation
// metad8 = norm of VT deviation
// metai1 = dps
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) {
ret->hz_angle += ((double)dtime)*ent->metad1;
ret->vt_angle += ((double)dtime)*ent->metad2;
ret->x = ent->metad4+(ent->metad7)*cos(ret->hz_angle);
ret->y = ent->metad5+(ent->metad8)*sin(ret->vt_angle);
ret->z = ent->metad6+(ent->metad7)*sin(ret->hz_angle)+(ent->metad8)*cos(ret->vt_angle);
}
void lava_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
player_hp -= ent->metai1;
}
void active_math(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
if(ent->metad1 == 0.0) {
mathSignal = true;

View File

@ -19,8 +19,10 @@ void go_to_player(double x, double y, double z, double w, double h, double d, do
void subtitle_text_box(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 beating_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 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_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 update_button(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
void spinning_translate(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);

View File

@ -59,17 +59,17 @@ void init_ent_generator(int n) {
hashtbl_entities[1].onDeath = NULL;
hashtbl_entities[2].id = 2;
hashtbl_entities[2].tex = 13;
hashtbl_entities[2].tex2 = 13;
hashtbl_entities[2].name = "ExplosiveSeek";
hashtbl_entities[2].updatePos = &go_to_player;
hashtbl_entities[2].onHit = &explodeOnHit;
hashtbl_entities[2].tex = 14;
hashtbl_entities[2].tex2 = 14;
hashtbl_entities[2].name = "SpinningDamagingThing";
hashtbl_entities[2].updatePos = &lava_postStep;
hashtbl_entities[2].onHit = &lava_onHit;
hashtbl_entities[2].onDeath = NULL;
hashtbl_entities[3].id = 3;
hashtbl_entities[3].tex = 13;
hashtbl_entities[3].tex2 = 13;
hashtbl_entities[3].name = "ExplosiveShoot";
hashtbl_entities[3].name = "ExplosiveSeekShoot";
hashtbl_entities[3].updatePos = &speen2;
hashtbl_entities[3].onHit = &explodeOnHit;
hashtbl_entities[3].onDeath = NULL;
@ -452,7 +452,27 @@ void parse_one_room(int id, char* filename) {
pool[id].area->ents[k]->metad7 = entry->metad7;
pool[id].area->ents[k]->metad8 = entry->metad8;
pool[id].area->ents[k]->metad9 = entry->metad9;
if(entry->id == 3) {
if(entry->id == 2) {
// spinning damage
double hz_spd = read_float(ptr);
double vt_spd = read_float(ptr);
double offx = read_float(ptr);
double offy = read_float(ptr);
double offz = read_float(ptr);
int dps = read_int(ptr);
pool[id].area->ents[k]->metad1 = hz_spd;
pool[id].area->ents[k]->metad2 = vt_spd;
pool[id].area->ents[k]->metad4 = pool[id].area->ents[k]->pos->x - offx;
pool[id].area->ents[k]->metad5 = pool[id].area->ents[k]->pos->y - offy;
pool[id].area->ents[k]->metad6 = pool[id].area->ents[k]->pos->z - offz;
pool[id].area->ents[k]->metad7 = sqrt(offx*offx+offz*offz);
pool[id].area->ents[k]->metad8 = sqrt(offy*offy+offz*offz);
printf("--> %lf %lf <-- with %lf %lf %lf\n", pool[id].area->ents[k]->metad7, pool[id].area->ents[k]->metad8, offx, offy, offz);
pool[id].area->ents[k]->metai1 = dps;
} else if(entry->id == 3) {
// mine
double pspd = read_float(ptr);
double bspd = read_float(ptr);
double bfreq = read_float(ptr);

View File

@ -527,7 +527,7 @@ int main_alt() {
glEnableVertexAttribArray(1);
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
// 16 max //
// 32 max //
//generate_texture_2D(0, "res/container.jpg", "jpg");
generate_texture_2D(0, "res/white.png", PNG);
@ -548,6 +548,7 @@ int main_alt() {
generate_texture_2D(11, "res/button_off.jpg", JPG);
generate_texture_2D(12, "res/pi.png", PNG);
generate_texture_2D(13, "res/tnt.png", PNG);
generate_texture_2D(14, "res/minecraft_lava.jpg", JPG);
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);

View File

@ -13,6 +13,7 @@ Teleporters :
[9.0, 1.0, 4.0, 1.0, 4.0, 2.0, 0.0, 0.0, 0, 0, 255; 0, 1]
Entities :
[0.0, 11.5, 0.0, 5.0, 1.0, 1.0, 1.57, 0.0, 255, 255, 255, 1, 0, 2, 0.0, 3.0, 0.0, 3.0, 0.0, 100]
[1.0, -6.0, 3.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 1, 32, 1]
[1.0, -3.0, 3.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 1, 32, 3, 0.0, 4.0, 1.0, 1.0]
[-1.0, 13.0, -1.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.5, 1.5, 0]