added jumping and moving platforms
This commit is contained in:
parent
381348a420
commit
541596e8c0
BIN
obj/base.o
BIN
obj/base.o
Binary file not shown.
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/hash.o
BIN
obj/hash.o
Binary file not shown.
BIN
obj/main.o
BIN
obj/main.o
Binary file not shown.
BIN
obj/menus.o
BIN
obj/menus.o
Binary file not shown.
BIN
obj/move.o
BIN
obj/move.o
Binary file not shown.
BIN
obj/proj.o
BIN
obj/proj.o
Binary file not shown.
|
@ -376,6 +376,7 @@ void add_entity(entity** arr, int* memlen, int* len, entity* ent) {
|
|||
arr = newarr ;
|
||||
*memlen *= 2;
|
||||
}
|
||||
free(arr[*len]);
|
||||
arr[*len] = ent ;
|
||||
*len += 1;
|
||||
}
|
|
@ -215,5 +215,9 @@ void gl_drawData(unsigned int shaderProg) {
|
|||
gl_drawInteger(shaderProg, (int)camy, 0.95f, 0.75f, 0.05f, 255, 255, 255, 0.005, -1);
|
||||
gl_drawInteger(shaderProg, (int)camz, 0.95f, 0.6f, 0.05f, 255, 255, 255, 0.005, -1);
|
||||
|
||||
gl_drawInteger(shaderProg, (int)10.0*camvx, 0.95f, -0.6f, 0.05f, 255, 255, 255, 0.005, -1);
|
||||
gl_drawInteger(shaderProg, (int)10.0*camvy, 0.95f, -0.75f, 0.05f, 255, 255, 255, 0.005, -1);
|
||||
gl_drawInteger(shaderProg, (int)10.0*camvz, 0.95f, -0.9f, 0.05f, 255, 255, 255, 0.005, -1);
|
||||
|
||||
gl_drawInteger(shaderProg, player_hp, -0.95f, 0.9f, 0.05f, 255-player_hp/4, player_hp/4, 0, 0.005f, 1);
|
||||
}
|
|
@ -42,7 +42,7 @@ bool is_colliding_with_tp(cube_0* cb) {
|
|||
// ------------------------------------------------------------------------------------------------------------------------------------------------ //
|
||||
|
||||
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->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) {
|
||||
|
@ -56,11 +56,11 @@ void update_entities(float dtime) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------------------------------------------------------ //
|
||||
|
||||
void speen(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, 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) {
|
||||
ret->hz_angle += ((double)dtime)*15.0;
|
||||
}
|
||||
|
||||
void speen2(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, 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) {
|
||||
ret->hz_angle += ((double)dtime)*22.5;
|
||||
if((int)(5.0*ret->hz_angle) != (int)(5.0*(ret->hz_angle - ((double)dtime)*22.5))) {
|
||||
double dx = (x+w/2 - camx);
|
||||
|
@ -74,12 +74,20 @@ void speen2(double x, double y, double z, double w, double h, double d, double h
|
|||
}
|
||||
}
|
||||
|
||||
void speen3(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, cube_0* ret) {
|
||||
void speen3(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->vt_angle += ((double)dtime)*22.5;
|
||||
}
|
||||
|
||||
void moving_x(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, cube_0* ret) {
|
||||
|
||||
// metad{1,2,3} = og pos
|
||||
// metad{4,5,6} = amplitudes
|
||||
// metai{1} = frequency multiplier
|
||||
// metai{2} = frequency divider
|
||||
// metai{3} = phase
|
||||
void moving_xyz(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->x = ent->metad1 + ent->metad4*cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0));
|
||||
ret->y = ent->metad2 + ent->metad5*cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0));
|
||||
ret->z = ent->metad3 + ent->metad6*cos((double)(ent->metai1*sim_time/ent->metai2 + ent->metai3*3.14159/180.0));
|
||||
//printf("%lf %lf %lf\n", ret->x, ret->y, ret->z);
|
||||
}
|
||||
|
||||
void detectHit(float dtime, int* hp, int* dmg, cube_0* ret) {
|
||||
|
@ -96,7 +104,7 @@ void detectHit(float dtime, int* hp, int* dmg, 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, 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) {
|
||||
double dx = (x+w/2 - camx);
|
||||
double dy = (y+h/2 - camy);
|
||||
double dz = (z+d/2 - camz);
|
||||
|
|
|
@ -7,11 +7,11 @@ bool is_colliding_with_tp(cube_0* cb);
|
|||
void update_entity(entity* ent, float dtime);
|
||||
void update_entities(float dtime);
|
||||
|
||||
void speen(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, 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, cube_0* ret);
|
||||
void speen3(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, 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, 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 speen3(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 moving_xyz(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 detectHit(float dtime, int* hp, int* dmg, cube_0* ret);
|
||||
void explodeOnHit(float dtime, int* hp, int* dmg, cube_0* ret);
|
||||
|
|
|
@ -59,6 +59,12 @@ void init_ent_generator(int n) {
|
|||
hashtbl_entities[3].updatePos = &speen3;
|
||||
hashtbl_entities[3].onHit = &explodeOnHit;
|
||||
hashtbl_entities[3].onDeath = NULL;
|
||||
|
||||
hashtbl_entities[4].id = 4;
|
||||
hashtbl_entities[4].name = "Platform";
|
||||
hashtbl_entities[4].updatePos = &moving_xyz;
|
||||
hashtbl_entities[4].onHit = NULL;
|
||||
hashtbl_entities[4].onDeath = NULL;
|
||||
}
|
||||
|
||||
fct_entry* get_entry(int k0) {
|
||||
|
@ -104,14 +110,18 @@ void copy_room(room* src, room* dest, int chx, int chy) {
|
|||
dest->ents[k] = malloc(sizeof(entity));
|
||||
dest->ents[k]->damage = src->ents[k]->damage;
|
||||
dest->ents[k]->hitpoints = malloc(sizeof(int));
|
||||
dest->ents[k]->meta1 = src->ents[k]->meta1;
|
||||
dest->ents[k]->meta2 = src->ents[k]->meta2;
|
||||
dest->ents[k]->meta3 = src->ents[k]->meta3;
|
||||
dest->ents[k]->meta4 = src->ents[k]->meta4;
|
||||
dest->ents[k]->meta5 = src->ents[k]->meta5;
|
||||
dest->ents[k]->meta6 = src->ents[k]->meta6;
|
||||
dest->ents[k]->meta7 = src->ents[k]->meta7;
|
||||
dest->ents[k]->meta8 = src->ents[k]->meta8;
|
||||
dest->ents[k]->metai1 = src->ents[k]->metai1;
|
||||
dest->ents[k]->metai2 = src->ents[k]->metai2;
|
||||
dest->ents[k]->metai3 = src->ents[k]->metai3;
|
||||
dest->ents[k]->metai4 = src->ents[k]->metai4;
|
||||
dest->ents[k]->metai5 = src->ents[k]->metai5;
|
||||
dest->ents[k]->metai6 = src->ents[k]->metai6;
|
||||
dest->ents[k]->metad1 = src->ents[k]->metad1;
|
||||
dest->ents[k]->metad2 = src->ents[k]->metad2;
|
||||
dest->ents[k]->metad3 = src->ents[k]->metad3;
|
||||
dest->ents[k]->metad4 = src->ents[k]->metad4;
|
||||
dest->ents[k]->metad5 = src->ents[k]->metad5;
|
||||
dest->ents[k]->metad6 = src->ents[k]->metad6;
|
||||
*(dest->ents[k]->hitpoints) = *(src->ents[k]->hitpoints);
|
||||
dest->ents[k]->pos = create_cube_0(
|
||||
(*(src->ents[k]->pos)).x, (*(src->ents[k]->pos)).y, (*(src->ents[k]->pos)).z,
|
||||
|
@ -362,14 +372,35 @@ void parse_one_room(int id, char* filename) {
|
|||
pool[id].area->ents[k]->updatePos = entry->updatePos;
|
||||
pool[id].area->ents[k]->onHit = entry->onHit ;
|
||||
pool[id].area->ents[k]->onDeath = entry->onDeath ;
|
||||
pool[id].area->ents[k]->meta1 = 0;
|
||||
pool[id].area->ents[k]->meta2 = 0;
|
||||
pool[id].area->ents[k]->meta3 = 0;
|
||||
pool[id].area->ents[k]->meta4 = 0;
|
||||
pool[id].area->ents[k]->meta5 = 0.0;
|
||||
pool[id].area->ents[k]->meta6 = 0.0;
|
||||
pool[id].area->ents[k]->meta7 = 0.0;
|
||||
pool[id].area->ents[k]->meta8 = 0.0;
|
||||
pool[id].area->ents[k]->metai1 = entry->metai1;
|
||||
pool[id].area->ents[k]->metai2 = entry->metai2;
|
||||
pool[id].area->ents[k]->metai3 = entry->metai3;
|
||||
pool[id].area->ents[k]->metai4 = entry->metai4;
|
||||
pool[id].area->ents[k]->metai5 = entry->metai5;
|
||||
pool[id].area->ents[k]->metai6 = entry->metai6;
|
||||
pool[id].area->ents[k]->metad1 = entry->metad1;
|
||||
pool[id].area->ents[k]->metad2 = entry->metad2;
|
||||
pool[id].area->ents[k]->metad3 = entry->metad3;
|
||||
pool[id].area->ents[k]->metad4 = entry->metad4;
|
||||
pool[id].area->ents[k]->metad5 = entry->metad5;
|
||||
pool[id].area->ents[k]->metad6 = entry->metad6;
|
||||
if(entry->id == 4) {
|
||||
double ccw = read_float(ptr);
|
||||
double cch = read_float(ptr);
|
||||
double ccd = read_float(ptr);
|
||||
int mult = read_int(ptr, true);
|
||||
int divd = read_int(ptr, true);
|
||||
int phase = read_int(ptr, true);
|
||||
pool[id].area->ents[k]->metad1 = cx;
|
||||
pool[id].area->ents[k]->metad2 = cy;
|
||||
pool[id].area->ents[k]->metad3 = cz;
|
||||
pool[id].area->ents[k]->metad4 = ccw;
|
||||
pool[id].area->ents[k]->metad5 = cch;
|
||||
pool[id].area->ents[k]->metad6 = ccd;
|
||||
pool[id].area->ents[k]->metai1 = mult;
|
||||
pool[id].area->ents[k]->metai2 = divd;
|
||||
pool[id].area->ents[k]->metai3 = phase;
|
||||
}
|
||||
//pool[id].area->ents[k]->updatePos = &speen2;
|
||||
//pool[id].area->ents[k]->onHit = &detectHit ;
|
||||
//pool[id].area->ents[k]->onDeath = NULL ;
|
||||
|
@ -380,7 +411,7 @@ void parse_one_room(int id, char* filename) {
|
|||
fflush(stdout);
|
||||
|
||||
// debug
|
||||
for(int k = 0; k < ncubes; k++) {
|
||||
/*for(int k = 0; k < ncubes; k++) {
|
||||
printf("(%lf, %lf, %lf), (%lf, %lf, %lf), (%lf, %lf), (%d, %d, %d)\n",
|
||||
pool[id].area->map[k]->x,
|
||||
pool[id].area->map[k]->y,
|
||||
|
@ -394,15 +425,14 @@ void parse_one_room(int id, char* filename) {
|
|||
pool[id].area->map[k]->green,
|
||||
pool[id].area->map[k]->blue
|
||||
);
|
||||
}
|
||||
|
||||
printf("OK\n");
|
||||
fflush(stdout);
|
||||
printf("\n\n");
|
||||
|
||||
}*/
|
||||
pool[id].weight = read_int(ptr, true);
|
||||
total_weight += pool[id].weight;
|
||||
|
||||
printf("(w = %d) OK\n", pool[id].weight);
|
||||
fflush(stdout);
|
||||
printf("\n\n");
|
||||
|
||||
fclose(ptr);
|
||||
}
|
||||
|
||||
|
@ -434,6 +464,7 @@ void parse_rooms(int n_rooms) {
|
|||
printf("Parsing...\n");
|
||||
|
||||
for(int k = 0; k < n_rooms; k++) {
|
||||
printf("parsing %d...", k);
|
||||
if(k < 10) {
|
||||
name[15] = (char)(k%10 + 48);
|
||||
} else if(k < 100) {
|
||||
|
@ -441,6 +472,7 @@ void parse_rooms(int n_rooms) {
|
|||
name[16] = (char)(k%10 + 48);
|
||||
}
|
||||
parse_one_room(k, name);
|
||||
printf("done.\n");
|
||||
}
|
||||
|
||||
printf("\nDone.\n");
|
||||
|
@ -485,6 +517,7 @@ void generate_nearby_chunks(int render_dist) {
|
|||
printf("generating (%d, %d)... ", player_chx + w, player_chy + h);
|
||||
//build_starting_chunk(player_chx + w, player_chy + h);
|
||||
int pick = rand()%total_weight;
|
||||
printf("R = %d ", pick);
|
||||
int sum = 0;
|
||||
for(int k = 0; k < pool_size; k++) {
|
||||
sum += pool[k].weight;
|
||||
|
|
|
@ -9,11 +9,25 @@ typedef struct entry {
|
|||
typedef struct fct_entry {
|
||||
int id ;
|
||||
char* name ;
|
||||
void (*updatePos)(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, cube_0* ret) ;
|
||||
void (*updatePos)(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) ;
|
||||
// act as velocity function
|
||||
void (*onHit)(float dtime, int* hp, int* dmg, cube_0* ret) ;
|
||||
// triggers when object is hit
|
||||
void (*onDeath)(float dtime) ;
|
||||
|
||||
// metadata //
|
||||
int metai1;
|
||||
int metai2;
|
||||
int metai3;
|
||||
int metai4;
|
||||
int metai5;
|
||||
int metai6;
|
||||
double metad1;
|
||||
double metad2;
|
||||
double metad3;
|
||||
double metad4;
|
||||
double metad5;
|
||||
double metad6;
|
||||
} fct_entry ;
|
||||
|
||||
void init_ent_generator(int n);
|
||||
|
|
36
src/main.c
36
src/main.c
|
@ -28,6 +28,7 @@ void processInput(GLFWwindow *window, float dtime) {
|
|||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) {
|
||||
/*
|
||||
for(int k = 0; k < 10; k++) {
|
||||
camz -= speed*cos(rot_hz)*cos(rot_vt)/10;
|
||||
camx -= speed*sin(rot_hz)*cos(rot_vt)/10;
|
||||
|
@ -39,8 +40,13 @@ void processInput(GLFWwindow *window, float dtime) {
|
|||
k=11;
|
||||
}
|
||||
}
|
||||
*/
|
||||
camvz = -speed*cos(rot_hz)*cos(rot_vt);
|
||||
camvx = -speed*sin(rot_hz)*cos(rot_vt);
|
||||
camvy = speed*sin(rot_vt);
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) {
|
||||
/*
|
||||
for(int k = 0; k < 10; k++) {
|
||||
camx -= speed*cos(rot_hz)/10;
|
||||
camz += speed*sin(rot_hz)/10;
|
||||
|
@ -49,10 +55,12 @@ void processInput(GLFWwindow *window, float dtime) {
|
|||
camz -= speed*sin(rot_hz)/10;
|
||||
k=11;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
camvx = -speed*cos(rot_hz);
|
||||
camvz = speed*sin(rot_hz);
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) {
|
||||
for(int k = 0; k < 10; k++) {
|
||||
/*for(int k = 0; k < 10; k++) {
|
||||
camz += speed*cos(rot_hz)*cos(rot_vt)/10;
|
||||
camx += speed*sin(rot_hz)*cos(rot_vt)/10;
|
||||
camy -= speed*sin(rot_vt)/10;
|
||||
|
@ -62,10 +70,13 @@ void processInput(GLFWwindow *window, float dtime) {
|
|||
camy += speed*sin(rot_vt)/10;
|
||||
k=11;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
camvz = speed*cos(rot_hz)*cos(rot_vt);
|
||||
camvx = speed*sin(rot_hz)*cos(rot_vt);
|
||||
camvy = -speed*sin(rot_vt);
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) {
|
||||
for(int k = 0; k < 10; k++) {
|
||||
/*for(int k = 0; k < 10; k++) {
|
||||
camx += speed*cos(rot_hz)/10;
|
||||
camz -= speed*sin(rot_hz)/10;
|
||||
if(is_colliding(dtime)) {
|
||||
|
@ -73,11 +84,14 @@ void processInput(GLFWwindow *window, float dtime) {
|
|||
camz += speed*sin(rot_hz)/10;
|
||||
k=11;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
camvx = speed*cos(rot_hz);
|
||||
camvz = -speed*sin(rot_hz);
|
||||
}
|
||||
|
||||
if(glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) {
|
||||
stop_evetything = true ;
|
||||
camvx = 0.0;
|
||||
camvz = 0.0;
|
||||
}
|
||||
|
||||
if(glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS) {
|
||||
|
@ -164,7 +178,7 @@ int main_alt() {
|
|||
init_hashtbl();
|
||||
init_ent_generator(10);
|
||||
init_proj();
|
||||
parse_rooms(5);
|
||||
parse_rooms(6);
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------------------- //
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------------------- //
|
||||
|
@ -321,13 +335,16 @@ int main_alt() {
|
|||
|
||||
finish = clock();
|
||||
delta = ((float)finish - (float)origin)/CLOCKS_PER_SEC;
|
||||
gl_drawInteger(shaderProgramR, (int)(1.0f/(delta)), 0.9f, -0.85f, 0.05, 32, 255, 32, 0.005, -1);
|
||||
gl_drawInteger(shaderProgramR, (int)(1.0f/(delta)), 0.0f, -0.92f, 0.05, 32, 255, 32, 0.005, -1);
|
||||
gl_drawInteger(shaderProgramR, triCount, 0.0f, 0.92f, 0.04f, 128, 128, 128, 0.005f, 1);
|
||||
gl_drawData(shaderProgramR);
|
||||
|
||||
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
|
||||
// -------------------------------------------------------------------------------
|
||||
finish = clock();
|
||||
delta = ((float)finish - (float)origin)/CLOCKS_PER_SEC;
|
||||
processInput(window, delta);
|
||||
movePlayerG(delta);
|
||||
teleport_on_edge();
|
||||
update_entities(delta);
|
||||
updateProj(delta);
|
||||
|
@ -335,6 +352,8 @@ int main_alt() {
|
|||
//printf("%lf, %lf, %lf\n", camx, camy, camz);
|
||||
|
||||
usleep(max(0, interval-(int)(1000000*delta)));
|
||||
finish = clock();
|
||||
sim_time += ((double)finish - (double)origin)/CLOCKS_PER_SEC;
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
|
@ -361,5 +380,6 @@ int main_alt() {
|
|||
int main(int argc, char** argv) {
|
||||
srand(time(NULL));
|
||||
triCount = 0;
|
||||
sim_time = 0.0;
|
||||
return main_alt();
|
||||
}
|
40
src/move.c
40
src/move.c
|
@ -18,7 +18,8 @@
|
|||
// ---------------------------------------------------------------------------------------------------- //
|
||||
double sensitivity = 0.06;
|
||||
double fov = 90.0;
|
||||
double speed = 0.22;
|
||||
//double speed = 0.22;
|
||||
double speed = 1000.0;
|
||||
double min_dist = 0.7;
|
||||
// ---------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
@ -30,6 +31,14 @@ double camx;
|
|||
double camy;
|
||||
double camz;
|
||||
|
||||
double camvx;
|
||||
double camvy;
|
||||
double camvz;
|
||||
|
||||
double gravity_factor;
|
||||
|
||||
double friction;
|
||||
|
||||
double rot_hz;
|
||||
double rot_vt;
|
||||
|
||||
|
@ -47,6 +56,11 @@ void init_csts() {
|
|||
camx = 2.0;
|
||||
camy = 5.0;
|
||||
camz = 2.0;
|
||||
camvx = 0.0;
|
||||
camvy = 0.0;
|
||||
camvz = 0.0;
|
||||
friction = 0.0005;
|
||||
gravity_factor = 20000.0;
|
||||
rot_hz = 0.0;
|
||||
rot_vt = 0.0;
|
||||
draw_type = 0;
|
||||
|
@ -109,6 +123,30 @@ bool is_colliding(float dtime) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void movePlayerG(float dtime) {
|
||||
camx += camvx*dtime;
|
||||
if(is_colliding(dtime)) {
|
||||
camx -= camvx*dtime;
|
||||
camvx = 0.0;
|
||||
}
|
||||
camvx *= pow(friction, (double)dtime*10);
|
||||
|
||||
camvy -= gravity_factor*dtime;
|
||||
camy += camvy*dtime;
|
||||
if(is_colliding(dtime)) {
|
||||
camy -= camvy*dtime;
|
||||
camvy = 0.0;
|
||||
}
|
||||
camvy *= pow(friction, (double)dtime*10);
|
||||
|
||||
camz += camvz*dtime;
|
||||
if(is_colliding(dtime)) {
|
||||
camz -= camvz*dtime;
|
||||
camvz = 0.0;
|
||||
}
|
||||
camvz *= pow(friction, (double)dtime*10);
|
||||
}
|
||||
|
||||
void teleport_on_edge() {
|
||||
if(camx >= room_width) {
|
||||
camx -= 2.0*room_width;
|
||||
|
|
|
@ -5,5 +5,6 @@ void init_csts();
|
|||
bool is_colliding(float dtime);
|
||||
|
||||
void teleport_on_edge();
|
||||
void movePlayerG(float dtime);
|
||||
|
||||
#endif
|
|
@ -33,7 +33,7 @@ typedef struct teleporter {
|
|||
typedef struct entity {
|
||||
cube_0* pos;
|
||||
// act as velocity function
|
||||
void (*updatePos)(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, cube_0* ret);
|
||||
void (*updatePos)(double x, double y, double z, double w, double h, double d, double hz_angle, double vt_angle, float dtime, struct entity* ent, cube_0* ret);
|
||||
|
||||
// triggers when object is hit
|
||||
void (*onHit)(float dtime, int* hp, int* dmg, cube_0* ret);
|
||||
|
@ -41,14 +41,18 @@ typedef struct entity {
|
|||
// triggers when <hitpoints> goes negative (death)
|
||||
void (*onDeath)(float dtime);
|
||||
|
||||
int meta1;
|
||||
int meta2;
|
||||
int meta3;
|
||||
int meta4;
|
||||
double meta5;
|
||||
double meta6;
|
||||
double meta7;
|
||||
double meta8;
|
||||
int metai1;
|
||||
int metai2;
|
||||
int metai3;
|
||||
int metai4;
|
||||
int metai5;
|
||||
int metai6;
|
||||
double metad1;
|
||||
double metad2;
|
||||
double metad3;
|
||||
double metad4;
|
||||
double metad5;
|
||||
double metad6;
|
||||
|
||||
int damage;
|
||||
int* hitpoints;
|
||||
|
@ -95,6 +99,14 @@ extern double camx;
|
|||
extern double camy;
|
||||
extern double camz;
|
||||
|
||||
extern double camvx;
|
||||
extern double camvy;
|
||||
extern double camvz;
|
||||
|
||||
extern double friction;
|
||||
|
||||
extern double gravity_factor;
|
||||
|
||||
extern double rot_hz;
|
||||
extern double rot_vt;
|
||||
|
||||
|
|
|
@ -12,7 +12,17 @@ Teleporters :
|
|||
[4.0, 1.0, 9.0, 2.0, 4.0, 1.0, 0.0, 0.0, 0, 255, 0; 0, 1]
|
||||
[9.0, 1.0, 4.0, 1.0, 4.0, 2.0, 0.0, 0.0, 0, 0, 255; 1, 0]
|
||||
|
||||
Weight :
|
||||
10
|
||||
Entities:
|
||||
[0.0, 14.0, 0.0, 2.0, 1.0, 2.0, 0.0, 0.0, 193, 192, 0, 1, 0, 4, 0.0, 5.0, 0.0, 80, 1, 45]
|
||||
|
||||
$
|
||||
Weight :
|
||||
50
|
||||
|
||||
$
|
||||
entities:
|
||||
[x, y, z, w, h, d, rhz, rvt, red, green, blue, hp, damage, entityType ..]
|
||||
|
||||
if entityType = 4
|
||||
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd]
|
||||
else
|
||||
[..]
|
|
@ -22,6 +22,13 @@ Entities :
|
|||
[0.0, 10.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.0, 193, 192, 0, 1, 0, 0]
|
||||
|
||||
Weight :
|
||||
60
|
||||
50
|
||||
|
||||
$
|
||||
$
|
||||
entities:
|
||||
[x, y, z, w, h, d, rhz, rvt, red, green, blue, hp, damage, entityType ..]
|
||||
|
||||
if entityType = 4
|
||||
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd]
|
||||
else
|
||||
[..]
|
|
@ -22,4 +22,11 @@ Entities :
|
|||
Weight :
|
||||
50
|
||||
|
||||
$
|
||||
$
|
||||
entities:
|
||||
[x, y, z, w, h, d, rhz, rvt, red, green, blue, hp, damage, entityType ..]
|
||||
|
||||
if entityType = 4
|
||||
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd]
|
||||
else
|
||||
[..]
|
|
@ -11,6 +11,13 @@ Teleporters :
|
|||
[-5.0, 1.0, 9.0, 10.0, 2.0, 1.0, 0.0, 0.0, 0, 0, 255; 1, 0]
|
||||
|
||||
Weight :
|
||||
20
|
||||
50
|
||||
|
||||
$
|
||||
$
|
||||
entities:
|
||||
[x, y, z, w, h, d, rhz, rvt, red, green, blue, hp, damage, entityType ..]
|
||||
|
||||
if entityType = 4
|
||||
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd]
|
||||
else
|
||||
[..]
|
|
@ -15,4 +15,11 @@ Entities :
|
|||
Weight :
|
||||
50
|
||||
|
||||
$
|
||||
$
|
||||
entities:
|
||||
[x, y, z, w, h, d, rhz, rvt, red, green, blue, hp, damage, entityType ..]
|
||||
|
||||
if entityType = 4
|
||||
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd]
|
||||
else
|
||||
[..]
|
|
@ -0,0 +1,28 @@
|
|||
Blocks :
|
||||
[-10.0, 0.0, -10.0, 20.0, 1.0, 20.0, 0.0, 0.0, 192, 192, 192]
|
||||
|
||||
Teleporters :
|
||||
[-10.0, 1.0, -5.0, 1.0, 2.0, 10.0, 0.0, 0.0, 255, 0, 0; 0, -1]
|
||||
[-5.0, 1.0, -10.0, 10.0, 2.0, 1.0, 0.0, 0.0, 255, 255, 0; -1, 0]
|
||||
[9.0, 1.0, -5.0, 1.0, 2.0, 10.0, 0.0, 0.0, 0, 255, 0; 0, 1]
|
||||
[-5.0, 1.0, 9.0, 10.0, 2.0, 1.0, 0.0, 0.0, 0, 0, 255; 1, 0]
|
||||
|
||||
Entities:
|
||||
[-15.0, 4.0, -15.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 128, 192, 10, 0, 4, 0.0, 5.0, 0.0, 50, 1, 90]
|
||||
[-5.0, 9.0, -15.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 128, 192, 10, 0, 4, 5.0, 0.0, 0.0, 50, 1, 0]
|
||||
[0.0, 10.0, -5.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 128, 192, 10, 0, 4, 0.0, 0.0, 5.0, 50, 1, 270]
|
||||
|
||||
Weight :
|
||||
50
|
||||
|
||||
$
|
||||
entities:
|
||||
[x, y, z, w, h, d, rhz, rvt, red, green, blue, hp, damage, entityType ..]
|
||||
|
||||
if entityType = 4 (moving platform)
|
||||
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd, phase] with
|
||||
amplitude_{x,y,z} = doubles[>= 0.0]
|
||||
{mult,divd} = int
|
||||
{phase} = int[0, 360]
|
||||
else
|
||||
[..]
|
Loading…
Reference in New Issue