added entity2 + added drag speeds (separate from the player's)

This commit is contained in:
Alexandre 2025-03-23 11:56:46 +01:00
parent 7d310d3f71
commit 09504a6b8a
20 changed files with 312 additions and 70 deletions

View File

@ -138,8 +138,15 @@ entities:
dmg = int (>0)
-> 16 (type 1 entity)
[.. speed, jump_height, dmg, kbPlayer, kbEntity] with
[.. speed, jump_height, dmg, kbPlayer, {buttonActivation}] with
all\{dmg} = double[>=0.0]
dmg = int (>=0)
buttonActivation = int[0-16]
-> 17 (type 2 entity)
[.. speed, jump_height, dmg, kbPlayer, kbEntity, {buttonActivation}] with
all\{dmg} = double[>=0.0]
dmg = int (>=0)
buttonActivation = int[0-16]
```

BIN
bin/back

Binary file not shown.

View File

@ -21,8 +21,8 @@ Blocks :
[ -2.0, 0.0, -2.0, 4.0, 2.0, 4.0, 0.0, 0.0, 192, 192, 192]
Entities :
[-5.0, 0.5, -5.0, 1.0, 2.0, 1.0, 0.0, 0.0, 64, 64, 64, 1, 0, 16, 2.5, 1.9, 0, 0.0, 0.0]
[ 4.0, 0.5, 4.0, 1.0, 2.0, 1.0, 0.0, 0.0, 64, 64, 64, 1, 0, 16, 2.5, 1.9, 0, 0.0, 0.0]
[-5.0, 0.5, -5.0, 1.0, 2.0, 1.0, 0.0, 0.0, 64, 64, 64, 1, 0, 17, 5.0, 1.9, 0, 12.0, 0.0]
[ 4.0, 0.5, 4.0, 1.0, 2.0, 1.0, 0.0, 0.0, 64, 64, 64, 1, 0, 17, 5.0, 1.9, 0, 12.0, 0.0]
[-1.0, 2.0, -1.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 32, 1, 0, 8, 250, 1, 255, 128, 128]
[-0.5, 2.5, -0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 32, 1, 0, 7, levels/level_05/, 5, impressive, 128, 255, 128]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -456,6 +456,15 @@ pt_2d rotate_to_y_axis(double x, double y, double z, double x0, double z0, int a
return res;
}
void normalize(pt_2d* p) {
double norm = sqrt(p->x*p->x + p->y*p->y + p->z*p->z);
if(norm >= 0.0001) {
p->x /= norm;
p->y /= norm;
p->z /= norm;
}
}
// ------------------------------------------------------------------------------------------------ //
void remove_entity(entity** arr, int* memlen, int* len, int index) {
@ -561,4 +570,20 @@ double read_float(FILE* ptr) {
//printf("%d, %d\n", ent, frac);
return sn0*((double)frac)/(pow(10.0, (double)ln_baseN(frac, 10)));
}
}
// RESET "\x1b[0m"
// RED "\033[38;2;192;40;40m"
// BLUE "\033[38;2;40;192;192m"
// GREEN "\033[38;2;192;255;0m"
// TREE "\033[38;2;20;180;20m"
// YELLOW "\033[38;2;255;255;40m"
// PURPLE "\033[38;2;250;12;250m"
// ORANGE "\033[38;2;250;120;0m"
// CYAN "\033[38;2;12;250;250m"
// GRAY "\033[38;2;192;192;192m"
// DARK "\033[38;2;128;128;128m"
// GRAYB "\033[1;38;2;192;192;192m"
void set_printf_color(const char* color) {
printf(color);
}

View File

@ -1,5 +1,19 @@
#ifndef BACK_BASE_H
#define BACK_BASE_H
#ifndef BASE_H
#define BASE_H
#define RESET "\x1b[0m"
#define RED "\033[38;2;192;40;40m"
#define BLUE "\033[38;2;40;192;192m"
#define GREEN "\033[38;2;192;255;0m"
#define TREE "\033[38;2;20;180;20m"
#define YELLOW "\033[38;2;160;160;40m"
#define PURPLE "\033[38;2;250;12;250m"
#define ORANGE "\033[38;2;250;120;0m"
#define CYAN "\033[38;2;12;250;250m"
#define GRAY "\033[38;2;192;192;192m"
#define DARK "\033[38;2;128;128;128m"
#define GRAYB "\033[1;38;2;192;192;192m"
void set_printf_color(const char* color);
int ln_baseN(int n, int b);
int pw(int x, int n);
@ -32,6 +46,7 @@ char* read_string(FILE* ptr);
pt_2d vect_diff(pt_2d p1, pt_2d p2);
double dot2D(pt_2d p1, pt_2d p2);
double dot3D(pt_2d p1, pt_2d p2);
void normalize(pt_2d* p);
cube_0* create_cube_0(double x, double y, double z, double w, double h, double d, double hz_a, double vt_a, int r, int g, int b);
void fill_cube_0(cube_0* cb, double x, double y, double z, double w, double h, double d, double hz_a, double vt_a, int r, int g, int b);

View File

@ -462,53 +462,157 @@ void movCrateButton_postStep(float dtime, entity* ent, cube_0* ret) {
}
}
void entity1_onHit(entity* ent, cube_0* ret) {
pt_2d direct = (pt_2d){.x = camx - ret->x-ret->w/2.0, .y = camy - ret->y-ret->h/2.0, .z = camz - ret->z-ret->d/2.0};
if(direct.x*direct.x + direct.y*direct.y + direct.z*direct.z >= 0.00001) {
normalize(&direct);
outvx = direct.x * ent->metad4;
//outvy = direct.y * ent->metad4;
outvz = direct.z * ent->metad4;
}
}
// metad1 = speed
// metad2 = jump height
// metad3 = vertical speed
// metad4 = knockback on hit (for player) [speed]
// metad5 = knockback on hit (for entity) [speed]
// metai1 = damage
// metai2 = isActivated (0/1)
// metai3 = trigger button (-1 if none)
void enemy1_postStep(float dtime, entity* ent, cube_0* ret) {
double dx = (camx - choffxE)-ret->x-ret->w/2.0;
ent->metad3 -= gravity_factor*dtime;
double dz = (camz - choffzE)-ret->z-ret->d/2.0;
double norm = sqrt(dx*dx + dz*dz);
dx = ent->metad1*dx/norm;
dz = ent->metad1*dz/norm;
if(ent->metai2) {
double dx = (camx - choffxE)-ret->x-ret->w/2.0;
ent->metad3 -= gravity_factor*dtime;
double dz = (camz - choffzE)-ret->z-ret->d/2.0;
double norm = sqrt(dx*dx + dz*dz);
dx = ent->metad1*dx/norm;
dz = ent->metad1*dz/norm;
bool hasCollisionXZ = false;
bool hasCollisionY = false;
bool hasCollisionXZ = false;
bool hasCollisionY = false;
ret->x += dtime*dx;
if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 16) || distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->x -= dtime*dx;
hasCollisionXZ = true;
}
ret->z += dtime*dz;
if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 16) || distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->z -= dtime*dz;
hasCollisionXZ = true;
}
ret->y += dtime*ent->metad3;
if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 16) || distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->x += dtime*dx;
if(distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->x -= dtime*dx;
player_hp -= ent->metai1;
entity1_onHit(ent, ret);
} else if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 16)) {
ret->x -= dtime*dx;
hasCollisionXZ = true;
hasCollisionY = true;
}
ret->y -= dtime*ent->metad3;
hasCollisionY = hasCollisionY || (ent->metad3 <= 0.0);
ent->metad3 = 0.0;
}
if(hasCollisionXZ && hasCollisionY) {
ent->metad3 += sqrt(2.0*gravity_factor*ent->metad2);
//printf("%lf\n", ent->metad3);
}
ret->z += dtime*dz;
if(distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->z -= dtime*dz;
player_hp -= ent->metai1;
entity1_onHit(ent, ret);
} else if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 16)) {
ret->z -= dtime*dz;
hasCollisionXZ = true;
}
if(ret->y <= -48.0) {
*(ent->hitpoints) = 0;
ret->y += dtime*ent->metad3;
if(distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->y -= dtime*ent->metad3;
player_hp -= ent->metai1;
entity1_onHit(ent, ret);
ent->metad3 = 0.0;
} else if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 16)) {
ret->y -= dtime*ent->metad3;
hasCollisionY = hasCollisionY || (ent->metad3 <= 0.0);
ent->metad3 = 0.0;
}
if(hasCollisionXZ && hasCollisionY) {
ent->metad3 += sqrt(2.0*gravity_factor*ent->metad2);
//printf("%lf\n", ent->metad3);
}
if(ret->y <= -48.0) {
*(ent->hitpoints) = 0;
}
} else if((choffxE == 0 && choffzE == 0) || (ent->metai3 != -1 && buttonSwitch[ent->metai3])) {
ent->metai2 = 1;
}
}
void entity2_onHit(entity* ent, cube_0* ret) {
pt_2d direct = (pt_2d){.x = camx - ret->x-ret->w/2.0, .y = camy - ret->y-ret->h/2.0, .z = camz - ret->z-ret->d/2.0};
if(direct.x*direct.x + direct.y*direct.y + direct.z*direct.z >= 0.00001) {
normalize(&direct);
outvx = direct.x * ent->metad3;
//outvy = direct.y * ent->metad4;
outvz = direct.z * ent->metad3;
}
}
// metad1 = speed
// metad2 = jump height
// metad3 = knockback on hit (for player) [speed]
// metad4 = knockback on hit (for entity) [speed]
// metad{5,6,7} = {x,y,z} speed
// metai1 = damage
// metai2 = isActivated (0/1)
// metai3 = trigger button (-1 if none)
void enemy2_postStep(float dtime, entity* ent, cube_0* ret) {
if(ent->metai2) {
double dx = (camx - choffxE)-ret->x-ret->w/2.0;
double dz = (camz - choffzE)-ret->z-ret->d/2.0;
double norm = sqrt(dx*dx + dz*dz);
dx = ent->metad1*dx/norm;
dz = ent->metad1*dz/norm;
ent->metad5 += dx*dtime;
ent->metad6 -= gravity_factor*dtime;
ent->metad7 += dz*dtime;
bool hasCollisionXZ = false;
bool hasCollisionY = false;
ret->x += dtime*ent->metad5;
if(distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->x -= dtime*ent->metad5;
ent->metad5 = 0.0;
player_hp -= ent->metai1;
entity2_onHit(ent, ret);
} else if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 17)) {
ret->x -= dtime*ent->metad5;
ent->metad5 = 0.0;
hasCollisionXZ = true;
}
ret->z += dtime*ent->metad7;
if(distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->z -= dtime*ent->metad7;
ent->metad7 = 0.0;
player_hp -= ent->metai1;
entity2_onHit(ent, ret);
} else if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 17)) {
ret->z -= dtime*ent->metad7;
ent->metad7 = 0.0;
hasCollisionXZ = true;
}
ret->y += dtime*ent->metad6;
if(distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist) {
ret->y -= dtime*ent->metad6;
player_hp -= ent->metai1;
entity2_onHit(ent, ret);
ent->metad6 = 0.0;
} else if(is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp2(ret, 10, 17)) {
ret->y -= dtime*ent->metad6;
hasCollisionY = hasCollisionY || (ent->metad6 <= 0.0);
ent->metad6 = 0.0;
}
if(hasCollisionXZ && hasCollisionY) {
ent->metad6 += sqrt(2.0*gravity_factor*ent->metad2);
//printf("%lf\n", ent->metad3);
}
if(ret->y <= -48.0) {
*(ent->hitpoints) = 0;
}
} else if((choffxE == 0 && choffzE == 0) || (ent->metai3 != -1 && buttonSwitch[ent->metai3])) {
ent->metai2 = 1;
}
}

View File

@ -28,6 +28,7 @@ void lava_postStep(float dtime, entity* ent, cube_0* ret);
void movableCrate_postStep(float dtime, entity* ent, cube_0* ret);
void movCrateButton_postStep(float dtime, entity* ent, cube_0* ret);
void enemy1_postStep(float dtime, entity* ent, cube_0* ret);
void enemy2_postStep(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);

View File

@ -177,6 +177,14 @@ void init_ent_generator(int n) {
hashtbl_entities[16].updatePos = &enemy1_postStep;
hashtbl_entities[16].onHit = NULL;
hashtbl_entities[16].onDeath = NULL;
hashtbl_entities[17].id = 17;
hashtbl_entities[17].tex = 14;
hashtbl_entities[17].tex2 = 14;
hashtbl_entities[17].name = "ennemy2";
hashtbl_entities[17].updatePos = &enemy2_postStep;
hashtbl_entities[17].onHit = NULL;
hashtbl_entities[17].onDeath = NULL;
}
fct_entry* get_entry(int k0) {
@ -770,14 +778,53 @@ void parse_one_room(int id, char* filename) {
double height = read_float(ptr);
int damage = read_int(ptr);
double kb_player = read_float(ptr);
double kb_entity = read_float(ptr);
int buttonTrig = -1;
doAlign = exists_optionnal(ptr, '{', '\n');
if(doAlign) {
buttonTrig = read_int(ptr);
if(buttonTrig < 0 || buttonTrig >= 16) {
fprintf(stderr, "warning : invalid button %d, using 0 instead\n", buttonTrig);
buttonTrig = 0;
}
}
pool[id].area->ents[k]->metad1 = speed;
pool[id].area->ents[k]->metad2 = height;
pool[id].area->ents[k]->metad3 = 0.0;
pool[id].area->ents[k]->metad4 = kb_player;
pool[id].area->ents[k]->metad5 = kb_entity;
pool[id].area->ents[k]->metai1 = damage;
pool[id].area->ents[k]->metai2 = 0;
pool[id].area->ents[k]->metai3 = buttonTrig;
} else if(entry->id == 17) {
// entity2
double speed = read_float(ptr);
double height = read_float(ptr);
int damage = read_int(ptr);
double kb_player = read_float(ptr);
double kb_entity = read_float(ptr);
int buttonTrig = -1;
doAlign = exists_optionnal(ptr, '{', '\n');
if(doAlign) {
buttonTrig = read_int(ptr);
if(buttonTrig < 0 || buttonTrig >= 16) {
fprintf(stderr, "warning : invalid button %d, using 0 instead\n", buttonTrig);
buttonTrig = 0;
}
}
pool[id].area->ents[k]->metad1 = speed;
pool[id].area->ents[k]->metad2 = height;
pool[id].area->ents[k]->metad3 = kb_player;
pool[id].area->ents[k]->metad4 = kb_entity;
pool[id].area->ents[k]->metad5 = 0.0;
pool[id].area->ents[k]->metad6 = 0.0;
pool[id].area->ents[k]->metad7 = 0.0;
pool[id].area->ents[k]->metai1 = damage;
pool[id].area->ents[k]->metai2 = 0;
pool[id].area->ents[k]->metai3 = buttonTrig;
} else {
pool[id].area->ents[k]->metai3 = 0;
}
@ -869,6 +916,7 @@ void generate_nearby_chunks(int render_dist) {
for(int w = -render_dist; w <= render_dist; w++) {
for(int h = -render_dist; h <= render_dist; h++) {
if(!hashtbl_mem(visited, player_chx + w, player_chy + h)) {
set_printf_color(YELLOW);
printf("generating (%d, %d)... ", player_chx + w, player_chy + h); fflush(stdout);
//build_starting_chunk(player_chx + w, player_chy + h);
int pick = rand()%(abs(total_weight));
@ -881,7 +929,9 @@ void generate_nearby_chunks(int render_dist) {
for(int k = 0; k < pool_size; k++) {
sum += pool[k].weight;
if(pick < sum) {
set_printf_color(GREEN);
printf("chose %d\n", k); fflush(stdout);
set_printf_color(RESET);
has_spawned = true;
room* new = malloc(sizeof(room));
copy_room(pool[k].area, new, player_chx + w, player_chy + h);
@ -891,7 +941,9 @@ void generate_nearby_chunks(int render_dist) {
}
}
if(!has_spawned) {
set_printf_color(CYAN);
printf("chose NULL\n"); fflush(stdout);
set_printf_color(RESET);
hashtbl_add(visited, player_chx + w, player_chy + h, NULL);
}
printf("Done\n");

View File

@ -74,9 +74,9 @@ void reset_everything(GLFWwindow *window, int count, char* folder) {
player_chx = 0;
player_chy = 0;
camvx = 0.0;
camvy = 0.0;
camvz = 0.0;
camvx = 0.0; outvx = 0.0;
camvy = 0.0; outvy = 0.0;
camvz = 0.0; outvz = 0.0;
printf("-------------------------------- resetting hashtbl... --------------------------------\n");
fflush(stdout);
@ -125,7 +125,6 @@ void reset_everything(GLFWwindow *window, int count, char* folder) {
printf("-------------------------------- Done 4 --------------------------------\n");
fflush(stdout);
interface_set(-1);
generate_nearby_chunks(1);
@ -143,6 +142,7 @@ void reset_everything(GLFWwindow *window, int count, char* folder) {
current_room = hashtbl_find_opt(visited, 0, 0);
}
}
interface_set(-1);
}
void processInput(GLFWwindow *window, float dtime) {

View File

@ -56,6 +56,10 @@ double camx;
double camy;
double camz;
double outvx;
double outvy;
double outvz;
double camvx;
double camvy;
double camvz;
@ -91,9 +95,9 @@ void init_csts() {
camz = 2.0;
player_chx = 0;
player_chy = 0;
camvx = 0.0;
camvy = 0.0;
camvz = 0.0;
camvx = 0.0; outvx = 0.0;
camvy = 0.0; outvy = 0.0;
camvz = 0.0; outvz = 0.0;
rot_hz = 0.0;
rot_vt = 0.0;
@ -212,13 +216,6 @@ pt_2d cross_product(pt_2d p1, pt_2d p2) {
};
}
void normalize(pt_2d* p) {
double norm = sqrt(p->x*p->x + p->y*p->y + p->z*p->z);
p->x /= norm;
p->y /= norm;
p->z /= norm;
}
void debugMove(cube_0* cb) {
for(int d = 0; d < 6; d++) {
cb->x -= min_dist;
@ -334,16 +331,25 @@ void updateF(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("-----------------------------------------------------------------------------------------------\n");
//printf("%d\n", d);
double normv = sqrt(camvx*camvx + camvy*camvy + camvz*camvz);
double normv = sqrt(camvx*camvx + camvy*camvy + camvz*camvz);
double normvB = sqrt(outvx*outvx + outvy*outvy + outvz*outvz);
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));
double alpha = acos(dot3D(normal, (pt_2d){.x = camvx, .y = camvy, .z = camvz})/normv);
double alphaB = acos(dot3D(normal, (pt_2d){.x = outvx, .y = outvy, .z = outvz})/maxd(0.001, normvB));
pt_2d u = (pt_2d){.x = normal.x*nu, .y = normal.y*nu, .z = normal.z*nu};
double beta = 3.1415926535 - 2*alpha;
double betaB = 3.1415926535 - 2*alphaB;
double nu = normv*sqrt(1-cos(beta));
double nuB = normvB*sqrt(1-cos(betaB));
pt_2d u = (pt_2d){.x = normal.x*nu, .y = normal.y*nu, .z = normal.z*nu};
pt_2d uB = (pt_2d){.x = normal.x*nuB, .y = normal.y*nuB, .z = normal.z*nuB};
normalize(&u);
normalize(&uB);
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
@ -372,13 +378,31 @@ void updateF(cube_0* cb, double dtime, entity* ent) {
//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 = u.x*normv*(blockRestitution) + utheta.x*radspeed + utheta2.x*radspeed2;
camvy = u.y*normv*(blockRestitution) + utheta.y*radspeed + utheta2.y*radspeed2;
camvz = u.z*normv*(blockRestitution) + utheta.z*radspeed + utheta2.z*radspeed2;
if(normv >= 0.0001 && nu >= 0.0001) { // no NaN
camvx = u.x*normv*(blockRestitution) + utheta.x*radspeed + utheta2.x*radspeed2;
camvy = u.y*normv*(blockRestitution) + utheta.y*radspeed + utheta2.y*radspeed2;
camvz = u.z*normv*(blockRestitution) + utheta.z*radspeed + utheta2.z*radspeed2;
}
if(normvB >= 0.0001 && nuB > 0.001) { // no NaN
//printf("%lf / %lf %lf %lf || %lf %lf %lf |||\n", normvB, alphaB, betaB, nuB, uB.x, uB.y, uB.z);
outvx = uB.x*normvB*(blockRestitution) + utheta.x*radspeed + utheta2.x*radspeed2;
outvy = uB.y*normvB*(blockRestitution) + utheta.y*radspeed + utheta2.y*radspeed2;
outvz = uB.z*normvB*(blockRestitution) + utheta.z*radspeed + utheta2.z*radspeed2;
}
} else {
camvx = u.x*normv*(blockRestitution);
camvy = u.y*normv*(blockRestitution);
camvz = u.z*normv*(blockRestitution);
if(normv >= 0.0001 && nu >= 0.0001) { // no NaN
camvx = u.x*normv*(blockRestitution);
camvy = u.y*normv*(blockRestitution);
camvz = u.z*normv*(blockRestitution);
}
if(normvB >= 0.0001 && nuB > 0.001) { // no NaN
//printf("%lf / %lf %lf %lf || %lf %lf %lf |||\n", normvB, alphaB, betaB, nuB, uB.x, uB.y, uB.z);
outvx = uB.x*normvB*(blockRestitution);
outvy = uB.y*normvB*(blockRestitution);
outvz = uB.z*normvB*(blockRestitution);
}
}
is_clipping = false;
@ -611,14 +635,20 @@ void movePlayerG(float dtime) {
player_hp -= (int)(0.75*absf(oldvy));
}
}
camx += camvx*dtime;
camy += camvy*dtime;
camz += camvz*dtime;
camx += (camvx+outvx)*dtime;
camy += (camvy+outvy)*dtime;
camz += (camvz+outvz)*dtime;
camvx *= (1.0 - friction*((double)(dtime)));
camvy *= (1.0 - friction*((double)(dtime)));
camvz *= (1.0 - friction*((double)(dtime)));
outvx *= (1.0 - mind(5.0*friction*((double)(dtime)), 1.0));
outvy *= (1.0 - mind(5.0*friction*((double)(dtime)), 1.0));
outvz *= (1.0 - mind(5.0*friction*((double)(dtime)), 1.0));
//printf("%lf %lf %lf ; %lf %lf %lf\n", camvx, camvy, camvz, outvx, outvy, outvz);
if(camy <= -48) {
camx = 0.0;
camz = 0.0;
@ -626,6 +656,10 @@ void movePlayerG(float dtime) {
camvx = 0.0;
camvy = 0.0;
camvz = 0.0;
outvx = 0.0;
outvy = 0.0;
outvz = 0.0;
player_chx = 0;
player_chy = 0;
if(is_HR==1) {

View File

@ -110,6 +110,10 @@ extern double camx;
extern double camy;
extern double camz;
extern double outvx;
extern double outvy;
extern double outvz;
extern double camvx;
extern double camvy;
extern double camvz;