added spinning platforms + small rework of physics related to moving platforms + fixed culling
This commit is contained in:
parent
ee270cdbed
commit
e17ebbffd4
|
@ -20,6 +20,7 @@
|
||||||
"limits.h": "c",
|
"limits.h": "c",
|
||||||
"png.h": "c",
|
"png.h": "c",
|
||||||
"stdlib.h": "c",
|
"stdlib.h": "c",
|
||||||
"stb_image.h": "c"
|
"stb_image.h": "c",
|
||||||
|
"string.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
24
README.md
24
README.md
|
@ -24,38 +24,42 @@ entities:
|
||||||
|> if entityType >= 4, use 1 for HP and 0 for damage <|
|
|> if entityType >= 4, use 1 for HP and 0 for damage <|
|
||||||
|> *Entity types are :* <|
|
|> *Entity types are :* <|
|
||||||
|
|
||||||
-> **0 (coin)** -> damage equals the coin's value
|
-> 0 (coin) -> damage equals the coin's value
|
||||||
-> **1 (non-moving explosive)**
|
-> 1 (non-moving explosive)
|
||||||
-> **2 (seeking explosive)**
|
-> 2 (seeking explosive)
|
||||||
-> **3 (shooting non-moving explosive)**
|
-> 3 (shooting non-moving explosive)
|
||||||
-> **4 (moving platform)**
|
-> 4 (moving platform)
|
||||||
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd, phase] with *<- extra arguments at the end of []*
|
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd, phase] with *<- extra arguments at the end of []*
|
||||||
amplitude_{x,y,z} = double[>= 0.0]
|
amplitude_{x,y,z} = double[>= 0.0]
|
||||||
{mult,divd} = int
|
{mult,divd} = int
|
||||||
{phase} = int[0, 360]
|
{phase} = int[0, 360]
|
||||||
|
|
||||||
-> **5 (linear moving platform)**
|
-> 5 (linear moving platform)
|
||||||
[.. amplitude_x, amplitude_y, amplitude_z, speed_x, speed_y, speed_z] with
|
[.. amplitude_x, amplitude_y, amplitude_z, speed_x, speed_y, speed_z] with
|
||||||
amplitude_{x,y,z} = double[>= 0.0]
|
amplitude_{x,y,z} = double[>= 0.0]
|
||||||
speed_{x,y,z} = double
|
speed_{x,y,z} = double
|
||||||
|
|
||||||
-> **6 (text box)**
|
-> 6 (text box)
|
||||||
[.. text, tred, tgreen, tblue] with
|
[.. text, tred, tgreen, tblue] with
|
||||||
text = {char*}
|
text = {char*}
|
||||||
|
|
||||||
-> **7 (warp text box)**
|
-> 7 (warp text box)
|
||||||
[.. dest_folder, room_count, text, tred, tgreen, tblue] with
|
[.. dest_folder, room_count, text, tred, tgreen, tblue] with
|
||||||
{dest_folder,text} = {char*} (length <= 50)
|
{dest_folder,text} = {char*} (length <= 50)
|
||||||
{r,g,b} = int[0-256]
|
{r,g,b} = int[0-256]
|
||||||
|
|
||||||
|
|
||||||
-> **8 (lock box)**
|
-> 8 (lock box)
|
||||||
[.. cost, doPay, tred, tgreen, tblue] with
|
[.. cost, doPay, tred, tgreen, tblue] with
|
||||||
cost = int[> 0] (0 breaks)
|
cost = int[> 0] (0 breaks)
|
||||||
doPay = {0, 1} (bool)
|
doPay = {0, 1} (bool)
|
||||||
|
|
||||||
-> 9 (beat block)**
|
-> 9 (beat block)
|
||||||
[.. ontime, offtime, start] with
|
[.. ontime, offtime, start] with
|
||||||
{ontime,offtime} = double[>0.0]
|
{ontime,offtime} = double[>0.0]
|
||||||
start = {0,1}
|
start = {0,1}
|
||||||
|
|
||||||
|
-> 10 (spinning platform)
|
||||||
|
[.. hz_speed, vt_speed] with
|
||||||
|
{hz_speed,vt_speed} = double
|
||||||
```
|
```
|
|
@ -4,6 +4,7 @@ Blocks :
|
||||||
[-1.0, 0.0, 13.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
[-1.0, 0.0, 13.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
||||||
[-15.0, 0.0, -1.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
[-15.0, 0.0, -1.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
||||||
[13.0, 0.0, -1.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
[13.0, 0.0, -1.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
||||||
|
[-5.0, 0.0, -5.0, 10.0, 1.0, 10.0, 0.0, 0.0, 128, 128, 128]
|
||||||
|
|
||||||
Entities:
|
Entities:
|
||||||
[-2.0, 5.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 4, 0.0, 3.0, 0.0, 4, 1, 0]
|
[-2.0, 5.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 4, 0.0, 3.0, 0.0, 4, 1, 0]
|
||||||
|
|
|
@ -4,6 +4,11 @@ Blocks :
|
||||||
[-15.0, 0.0, 13.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
[-15.0, 0.0, 13.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
||||||
[13.0, 0.0, -15.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
[13.0, 0.0, -15.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
||||||
[13.0, 0.0, 13.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
[13.0, 0.0, 13.0, 2.0, 10.0, 2.0, 0.0, 0.0, 128, 128, 128]
|
||||||
|
[-5.0, 0.0, -5.0, 10.0, 1.0, 10.0, 0.0, 0.0, 128, 128, 128]
|
||||||
|
[-10.0, 7.0, -2.0, 4.0, 1.0, 4.0, 0.785, 0.0, 128, 128, 128]
|
||||||
|
[6.0, 7.0, -2.0, 4.0, 1.0, 4.0, 0.785, 0.0, 128, 128, 128]
|
||||||
|
[-2.0, 7.0, -10.0, 4.0, 1.0, 4.0, 0.785, 0.0, 128, 128, 128]
|
||||||
|
[-2.0, 7.0, 6.0, 4.0, 1.0, 4.0, 0.785, 0.0, 128, 128, 128]
|
||||||
|
|
||||||
Entities:
|
Entities:
|
||||||
[-2.0, 5.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 5, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0]
|
[-2.0, 5.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 5, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0]
|
||||||
|
|
|
@ -7,6 +7,7 @@ Blocks :
|
||||||
[15.0, 15.0, -1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192]
|
[15.0, 15.0, -1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192]
|
||||||
[-1.0, 15.0, -16.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
[-1.0, 15.0, -16.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
||||||
[-1.0, 15.0, 15.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
[-1.0, 15.0, 15.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
||||||
|
[-1.5, 0.0, -1.5, 3.0, 1.0, 3.0, 0.0, 0.0, 192, 192, 192]
|
||||||
|
|
||||||
Entities :
|
Entities :
|
||||||
[-2.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[-2.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
|
|
|
@ -7,6 +7,7 @@ Blocks :
|
||||||
[15.0, 15.0, -1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192]
|
[15.0, 15.0, -1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192]
|
||||||
[-1.0, 15.0, -16.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
[-1.0, 15.0, -16.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
||||||
[-1.0, 15.0, 15.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
[-1.0, 15.0, 15.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
||||||
|
[-1.5, 0.0, -1.5, 3.0, 1.0, 3.0, 0.0, 0.0, 192, 192, 192]
|
||||||
|
|
||||||
Entities :
|
Entities :
|
||||||
[-2.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[-2.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
|
|
|
@ -7,6 +7,7 @@ Blocks :
|
||||||
[15.0, 15.0, -1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192]
|
[15.0, 15.0, -1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192]
|
||||||
[-1.0, 15.0, -16.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
[-1.0, 15.0, -16.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
||||||
[-1.0, 15.0, 15.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
[-1.0, 15.0, 15.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
||||||
|
[-1.5, 0.0, -1.5, 3.0, 1.0, 3.0, 0.0, 0.0, 192, 192, 192]
|
||||||
|
|
||||||
Entities :
|
Entities :
|
||||||
[-2.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[-2.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
|
|
|
@ -7,6 +7,7 @@ Blocks :
|
||||||
[15.0, 15.0, -1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192]
|
[15.0, 15.0, -1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192]
|
||||||
[-1.0, 15.0, -16.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
[-1.0, 15.0, -16.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
||||||
[-1.0, 15.0, 15.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
[-1.0, 15.0, 15.0, 2.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192]
|
||||||
|
[-1.5, 0.0, -1.5, 3.0, 1.0, 3.0, 0.0, 0.0, 192, 192, 192]
|
||||||
|
|
||||||
Entities :
|
Entities :
|
||||||
[-2.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[-2.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
|
|
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/main.o
BIN
obj/main.o
Binary file not shown.
BIN
obj/move.o
BIN
obj/move.o
Binary file not shown.
|
@ -133,8 +133,8 @@ void gl_renderCube(unsigned int shaderProgram, unsigned int fragmentShader, unsi
|
||||||
scale[1][1] = (float)(c->h);
|
scale[1][1] = (float)(c->h);
|
||||||
scale[2][2] = (float)(c->d);
|
scale[2][2] = (float)(c->d);
|
||||||
glm_translate(model, (vec3){(float)(c->x+c->w/2.0+offx), (float)(c->y+c->h/2.0+offy), (float)(c->z+c->d/2.0+offz)});
|
glm_translate(model, (vec3){(float)(c->x+c->w/2.0+offx), (float)(c->y+c->h/2.0+offy), (float)(c->z+c->d/2.0+offz)});
|
||||||
glm_rotate(model, (float)(-c->hz_angle), (vec3){0.0f, 1.0f, 0.0f});
|
|
||||||
glm_rotate(model, (float)(c->vt_angle), (vec3){1.0f, 0.0f, 0.0f});
|
glm_rotate(model, (float)(c->vt_angle), (vec3){1.0f, 0.0f, 0.0f});
|
||||||
|
glm_rotate(model, (float)(c->hz_angle), (vec3){0.0f, 1.0f, 0.0f});
|
||||||
|
|
||||||
glUniformMatrix4fv(loc_scale, 1, GL_FALSE, (float*)scale);
|
glUniformMatrix4fv(loc_scale, 1, GL_FALSE, (float*)scale);
|
||||||
glUniformMatrix4fv(loc_model, 1, GL_FALSE, (float*)model);
|
glUniformMatrix4fv(loc_model, 1, GL_FALSE, (float*)model);
|
||||||
|
@ -151,9 +151,10 @@ void gl_renderCube(unsigned int shaderProgram, unsigned int fragmentShader, unsi
|
||||||
double px, py, pz;
|
double px, py, pz;
|
||||||
double px2, py2, pz2;
|
double px2, py2, pz2;
|
||||||
bool is_visible(cube_0* cb, double offx, double offy, double offz) {
|
bool is_visible(cube_0* cb, double offx, double offy, double offz) {
|
||||||
|
//return true;
|
||||||
for(int d = 0; d < 8; d++) {
|
for(int d = 0; d < 8; d++) {
|
||||||
project_to_cube(cb->x+cb->w*(d%2==0)+offx, cb->y+cb->h*((d/2)%2==0)+offy, cb->z+cb->d*((d/4)%2==0)+offz, &px, &py, &pz, cb);
|
project_to_cube(cb->x+cb->w*(d%2==0), cb->y+cb->h*((d/2)%2==0), cb->z+cb->d*((d/4)%2==0), &px, &py, &pz, cb);
|
||||||
project_to_camera(px, py, pz, &px2, &py2, &pz2);
|
project_to_camera(px+offx, py+offy, pz+offz, &px2, &py2, &pz2);
|
||||||
if(pz2 >= near) {
|
if(pz2 >= near) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +184,7 @@ void gl_renderAll(unsigned int shaderProgram, unsigned int fragmentShader, unsig
|
||||||
for(int k = 0; k < rtd->ent_len; k++) {
|
for(int k = 0; k < rtd->ent_len; k++) {
|
||||||
if(is_visible(rtd->ents[k]->pos, offx, offy, offz)) {
|
if(is_visible(rtd->ents[k]->pos, offx, offy, offz)) {
|
||||||
//printf("%d\n", rtd->ents[k]->tex);
|
//printf("%d\n", rtd->ents[k]->tex);
|
||||||
if(rtd->ents[k]->entity_type != 9 || /* entityType == 9 */rtd->ents[k]->metai1) {
|
if(rtd->ents[k]->entity_type != 9 || rtd->ents[k]->metai1) {
|
||||||
glBindTexture(GL_TEXTURE_2D, textures[rtd->ents[k]->tex]);
|
glBindTexture(GL_TEXTURE_2D, textures[rtd->ents[k]->tex]);
|
||||||
} else {
|
} else {
|
||||||
//printf(">>%d<<\n", rtd->ents[k]->tex2);
|
//printf(">>%d<<\n", rtd->ents[k]->tex2);
|
||||||
|
@ -198,9 +199,11 @@ void gl_renderAll(unsigned int shaderProgram, unsigned int fragmentShader, unsig
|
||||||
void gl_renderNearbyChunks(unsigned int shaderProgram, unsigned int fragmentShader, unsigned int VAO, unsigned int VBO, int render_distance) {
|
void gl_renderNearbyChunks(unsigned int shaderProgram, unsigned int fragmentShader, unsigned int VAO, unsigned int VBO, int render_distance) {
|
||||||
for(int w = -render_distance; w <= render_distance; w++) {
|
for(int w = -render_distance; w <= render_distance; w++) {
|
||||||
for(int h = -render_distance; h <= render_distance; h++) {
|
for(int h = -render_distance; h <= render_distance; h++) {
|
||||||
|
//printf("(%d %d -> %d)", w, h, hashtbl_find_opt(visited, player_chx+w, player_chy+h)->ent_len);
|
||||||
gl_renderAll(shaderProgram, fragmentShader, VAO, VBO, hashtbl_find_opt(visited, player_chx+w, player_chy+h), (2.0*room_width)*w, 0.0, (2.0*room_depth)*h);
|
gl_renderAll(shaderProgram, fragmentShader, VAO, VBO, hashtbl_find_opt(visited, player_chx+w, player_chy+h), (2.0*room_width)*w, 0.0, (2.0*room_depth)*h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//printf("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 dir0;
|
vec3 dir0;
|
||||||
|
|
|
@ -48,11 +48,21 @@ void update_entity(entity* ent, float dtime) {
|
||||||
(*ent->updatePos)(ent->pos->x, ent->pos->y, ent->pos->z, ent->pos->w, ent->pos->h, ent->pos->d, ent->pos->hz_angle, ent->pos->vt_angle, dtime, ent, ent->pos);
|
(*ent->updatePos)(ent->pos->x, ent->pos->y, ent->pos->z, ent->pos->w, ent->pos->h, ent->pos->d, ent->pos->hz_angle, ent->pos->vt_angle, dtime, ent, ent->pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_entities(float dtime) {
|
void update_entities(float dtime, room* rtd) {
|
||||||
for(int k = 0; k < current_room->ent_len; k++) {
|
if(rtd != NULL) {
|
||||||
if(current_room->ents[k]->updatePos != NULL) {
|
for(int k = 0; k < rtd->ent_len; k++) {
|
||||||
|
if(rtd->ents[k]->updatePos != NULL) {
|
||||||
//printf("e\n");
|
//printf("e\n");
|
||||||
update_entity(current_room->ents[k], dtime);
|
update_entity(rtd->ents[k], dtime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_nearby_entities(float dtime, int render_distance) {
|
||||||
|
for(int w = -render_distance; w <= render_distance; w++) {
|
||||||
|
for(int h = -render_distance; h <= render_distance; h++) {
|
||||||
|
update_entities(dtime, hashtbl_find_opt(visited, player_chx+w, player_chy+h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +140,7 @@ void moving_xyz_line(double x, double y, double z, double w, double h, double d,
|
||||||
// metai3 = doPay
|
// metai3 = doPay
|
||||||
// metach1 = text (stored here to free() easily)
|
// metach1 = text (stored here to free() easily)
|
||||||
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 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) {
|
||||||
if(distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= 1.5) {
|
if(distance_pt_cube_0_3d_infinite(camx+player_chx*room_width*2, camy, camz+player_chy*room_depth*2, ret) <= 1.5) {
|
||||||
gl_drawString(fShader, ent->metach1, 0.0f, -0.7f, 0.03f, ret->red, ret->green, ret->blue, 0.003f, 0);
|
gl_drawString(fShader, ent->metach1, 0.0f, -0.7f, 0.03f, ret->red, ret->green, ret->blue, 0.003f, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,6 +161,17 @@ void beating_block(double x, double y, double z, double w, double h, double d, d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// metad1 = hz_speed
|
||||||
|
// metad2 = vt_speed
|
||||||
|
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) {
|
||||||
|
ret->hz_angle += ent->metad1*dtime;
|
||||||
|
ret->vt_angle += ent->metad2*dtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spinning_translate(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void detectHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
void detectHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
||||||
if(ret->red == 193) {
|
if(ret->red == 193) {
|
||||||
ret->red = 0;
|
ret->red = 0;
|
||||||
|
@ -178,18 +199,18 @@ void translatePlayer(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
||||||
double dx = ent->metad4*(cos((double)(ent->metai1*(sim_time+(double)dtime)/ent->metai2 + ent->metai3*3.14159/180.0))-cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0)));
|
double dx = ent->metad4*(cos((double)(ent->metai1*(sim_time+(double)dtime)/ent->metai2 + ent->metai3*3.14159/180.0))-cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0)));
|
||||||
double dy = ent->metad5*(cos((double)(ent->metai1*(sim_time+(double)dtime)/ent->metai2 + ent->metai3*3.14159/180.0))-cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0)));
|
double dy = ent->metad5*(cos((double)(ent->metai1*(sim_time+(double)dtime)/ent->metai2 + ent->metai3*3.14159/180.0))-cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0)));
|
||||||
double dz = ent->metad6*(cos((double)(ent->metai1*(sim_time+(double)dtime)/ent->metai2 + ent->metai3*3.14159/180.0))-cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0)));
|
double dz = ent->metad6*(cos((double)(ent->metai1*(sim_time+(double)dtime)/ent->metai2 + ent->metai3*3.14159/180.0))-cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0)));
|
||||||
//fx += dx/(dtime*dtime);
|
fx += dx/(dtime*dtime);
|
||||||
fy += dy/(dtime*dtime);
|
fy += dy/(dtime*dtime);
|
||||||
//fz += dz/(dtime*dtime);
|
fz += dz/(dtime*dtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void translatePlayerLine(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
void translatePlayerLine(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
||||||
double dx = (ent->metai1)*ent->metad4*dtime;
|
double dx = (ent->metai1)*ent->metad4*dtime;
|
||||||
double dy = (ent->metai2)*ent->metad5*dtime;
|
double dy = (ent->metai2)*ent->metad5*dtime;
|
||||||
double dz = (ent->metai3)*ent->metad6*dtime;
|
double dz = (ent->metai3)*ent->metad6*dtime;
|
||||||
//fx += dx/(dtime*dtime);
|
fx += dx/(dtime*dtime);
|
||||||
fy += dy/(dtime*dtime);
|
fy += dy/(dtime*dtime);
|
||||||
//fz += dz/(dtime*dtime);
|
fz += dz/(dtime*dtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void go_to_player(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 go_to_player(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) {
|
||||||
|
|
|
@ -7,7 +7,8 @@ bool is_colliding_with_map(cube_0* cb);
|
||||||
bool is_colliding_with_tp(cube_0* cb);
|
bool is_colliding_with_tp(cube_0* cb);
|
||||||
|
|
||||||
void update_entity(entity* ent, float dtime);
|
void update_entity(entity* ent, float dtime);
|
||||||
void update_entities(float dtime);
|
void update_entities(float dtime, room* rtd);
|
||||||
|
void update_nearby_entities(float dtime, int render_distance);
|
||||||
|
|
||||||
void speen(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 speen(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 speen2(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 speen2(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);
|
||||||
|
@ -17,7 +18,9 @@ void moving_xyz_line(double x, double y, double z, double w, double h, double d,
|
||||||
void go_to_player(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 go_to_player(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 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 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 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 spinning_translate(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
|
||||||
void detectHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
|
void detectHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
|
||||||
void money(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
|
void money(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
|
||||||
void explodeOnHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
|
void explodeOnHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret);
|
||||||
|
|
|
@ -38,7 +38,7 @@ void init_ent_generator(int n) {
|
||||||
//!\\ size = 30 now
|
//!\\ size = 30 now
|
||||||
hashtbl_entities = malloc(sizeof(fct_entry)*n);
|
hashtbl_entities = malloc(sizeof(fct_entry)*n);
|
||||||
fct_entry_size = n;
|
fct_entry_size = n;
|
||||||
for(int k = 0; k < 10; k++) {
|
for(int k = 0; k < n; k++) {
|
||||||
hashtbl_entities[k].id = (-1);
|
hashtbl_entities[k].id = (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +121,14 @@ void init_ent_generator(int n) {
|
||||||
hashtbl_entities[9].updatePos = &beating_block;
|
hashtbl_entities[9].updatePos = &beating_block;
|
||||||
hashtbl_entities[9].onHit = NULL;
|
hashtbl_entities[9].onHit = NULL;
|
||||||
hashtbl_entities[9].onDeath = NULL;
|
hashtbl_entities[9].onDeath = NULL;
|
||||||
|
|
||||||
|
hashtbl_entities[10].id = 10;
|
||||||
|
hashtbl_entities[10].tex = 4;
|
||||||
|
hashtbl_entities[10].tex2 = 4;
|
||||||
|
hashtbl_entities[10].name = "SpinningPlatform";
|
||||||
|
hashtbl_entities[10].updatePos = &spinning_platform;
|
||||||
|
hashtbl_entities[10].onHit = &spinning_translate;
|
||||||
|
hashtbl_entities[10].onDeath = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fct_entry* get_entry(int k0) {
|
fct_entry* get_entry(int k0) {
|
||||||
|
@ -298,7 +306,7 @@ void align_to(FILE* ptr, char ch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_int(FILE* ptr, bool print) {
|
int read_int(FILE* ptr) {
|
||||||
bool is_reading = false;
|
bool is_reading = false;
|
||||||
int buffer = 0;
|
int buffer = 0;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
|
@ -344,8 +352,8 @@ double sign(double __x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double read_float(FILE* ptr) {
|
double read_float(FILE* ptr) {
|
||||||
int ent = read_int(ptr, false);
|
int ent = read_int(ptr);
|
||||||
int frac = read_int(ptr, false);
|
int frac = read_int(ptr);
|
||||||
//printf("%d.%d; ", ent, frac);
|
//printf("%d.%d; ", ent, frac);
|
||||||
if(ent != 0.0) {
|
if(ent != 0.0) {
|
||||||
return (ent/abs(ent))*(absf((double)ent) + ((double)frac)/(pow(10.0, (double)ln_baseN(frac, 10))));
|
return (ent/abs(ent))*(absf((double)ent) + ((double)frac)/(pow(10.0, (double)ln_baseN(frac, 10))));
|
||||||
|
@ -400,9 +408,9 @@ void parse_one_room(int id, char* filename) {
|
||||||
double cd = read_float(ptr);
|
double cd = read_float(ptr);
|
||||||
double chz = read_float(ptr);
|
double chz = read_float(ptr);
|
||||||
double cvt = read_float(ptr);
|
double cvt = read_float(ptr);
|
||||||
int red = read_int(ptr, true);
|
int red = read_int(ptr);
|
||||||
int green = read_int(ptr, true);
|
int green = read_int(ptr);
|
||||||
int blue = read_int(ptr, true);
|
int blue = read_int(ptr);
|
||||||
pool[id].area->map[k] = create_cube_0(cx, cy, cz, cw, ch, cd, chz, cvt, red, green, blue);
|
pool[id].area->map[k] = create_cube_0(cx, cy, cz, cw, ch, cd, chz, cvt, red, green, blue);
|
||||||
//printf("\n");
|
//printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -420,12 +428,12 @@ void parse_one_room(int id, char* filename) {
|
||||||
double cd = read_float(ptr);
|
double cd = read_float(ptr);
|
||||||
double chz = read_float(ptr);
|
double chz = read_float(ptr);
|
||||||
double cvt = read_float(ptr);
|
double cvt = read_float(ptr);
|
||||||
int red = read_int(ptr, true);
|
int red = read_int(ptr);
|
||||||
int green = read_int(ptr, true);
|
int green = read_int(ptr);
|
||||||
int blue = read_int(ptr, true);
|
int blue = read_int(ptr);
|
||||||
pool[id].area->tps[k]->hitbox = create_cube_0(cx, cy, cz, cw, ch, cd, chz, cvt, red, green, blue);
|
pool[id].area->tps[k]->hitbox = create_cube_0(cx, cy, cz, cw, ch, cd, chz, cvt, red, green, blue);
|
||||||
pool[id].area->tps[k]->dest_chx = read_int(ptr, true);
|
pool[id].area->tps[k]->dest_chx = read_int(ptr);
|
||||||
pool[id].area->tps[k]->dest_chy = read_int(ptr, true);
|
pool[id].area->tps[k]->dest_chy = read_int(ptr);
|
||||||
//printf("\n");
|
//printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,12 +450,12 @@ void parse_one_room(int id, char* filename) {
|
||||||
double cd = read_float(ptr);
|
double cd = read_float(ptr);
|
||||||
double chz = read_float(ptr);
|
double chz = read_float(ptr);
|
||||||
double cvt = read_float(ptr);
|
double cvt = read_float(ptr);
|
||||||
int red = read_int(ptr, true);
|
int red = read_int(ptr);
|
||||||
int green = read_int(ptr, true);
|
int green = read_int(ptr);
|
||||||
int blue = read_int(ptr, true);
|
int blue = read_int(ptr);
|
||||||
int hp = read_int(ptr, true);
|
int hp = read_int(ptr);
|
||||||
int dmg = read_int(ptr, true);
|
int dmg = read_int(ptr);
|
||||||
int fid = read_int(ptr, true);
|
int fid = read_int(ptr);
|
||||||
fct_entry* entry = get_entry(fid);
|
fct_entry* entry = get_entry(fid);
|
||||||
if(entry == NULL) {
|
if(entry == NULL) {
|
||||||
entry = get_entry(0);
|
entry = get_entry(0);
|
||||||
|
@ -482,9 +490,9 @@ void parse_one_room(int id, char* filename) {
|
||||||
double ccw = read_float(ptr);
|
double ccw = read_float(ptr);
|
||||||
double cch = read_float(ptr);
|
double cch = read_float(ptr);
|
||||||
double ccd = read_float(ptr);
|
double ccd = read_float(ptr);
|
||||||
int mult = read_int(ptr, true);
|
int mult = read_int(ptr);
|
||||||
int divd = read_int(ptr, true);
|
int divd = read_int(ptr);
|
||||||
int phase = read_int(ptr, true);
|
int phase = read_int(ptr);
|
||||||
pool[id].area->ents[k]->metad1 = cx;
|
pool[id].area->ents[k]->metad1 = cx;
|
||||||
pool[id].area->ents[k]->metad2 = cy;
|
pool[id].area->ents[k]->metad2 = cy;
|
||||||
pool[id].area->ents[k]->metad3 = cz;
|
pool[id].area->ents[k]->metad3 = cz;
|
||||||
|
@ -520,9 +528,9 @@ void parse_one_room(int id, char* filename) {
|
||||||
to_free[to_length] = msg;
|
to_free[to_length] = msg;
|
||||||
to_length += 1;
|
to_length += 1;
|
||||||
pool[id].area->ents[k]->metach1 = msg;
|
pool[id].area->ents[k]->metach1 = msg;
|
||||||
int ired = read_int(ptr, true);
|
int ired = read_int(ptr);
|
||||||
int igreen = read_int(ptr, true);
|
int igreen = read_int(ptr);
|
||||||
int iblue = read_int(ptr, true);
|
int iblue = read_int(ptr);
|
||||||
pool[id].area->ents[k]->metai1 = build_text_box(msg, ired, igreen, iblue);
|
pool[id].area->ents[k]->metai1 = build_text_box(msg, ired, igreen, iblue);
|
||||||
pool[id].area->ents[k]->metai3 = (-727); // random value to recognize
|
pool[id].area->ents[k]->metai3 = (-727); // random value to recognize
|
||||||
} else if(entry->id == 7) {
|
} else if(entry->id == 7) {
|
||||||
|
@ -530,28 +538,28 @@ void parse_one_room(int id, char* filename) {
|
||||||
char* dest = read_string(ptr);
|
char* dest = read_string(ptr);
|
||||||
to_free[to_length] = dest;
|
to_free[to_length] = dest;
|
||||||
to_length += 1;
|
to_length += 1;
|
||||||
int count = read_int(ptr, true);
|
int count = read_int(ptr);
|
||||||
char* msg = read_string(ptr);
|
char* msg = read_string(ptr);
|
||||||
to_free[to_length] = msg;
|
to_free[to_length] = msg;
|
||||||
to_length += 1;
|
to_length += 1;
|
||||||
pool[id].area->ents[k]->metach1 = dest;
|
pool[id].area->ents[k]->metach1 = dest;
|
||||||
pool[id].area->ents[k]->metach2 = msg;
|
pool[id].area->ents[k]->metach2 = msg;
|
||||||
int ired = read_int(ptr, true);
|
int ired = read_int(ptr);
|
||||||
int igreen = read_int(ptr, true);
|
int igreen = read_int(ptr);
|
||||||
int iblue = read_int(ptr, true);
|
int iblue = read_int(ptr);
|
||||||
pool[id].area->ents[k]->metai1 = build_text_box(msg, ired, igreen, iblue);
|
pool[id].area->ents[k]->metai1 = build_text_box(msg, ired, igreen, iblue);
|
||||||
pool[id].area->ents[k]->metai2 = count;
|
pool[id].area->ents[k]->metai2 = count;
|
||||||
pool[id].area->ents[k]->metai3 = (-72727); // random value to recognize
|
pool[id].area->ents[k]->metai3 = (-72727); // random value to recognize
|
||||||
} else if(entry->id == 8) {
|
} else if(entry->id == 8) {
|
||||||
// lock box
|
// lock box
|
||||||
int cost = read_int(ptr, true); // assume cost > 0
|
int cost = read_int(ptr); // assume cost > 0
|
||||||
int doPay = read_int(ptr, true);
|
int doPay = read_int(ptr);
|
||||||
|
|
||||||
//printf("%d %d --------<>---------\n", cost, doPay);
|
//printf("%d %d --------<>---------\n", cost, doPay);
|
||||||
|
|
||||||
int ired = read_int(ptr, true);
|
int ired = read_int(ptr);
|
||||||
int igreen = read_int(ptr, true);
|
int igreen = read_int(ptr);
|
||||||
int iblue = read_int(ptr, true);
|
int iblue = read_int(ptr);
|
||||||
|
|
||||||
int nsize = 1+ln_baseN(cost, 10);
|
int nsize = 1+ln_baseN(cost, 10);
|
||||||
// char* test = "you need 0 to pass"; char[19] //
|
// char* test = "you need 0 to pass"; char[19] //
|
||||||
|
@ -596,7 +604,7 @@ void parse_one_room(int id, char* filename) {
|
||||||
// beat block
|
// beat block
|
||||||
double ontime = read_float(ptr);
|
double ontime = read_float(ptr);
|
||||||
double offtime = read_float(ptr);
|
double offtime = read_float(ptr);
|
||||||
int stst = read_int(ptr, true);
|
int stst = read_int(ptr);
|
||||||
if(stst != 0 && stst != 1) {
|
if(stst != 0 && stst != 1) {
|
||||||
stst = 1;
|
stst = 1;
|
||||||
}
|
}
|
||||||
|
@ -605,6 +613,13 @@ void parse_one_room(int id, char* filename) {
|
||||||
pool[id].area->ents[k]->metad2 = offtime;
|
pool[id].area->ents[k]->metad2 = offtime;
|
||||||
pool[id].area->ents[k]->metad3 = 0.0;
|
pool[id].area->ents[k]->metad3 = 0.0;
|
||||||
pool[id].area->ents[k]->metai1 = 1-stst;
|
pool[id].area->ents[k]->metai1 = 1-stst;
|
||||||
|
} else if(entry->id == 10) {
|
||||||
|
// spinning platform
|
||||||
|
double hzspd = read_float(ptr);
|
||||||
|
double vtspd = read_float(ptr);
|
||||||
|
|
||||||
|
pool[id].area->ents[k]->metad1 = hzspd;
|
||||||
|
pool[id].area->ents[k]->metad2 = vtspd;
|
||||||
} else {
|
} else {
|
||||||
pool[id].area->ents[k]->metai3 = 0;
|
pool[id].area->ents[k]->metai3 = 0;
|
||||||
}
|
}
|
||||||
|
@ -615,7 +630,7 @@ void parse_one_room(int id, char* filename) {
|
||||||
|
|
||||||
align_to(ptr, 'W');
|
align_to(ptr, 'W');
|
||||||
|
|
||||||
pool[id].weight = read_int(ptr, true);
|
pool[id].weight = read_int(ptr);
|
||||||
total_weight += pool[id].weight;
|
total_weight += pool[id].weight;
|
||||||
|
|
||||||
printf("(w = %d) OK\n", pool[id].weight);
|
printf("(w = %d) OK\n", pool[id].weight);
|
||||||
|
|
|
@ -50,7 +50,7 @@ void init_hashtbl() ;
|
||||||
|
|
||||||
void get_number_blocks(int* ret_cubes, int* ret_tps, int* ret_ent, FILE* ptr) ;
|
void get_number_blocks(int* ret_cubes, int* ret_tps, int* ret_ent, FILE* ptr) ;
|
||||||
void align_to(FILE* ptr, char ch) ;
|
void align_to(FILE* ptr, char ch) ;
|
||||||
int read_int(FILE* ptr, bool print) ;
|
int read_int(FILE* ptr) ;
|
||||||
double read_float(FILE* ptr) ;
|
double read_float(FILE* ptr) ;
|
||||||
char* read_string(FILE* ptr);
|
char* read_string(FILE* ptr);
|
||||||
void parse_one_room(int id, char* filename) ;
|
void parse_one_room(int id, char* filename) ;
|
||||||
|
|
|
@ -564,7 +564,7 @@ int main_alt() {
|
||||||
movePlayerG(delta);
|
movePlayerG(delta);
|
||||||
}
|
}
|
||||||
teleport_on_edge();
|
teleport_on_edge();
|
||||||
update_entities(delta);
|
update_nearby_entities(delta, 1);
|
||||||
updateProj(delta);
|
updateProj(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,8 +263,6 @@ bool is_colliding(float dtime) {
|
||||||
if(current_room->ents[k]->onDeath != NULL) {
|
if(current_room->ents[k]->onDeath != NULL) {
|
||||||
(*current_room->ents[k]->onDeath)(dtime);
|
(*current_room->ents[k]->onDeath)(dtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
remove_entity(current_room->ents, ¤t_room->ent_memlen, ¤t_room->ent_len, k);
|
remove_entity(current_room->ents, ¤t_room->ent_memlen, ¤t_room->ent_len, k);
|
||||||
is_clipping = false;
|
is_clipping = false;
|
||||||
exists = false;
|
exists = false;
|
||||||
|
@ -273,7 +271,7 @@ bool is_colliding(float dtime) {
|
||||||
if(exists && updateForces && current_room->ents[k]->entity_type != 0) {
|
if(exists && updateForces && current_room->ents[k]->entity_type != 0) {
|
||||||
updateF(current_room->ents[k]->pos, (double)dtime);
|
updateF(current_room->ents[k]->pos, (double)dtime);
|
||||||
}
|
}
|
||||||
if(exists && current_room->ents[k]->entity_type == 9) {
|
if(exists && (current_room->ents[k]->entity_type == 9 || current_room->ents[k]->entity_type == 4 || current_room->ents[k]->entity_type == 5)) {
|
||||||
is_clipping = false;
|
is_clipping = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue