Compare commits

..

No commits in common. "f09196df7fd0f8c8bec39843ca93629b0ac12a99" and "8c38e0fe78337b20049b03d8755ed738f638f52e" have entirely different histories.

9 changed files with 13 additions and 147 deletions

BIN
bin/back

Binary file not shown.

View File

@ -88,7 +88,7 @@ Entities:
[-14.0, 21.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 5.0, 0.0, 4.0, 3, 7, 0] // button part
[-18.0, 22.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 5.0, 0.0, -4.0, 3, 7, 90]
[ -4.0, 20.0,-14.0, 2.0, 2.0, 14.0, 0.0, 0.0, 192, 192, 192, 1, 0, 12, 1, 0]
[-33.0, 24.0, 18.0, 2.0, 2.0, 2.0, 0.71, 0.0, 92, 92, 92, 1, 0, 11, 1, 30.0]
[-33.0, 24.0, 18.0, 2.0, 2.0, 2.0, 0.71, 0.0, 92, 92, 92, 1, 0, 11, 1, 10.0]
[-5.0, 20.0, -18.0, 4.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 10.0, 0.0, 0.0, 3, 4, 0, {1, 1}] // 3 - platforms

View File

@ -19,8 +19,7 @@ Blocks:
Entities:
[-5.5, 4.0, -0.5, 2.5, 1.0, 5.0, 0.0, 0.0, 255, 255, 255, 1, 0, 2, 0.0, 25.0, 0.0, 0.0, 2.0, 0]
[-1.0, 4.0, -0.5, 2.5, 1.0, 5.0, 0.0, 0.0, 255, 255, 255, 1, 0, 2, 0.0, -25.0, 0.0, 0.0, 2.0, 0]
[-4.0, 4.0, -0.5, 4.0, 1.0, 5.0, 0.0, 0.0, 255, 255, 255, 1, 0, 2, 0.0, 25.0, 0.0, 0.0, 2.0, 0]
[-16.0, 0.0, -16.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 192, 1, 0, 6, yeet, 255, 255, 255]
[12.0, 0.0, 12.0, 4.0, 4.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 8, 200, 1, 64, 64, 64]

View File

@ -41,10 +41,6 @@ Entities:
[ -1.9, 0.1, 2.1, 3.8, 3.8, 3.8, 0.0, 0.0, 192, 129, 192, 1, 0, 10, 0.98, 1.0]
[ 6.1, 0.1, 2.1, 3.8, 3.8, 3.8, 0.0, 0.0, 192, 129, 192, 1, 0, 10, 0.98, 1.0]
[-16.0, 0.0, -0.3, 32.0, 0.3, 0.6, 0.0, 0.0, 192, 192, 192, 1,0, 2, 1.4, 0.0, 0.0, 0.0, 0.0, 5]
[-0.3, 1.2, -16.0, 0.6, 0.3, 32.0, 0.0, 0.0, 192, 192, 192, 1,0, 2, 1.4, 0.0, 0.0, 0.0, 0.0, 5]
[-3.0, 10.0, -3.0, 6.0, 1.0, 6.0, 0.0, 0.0, 192, 192, 192, 1, 0, 2, 1.0, 0.0, 0.0, 0.0, 0.0, 0]
[ -9.0, 0.0, 7.0, 2.0, 0.2, 2.0, 0.0, 0.0, 192, 129, 192, 1, 0, 14, 0] // keys
[ -5.0, 0.0, 7.0, 2.0, 0.2, 2.0, 0.0, 0.0, 192, 129, 192, 1, 0, 14, 1]
[ 3.0, 0.0, -9.0, 2.0, 0.2, 2.0, 0.0, 0.0, 192, 129, 192, 1, 0, 14, 2]

Binary file not shown.

Binary file not shown.

View File

@ -268,15 +268,14 @@ void lava_postStep(double x, double y, double z, double w, double h, double d, d
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);
if(distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
/*ret->hz_angle -= ((double)dtime)*ent->metad1;
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);*/
//printf("DDDD\n");
movingPlatformUpdate = ent;
doUpdateMoving = true;
ret->z = ent->metad6+(ent->metad7)*sin(ret->hz_angle)+(ent->metad8)*cos(ret->vt_angle);
updateF(ret, (double)dtime, ent);
}
}
@ -356,8 +355,6 @@ void movCrateButton_postStep(double x, double y, double z, double w, double h, d
void movableCrate_onHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
//printf("(+%lf, +%lf)\n", camvx, camvz);
//entToVelCheck = ent;
//doUpdateEntVel = true;
updateF_movableCrate(ret, (double)dtime, ent);
}

View File

@ -32,12 +32,6 @@ double gravity_factor = 26.0;
const double blockRestitution = 0.2;
entity* entToVelCheck = NULL;
bool doUpdateEntVel = false;
entity* movingPlatformUpdate = NULL;
bool doUpdateMoving = false;
bool is_clipping = false;
int clip_dps = 500;
@ -298,10 +292,6 @@ void updateF_movableCrate(cube_0* cb, double dtime, entity* ent) {
}
}
pt_2d normal_axis = {.x = 0.0, .y = 1.0, .z = 0.0};
pt_2d normal_axis2 = {.x = 1.0, .y = 0.0, .z = 0.0};
// rotation axis
void updateF(cube_0* cb, double dtime, entity* ent) {
for(int d = 0; d < 6; d++) {
cb->x -= min_dist;
@ -354,22 +344,19 @@ void updateF(cube_0* cb, double dtime, entity* ent) {
camD.x = camx - ent->pos->w/2.0 - ent->metad4;
camD.y = 0.0;
camD.z = camz - ent->pos->d/2.0 - ent->metad6;
if(camD.x*camD.x + camD.y*camD.y + camD.z*camD.z >= 0.001) { // avoid division by 0.0
if(camD.x*camD.x + camD.y*camD.y + camD.z*camD.z != 0.0) { // avoid division by 0.0
normalize(&camD);
}
pt_2d utheta = cross_product(camD, normal_axis);
pt_2d utheta = cross_product(camD, normal);
pt_2d camD2;
camD2.x = 0.0;
camD2.y = camy - ent->pos->h/2.0 - ent->metad5;
camD2.z = camz - ent->pos->d/2.0 - ent->metad6;
if(camD2.x*camD2.x + camD2.y*camD2.y + camD2.z*camD2.z >= 0.001) { // avoid division by 0.0
if(camD2.x*camD2.x + camD2.y*camD2.y + camD2.z*camD2.z != 0.0) { // avoid division by 0.0
normalize(&camD2);
}
pt_2d utheta2 = cross_product(camD2, normal_axis2);
//printf("(HZ) %lf %lf %lf\n", utheta.x*radspeed , utheta.y*radspeed , utheta.z*radspeed );
//printf("(VT) %lf %lf %lf\n\n", utheta2.x*radspeed2, utheta2.y*radspeed2, utheta2.z*radspeed2);
pt_2d utheta2 = normal;//cross_product(camD2, normal);
camvx = u.x*normv*(blockRestitution) + utheta.x*radspeed + utheta2.x*radspeed2;
camvy = u.y*normv*(blockRestitution) + utheta.y*radspeed + utheta2.y*radspeed2;
@ -385,99 +372,8 @@ void updateF(cube_0* cb, double dtime, entity* ent) {
}
}
void updateF_specific(cube_0* cb, double dtime, entity* ent) {
double dilat = distance_pt_cube_0_3d_infinite(camx, camy, camz, cb);
for(int d = 0; d < 6; d++) {
// force a collision
cb->x -= dilat;
cb->y -= dilat;
cb->z -= dilat;
getSF(cb, d);
cb->x += dilat;
cb->y += dilat;
cb->z += dilat;
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)
) {
double normv = sqrt(camvx*camvx + camvy*camvy + camvz*camvz);
double alpha = acos(dot3D(normal, (pt_2d){.x = camvx, .y = camvy, .z = camvz})/normv);
double beta = 3.1415926535 - 2*alpha;
double nu = normv*sqrt(1-cos(beta));
pt_2d u = (pt_2d){.x = normal.x*nu, .y = normal.y*nu, .z = normal.z*nu};
normalize(&u);
camvx = u.x*normv*(blockRestitution);
camvy = u.y*normv*(blockRestitution);
camvz = u.z*normv*(blockRestitution);
is_clipping = false;
}
}
if(ent != NULL && ent->entity_type == 2) {
double radspeed = distance_pt_pt_3d(camx, camy, camz, ent->metad4+ent->pos->w/2.0, camy, ent->metad6+ent->pos->d/2.0
)*(ent->metad1);
double radspeed2 = distance_pt_pt_3d(camx, camy, camz, camx, ent->metad5+ent->pos->h/2.0, ent->metad6+ent->pos->d/2.0
)*(ent->metad2);
pt_2d camD;
camD.x = camx - ent->pos->w/2.0 - ent->metad4;
camD.y = 0.0;
camD.z = camz - ent->pos->d/2.0 - ent->metad6;
if(camD.x*camD.x + camD.y*camD.y + camD.z*camD.z >= 0.001) { // avoid division by 0.0
normalize(&camD);
}
pt_2d utheta = cross_product(camD, normal_axis);
pt_2d camD2;
camD2.x = 0.0;
camD2.y = camy - ent->pos->h/2.0 - ent->metad5;
camD2.z = camz - ent->pos->d/2.0 - ent->metad6;
if(camD2.x*camD2.x + camD2.y*camD2.y + camD2.z*camD2.z >= 0.001) { // avoid division by 0.0
normalize(&camD2);
}
pt_2d utheta2 = cross_product(camD2, normal_axis2);
//printf("(HZ) %lf %lf %lf\n", utheta.x*radspeed , utheta.y*radspeed , utheta.z*radspeed );
//printf("(VT) %lf %lf %lf\n\n", utheta2.x*radspeed2, utheta2.y*radspeed2, utheta2.z*radspeed2);
camvx = utheta.x*radspeed + utheta2.x*radspeed2;
camvy = utheta.y*radspeed + utheta2.y*radspeed2;
camvz = utheta.z*radspeed + utheta2.z*radspeed2;
}
//printf("\n");
}
bool update_physics = true;
bool is_colliding(float dtime) {
bool globalCollision = false;
if(doUpdateEntVel) {
updateF_movableCrate(entToVelCheck->pos, (double)dtime, entToVelCheck);
doUpdateEntVel = false;
}
if(doUpdateMoving) {
updateF_specific(movingPlatformUpdate->pos, (double)dtime, movingPlatformUpdate);
doUpdateMoving = false;
}
for(int w = -1; w <= 1; w++) {
for(int h = -1; h <= 1; h++) {
room* vstd = hashtbl_find_opt(visited, player_chx+w, player_chy+h);
@ -488,7 +384,7 @@ bool is_colliding(float dtime) {
// printf("(%lf)\n", dist);
//}
if(dist <= min_dist) {
if(update_physics && updateForces) {
if(updateForces) {
updateF(vstd->map[k], (double)dtime, NULL);
}
globalCollision = true;
@ -498,7 +394,7 @@ bool is_colliding(float dtime) {
for(int k = 0; k < vstd->tps_size; k++) {
double dist = distance_pt_cube_0_3d_infinite(camx-2*room_width*w, camy, camz-2*room_depth*h, vstd->tps[k]->hitbox);
if(dist <= min_dist) {
if(update_physics && updateForces) {
if(updateForces) {
updateF(vstd->tps[k]->hitbox, (double)dtime, NULL);
}
int old_chx = player_chx;
@ -538,7 +434,7 @@ bool is_colliding(float dtime) {
k =- 1;
}
}
if(update_physics && exists && updateForces && vstd->ents[k]->entity_type != 0) {
if(exists && updateForces && vstd->ents[k]->entity_type != 0) {
updateF(vstd->ents[k]->pos, (double)dtime, vstd->ents[k]);
}
if(exists && (
@ -559,15 +455,7 @@ bool is_colliding(float dtime) {
return globalCollision;
}
double old_camx = 0.0;
double old_camy = 0.0;
double old_camz = 0.0;
void movePlayerG(float dtime) {
old_camx = camx;
old_camy = camy;
old_camz = camz;
updateForces = true;
fx = 0.0;
fy = 0.0;
@ -585,7 +473,6 @@ void movePlayerG(float dtime) {
camy += dely;
camz += delz;
is_clipping = true;
update_physics = true;
if(is_colliding(dtime)) {
if(is_clipping) {
//player_hp -= (dtime)*clip_dps;
@ -635,13 +522,6 @@ void movePlayerG(float dtime) {
current_room = hashtbl_find_opt(visited, player_chx, player_chy);
resetProj();
}
update_physics = false;
if(is_colliding(dtime)) {
camx = old_camx;
camy = old_camy;
camz = old_camz;
}
}
void teleport_on_edge() {

View File

@ -204,12 +204,6 @@ extern bool mathSignal;
extern int mathSigCD;
extern mathRes mathResult;
extern entity* entToVelCheck;
extern bool doUpdateEntVel;
extern entity* movingPlatformUpdate;
extern bool doUpdateMoving;
extern int creativeWarpTarget;
extern int creativeIntID;