Compare commits
2 Commits
7b79815188
...
1859c47de2
Author | SHA1 | Date |
---|---|---|
|
1859c47de2 | |
|
65c009e3af |
BIN
obj/entities.o
BIN
obj/entities.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.
|
@ -111,7 +111,7 @@ void translatePlayer(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
||||||
//printf("(%lf %lf) (%lf %lf) (%lf %lf)\n", vx, camvx, vy, camvy, vz, camvz);
|
//printf("(%lf %lf) (%lf %lf) (%lf %lf)\n", vx, camvx, vy, camvy, vz, camvz);
|
||||||
if(true) {
|
if(true) {
|
||||||
double oldvx = camvx;
|
double oldvx = camvx;
|
||||||
camvx += vx/dtime;
|
camvx = vx/dtime;
|
||||||
camx -= oldvx*dtime;
|
camx -= oldvx*dtime;
|
||||||
camx += camvx*dtime;
|
camx += camvx*dtime;
|
||||||
noResetSpeed = true;
|
noResetSpeed = true;
|
||||||
|
@ -121,15 +121,15 @@ void translatePlayer(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {
|
||||||
camvy += vy/dtime;
|
camvy += vy/dtime;
|
||||||
camy -= oldvy*dtime;
|
camy -= oldvy*dtime;
|
||||||
camy += camvy*dtime;
|
camy += camvy*dtime;
|
||||||
noResetSpeed = true;
|
|
||||||
}
|
}
|
||||||
if(true) {
|
if(true) {
|
||||||
double oldvz = camvz;
|
double oldvz = camvz;
|
||||||
camvz += vz/dtime;
|
camvz = vz/dtime;
|
||||||
camz -= oldvz*dtime;
|
camz -= oldvz*dtime;
|
||||||
camz += camvz*dtime;
|
camz += camvz*dtime;
|
||||||
noResetSpeed = true;
|
noResetSpeed = true;
|
||||||
}
|
}
|
||||||
|
noFriction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
|
@ -178,6 +178,7 @@ int main_alt() {
|
||||||
init_hashtbl();
|
init_hashtbl();
|
||||||
init_ent_generator(10);
|
init_ent_generator(10);
|
||||||
init_proj();
|
init_proj();
|
||||||
|
init_interf();
|
||||||
parse_rooms(6);
|
parse_rooms(6);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------------------------------- //
|
// ---------------------------------------------------------------------------------------------------------------------------------------------- //
|
||||||
|
@ -360,6 +361,7 @@ int main_alt() {
|
||||||
|
|
||||||
hashtbl_free(visited);
|
hashtbl_free(visited);
|
||||||
free_proj();
|
free_proj();
|
||||||
|
free_interf();
|
||||||
free_pool();
|
free_pool();
|
||||||
|
|
||||||
// optional: de-allocate all resources once they've outlived their purpose:
|
// optional: de-allocate all resources once they've outlived their purpose:
|
||||||
|
|
13
src/menus.c
13
src/menus.c
|
@ -132,3 +132,16 @@ void gl_drawInteger(unsigned int fragShader, int n, float x, float y, float size
|
||||||
void gl_initDrawRect(unsigned int shaderProgram) {
|
void gl_initDrawRect(unsigned int shaderProgram) {
|
||||||
glUseProgram(shaderProgram);
|
glUseProgram(shaderProgram);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static onoff_button* buttonList;
|
||||||
|
static interface* interfaceList;
|
||||||
|
|
||||||
|
void init_interf() {
|
||||||
|
buttonList = malloc(sizeof(onoff_button)*256);
|
||||||
|
interfaceList = malloc(sizeof(interface)*64);
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_interf() {
|
||||||
|
free(buttonList);
|
||||||
|
free(interfaceList);
|
||||||
|
}
|
30
src/menus.h
30
src/menus.h
|
@ -1,6 +1,33 @@
|
||||||
#ifndef MENUS_H
|
#ifndef MENUS_H
|
||||||
#define MENUS_H
|
#define MENUS_H
|
||||||
|
|
||||||
|
typedef enum button_action {WARP, SET_VAR} button_action ;
|
||||||
|
|
||||||
|
typedef struct onoff_button {
|
||||||
|
int id;
|
||||||
|
|
||||||
|
char* text;
|
||||||
|
double x; double y; double w; double h;
|
||||||
|
int red;
|
||||||
|
int green;
|
||||||
|
int blue;
|
||||||
|
|
||||||
|
// {WARP, SET_VAR}
|
||||||
|
button_action type;
|
||||||
|
|
||||||
|
// the value to change (if SET_VAR) or the destination interface (if WARP)
|
||||||
|
int* metadata;
|
||||||
|
} onoff_button;
|
||||||
|
|
||||||
|
typedef struct interface {
|
||||||
|
int intfid;
|
||||||
|
|
||||||
|
char* title;
|
||||||
|
|
||||||
|
onoff_button* buttons;
|
||||||
|
int nbuttons;
|
||||||
|
} interface;
|
||||||
|
|
||||||
void initMenus();
|
void initMenus();
|
||||||
|
|
||||||
void gl_drawRect(unsigned int fragShader, float x, float y, float w, float h, int r, int g, int b);
|
void gl_drawRect(unsigned int fragShader, float x, float y, float w, float h, int r, int g, int b);
|
||||||
|
@ -8,4 +35,7 @@ void gl_initDrawRect(unsigned int shaderProgram);
|
||||||
|
|
||||||
void gl_drawInteger(unsigned int fragShader, int n, float x, float y, float size, int r, int g, int b, float width, int side);
|
void gl_drawInteger(unsigned int fragShader, int n, float x, float y, float size, int r, int g, int b, float width, int side);
|
||||||
|
|
||||||
|
void init_interf();
|
||||||
|
void free_interf();
|
||||||
|
|
||||||
#endif
|
#endif
|
10
src/move.c
10
src/move.c
|
@ -25,6 +25,7 @@ double min_dist = 0.7;
|
||||||
double friction = 0.8;
|
double friction = 0.8;
|
||||||
double gravity_factor = 9.8;
|
double gravity_factor = 9.8;
|
||||||
bool noResetSpeed = false;
|
bool noResetSpeed = false;
|
||||||
|
bool noFriction = false;
|
||||||
// ---------------------------------------------------------------------------------------------------- //
|
// ---------------------------------------------------------------------------------------------------- //
|
||||||
|
|
||||||
int player_hp;
|
int player_hp;
|
||||||
|
@ -123,35 +124,44 @@ bool is_colliding(float dtime) {
|
||||||
void movePlayerG(double dtime) {
|
void movePlayerG(double dtime) {
|
||||||
camx += camvx*dtime;
|
camx += camvx*dtime;
|
||||||
noResetSpeed = false;
|
noResetSpeed = false;
|
||||||
|
noFriction = false;
|
||||||
if(is_colliding(dtime)) {
|
if(is_colliding(dtime)) {
|
||||||
camx -= camvx*dtime;
|
camx -= camvx*dtime;
|
||||||
if(!noResetSpeed) {
|
if(!noResetSpeed) {
|
||||||
camvx = 0.0;
|
camvx = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!noFriction) {
|
||||||
camvx = camvx*(1-dtime*friction);
|
camvx = camvx*(1-dtime*friction);
|
||||||
|
}
|
||||||
|
|
||||||
camvy -= gravity_factor*dtime;
|
camvy -= gravity_factor*dtime;
|
||||||
camy += camvy*dtime;
|
camy += camvy*dtime;
|
||||||
noResetSpeed = false;
|
noResetSpeed = false;
|
||||||
|
noFriction = false;
|
||||||
if(is_colliding(dtime)) {
|
if(is_colliding(dtime)) {
|
||||||
camy -= camvy*dtime;
|
camy -= camvy*dtime;
|
||||||
if(!noResetSpeed) {
|
if(!noResetSpeed) {
|
||||||
camvy = 0.0;
|
camvy = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!noFriction) {
|
||||||
camvy = camvy*(1-dtime*friction);
|
camvy = camvy*(1-dtime*friction);
|
||||||
|
}
|
||||||
|
|
||||||
camz += camvz*dtime;
|
camz += camvz*dtime;
|
||||||
noResetSpeed = false;
|
noResetSpeed = false;
|
||||||
|
noFriction = false;
|
||||||
if(is_colliding(dtime)) {
|
if(is_colliding(dtime)) {
|
||||||
camz -= camvz*dtime;
|
camz -= camvz*dtime;
|
||||||
if(!noResetSpeed) {
|
if(!noResetSpeed) {
|
||||||
camvz = 0.0;
|
camvz = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!noFriction) {
|
||||||
camvz = camvz*(1-dtime*friction);
|
camvz = camvz*(1-dtime*friction);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void teleport_on_edge() {
|
void teleport_on_edge() {
|
||||||
if(camx >= room_width) {
|
if(camx >= room_width) {
|
||||||
|
|
|
@ -148,5 +148,6 @@ extern float rectDefault[18];
|
||||||
extern int triCount;
|
extern int triCount;
|
||||||
|
|
||||||
extern bool noResetSpeed;
|
extern bool noResetSpeed;
|
||||||
|
extern bool noFriction;
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue