added mods
This commit is contained in:
parent
563dd34ea5
commit
530d0e1283
BIN
obj/display.o
BIN
obj/display.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.
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
|
@ -74,11 +74,6 @@ void gl_renderTriangle(unsigned int shaderProgram, unsigned int VAO, unsigned in
|
|||
double near = 0.0 ;
|
||||
double far = 10.0 ;
|
||||
|
||||
double top = 1.0 ;
|
||||
double bottom = -1.0 ;
|
||||
double left = -1.0 ;
|
||||
double right = 1.0 ;
|
||||
|
||||
mat4 model, view, projection;
|
||||
mat4 scale;
|
||||
mat2 texShift;
|
||||
|
@ -242,7 +237,7 @@ void gl_initRender(unsigned int shaderProgram, unsigned int fragmentShader, unsi
|
|||
glm_mat4_identity(view);
|
||||
glm_lookat((vec3){(float)camx, (float)camy, (float)camz}, direction, (vec3){0.0f, 1.0f, 0.0f}, view);
|
||||
|
||||
glm_perspective(glm_rad((float)fov), 1500.0f / 1000.0f, 0.1f, 100.0f, projection);
|
||||
glm_perspective(glm_rad((float)fov), 1500.0f / 1000.0f, 0.1f, 100.0f*((float)bounding_mult), projection);
|
||||
|
||||
loc_scale = glGetUniformLocation(shaderProgram, "scale");
|
||||
loc_model = glGetUniformLocation(shaderProgram, "model");
|
||||
|
|
45
src/main.c
45
src/main.c
|
@ -9,6 +9,7 @@
|
|||
#include <time.h>
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <cglm/cglm.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifndef STB_IMAGE_IMPLEMENTATION
|
||||
|
@ -34,8 +35,6 @@ int gamemode;
|
|||
|
||||
int creativeWarpTarget;
|
||||
|
||||
static double time_dilation = 1.0;
|
||||
|
||||
char* newRoomName;
|
||||
int newRoomCount;
|
||||
bool switchRoom;
|
||||
|
@ -59,6 +58,8 @@ int kodami[10] = {GLFW_KEY_UP, GLFW_KEY_UP, GLFW_KEY_DOWN, GLFW_KEY_DOWN, GLFW_K
|
|||
int kodid = 0;
|
||||
bool kodhit = false;
|
||||
|
||||
cube_0* modCube;
|
||||
|
||||
void reset_everything(GLFWwindow *window, int count, char* folder) {
|
||||
oldx = camx;
|
||||
oldy = camy;
|
||||
|
@ -151,7 +152,7 @@ void processInput(GLFWwindow *window, float dtime) {
|
|||
}
|
||||
|
||||
// kodami
|
||||
if(!kodhit) {
|
||||
if(!kodhit && is_SD == 0) { // no cheating with SD !
|
||||
if(kodid == 10) {
|
||||
kodhit = true;
|
||||
player_hp += 1500;
|
||||
|
@ -595,6 +596,11 @@ int main_alt() {
|
|||
generate_texture_2D(13, "res/tnt.png", PNG);
|
||||
generate_texture_2D(14, "res/minecraft_lava.jpg", JPG);
|
||||
|
||||
//generate_texture_2D(15, "res/selection-mod-doubletime.png", PNG);
|
||||
//generate_texture_2D(16, "res/selection-mod-hardrock.png", PNG);
|
||||
//generate_texture_2D(17, "res/selection-mod-flashlight.png", PNG);
|
||||
//generate_texture_2D(18, "res/selection-mod-suddendeath.png", PNG);
|
||||
|
||||
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------------------- //
|
||||
|
@ -686,6 +692,9 @@ int main_alt() {
|
|||
mathSignal = true;
|
||||
float calc_T = 0.0f;
|
||||
|
||||
vec3 md_dir0;
|
||||
vec3 md_direction;
|
||||
|
||||
while(!glfwWindowShouldClose(window) && player_hp > 0) {
|
||||
gettimeofday(&ogn, NULL);
|
||||
// input
|
||||
|
@ -711,6 +720,33 @@ int main_alt() {
|
|||
gl_renderProj();
|
||||
//printf("4\n"); fflush(stdout);
|
||||
|
||||
/*if(is_DT + is_HR + is_FL >= 1) {
|
||||
md_dir0[0] = sinf((float)(rot_hz)) * cosf((float)(rot_vt));
|
||||
md_dir0[1] = -sinf((float)(rot_vt));
|
||||
md_dir0[2] = cosf((float)(rot_hz)) * cosf((float)(rot_vt));
|
||||
|
||||
glm_vec3_normalize(md_dir0); // Normalize to unit length
|
||||
glm_vec3_add((vec3){(float)camx, (float)camy, (float)camz}, md_dir0, md_direction);
|
||||
|
||||
fill_cube_0(modCube, md_direction[0], md_direction[1], md_direction[2], 0.2f, 0.2f, 0.2f, -rot_hz, 0.0, 255, 255, 255);
|
||||
|
||||
if(is_DT == 1) {
|
||||
glBindTexture(GL_TEXTURE_2D, textures[15]);
|
||||
gl_renderCube(modCube, 0.0, 0.0, 0.0);
|
||||
modCube->y += 0.2;
|
||||
}
|
||||
if(is_HR == 1) {
|
||||
glBindTexture(GL_TEXTURE_2D, textures[16]);
|
||||
gl_renderCube(modCube, 0.0, 0.0, 0.0);
|
||||
modCube->y += 0.2;
|
||||
}
|
||||
if(is_FL == 1) {
|
||||
glBindTexture(GL_TEXTURE_2D, textures[17]);
|
||||
gl_renderCube(modCube, 0.0, 0.0, 0.0);
|
||||
modCube->y += 0.2;
|
||||
}
|
||||
}*/
|
||||
|
||||
// draw data
|
||||
glUseProgram(shaderProgramR);
|
||||
glBindVertexArray(RVAO);
|
||||
|
@ -763,6 +799,8 @@ int main_alt() {
|
|||
if(lastDmg != player_hp) {
|
||||
if(lastDmg > player_hp) {
|
||||
dmgCD = 0.5f;
|
||||
int taken = lastDmg - player_hp;
|
||||
player_hp -= taken*((int)(damage_scaling-1.0));
|
||||
}
|
||||
lastDmg = player_hp;
|
||||
}
|
||||
|
@ -820,6 +858,7 @@ int main(int argc, char** argv) {
|
|||
switchRoom = false;
|
||||
newRoomName = "templates/";
|
||||
creativeWarpTarget = 0;
|
||||
modCube = malloc(sizeof(cube_0));
|
||||
//play_sound("sound/audio/tetris_2.wav");
|
||||
//tstst();
|
||||
return main_alt();
|
||||
|
|
58
src/menus.c
58
src/menus.c
|
@ -24,6 +24,15 @@ float incr;
|
|||
|
||||
int creativeIntID;
|
||||
|
||||
int is_DT = 0;
|
||||
int is_HR = 0;
|
||||
int is_FL = 0;
|
||||
int is_SD = 0;
|
||||
|
||||
double time_dilation = 1.0;
|
||||
double damage_scaling = 1.0;
|
||||
double bounding_mult = 1.0;
|
||||
|
||||
static mat4 scale, slide;
|
||||
void initMenus() {
|
||||
rectDefault[0] = -0.5f; rectDefault[1] = -0.5f; rectDefault[2] = -0.99f;
|
||||
|
@ -837,19 +846,23 @@ int button_ok;
|
|||
int button_pay;
|
||||
|
||||
int welcome_start_i, settings_i;
|
||||
int modMenu_i;
|
||||
void build_all_menus() {
|
||||
init_math_interfaces();
|
||||
creativeIntID = build_creative_warp();
|
||||
modMenu_i = build_mod_menu();
|
||||
|
||||
welcome_start_i = interface_create("Welcome", 255, 255, 255, -0.4f, 0.7f, 0.8f, 0.25f);
|
||||
settings_i = interface_create("Settings", 128, 128, 128, -0.4f, 0.7f, 0.8f, 0.25f);
|
||||
|
||||
int welcome_start_go = button_create_onoff("start", 0, 255, 255, -0.25f, 0.05f, 0.5f, 0.3f, EXIT, NULL, 0.0, 0.0, INT, NULL, NULL);
|
||||
int welcome_start_settings = button_create_onoff("config", 96, 96, 96 , -0.25f, -0.35f, 0.5f, 0.3f, WARP, &settings_i, 0.0, 0.0, INT, NULL, NULL);
|
||||
int welcome_start_math = button_create_onoff("math config", 64, 64, 255, -0.25f, -0.75f, 0.5f, 0.3f, WARP, &mthInterface, 0.0, 0.0, INT, NULL, NULL);
|
||||
int welcome_start_go = button_create_onoff("start", 0, 255, 255, -0.25f, 0.25f, 0.5f, 0.22f, EXIT, NULL, 0.0, 0.0, INT, NULL, NULL);
|
||||
int welcome_start_settings = button_create_onoff("config", 96, 96, 96 , -0.25f, -0.05f, 0.5f, 0.22f, WARP, &settings_i, 0.0, 0.0, INT, NULL, NULL);
|
||||
int welcome_start_mods = button_create_onoff("mods", 255, 96, 96, -0.25f, -0.35f, 0.5f, 0.22f, WARP, &modMenu_i, 0.0, 0.0, INT, NULL, NULL);
|
||||
int welcome_start_math = button_create_onoff("math config", 64, 64, 255, -0.25f, -0.65f, 0.5f, 0.22f, WARP, &mthInterface, 0.0, 0.0, INT, NULL, NULL);
|
||||
|
||||
interface_link_button(welcome_start_i, welcome_start_go);
|
||||
interface_link_button(welcome_start_i, welcome_start_settings);
|
||||
interface_link_button(welcome_start_i, welcome_start_mods);
|
||||
interface_link_button(welcome_start_i, welcome_start_math);
|
||||
|
||||
int settings_speed = button_create_onoff("speed", 0, 192, 192, -0.25f, 0.2f, 0.5f, 0.3f, SET_VAR, &speed, 0.1, 20.0, DOUBLE, NULL, NULL);
|
||||
|
@ -897,4 +910,43 @@ int build_creative_warp() {
|
|||
interface_link_button(intid, warpGTFO);
|
||||
|
||||
return intid;
|
||||
}
|
||||
|
||||
/*
|
||||
int is_DT = 0;
|
||||
int is_HR = 0;
|
||||
int is_FL = 0;
|
||||
|
||||
double time_dilation = 1.0;
|
||||
double damage_scaling = 1.0;
|
||||
double bounding_mult = 1.0;
|
||||
*/
|
||||
|
||||
void update_values(void* arg) {
|
||||
time_dilation = 1.0+0.5*(is_DT==1);
|
||||
damage_scaling = 1.0+8.0*(is_HR==1);
|
||||
bounding_mult = 1.0-0.93*(is_FL==1);
|
||||
if(is_SD) {
|
||||
player_hp = 1;
|
||||
} else {
|
||||
player_hp = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
int build_mod_menu() {
|
||||
int modMenuId = interface_create("mods", 200, 200, 200, -1.0, 0.7, 2.0, 0.3);
|
||||
|
||||
int btnDT = button_create_onoff("double time", 96,210,210, -0.25f, 0.25f, 0.5f, 0.2f, SET_VAR, &is_DT, 0, 1, INT, NULL, NULL);
|
||||
int btnHR = button_create_onoff("hard rock", 210, 96, 96, -0.25f, -0.05f, 0.5f, 0.2f, SET_VAR, &is_HR, 0, 1, INT, NULL, NULL);
|
||||
int btnFL = button_create_onoff("flashlight", 32, 32, 32, -0.25f, -0.35f, 0.5f, 0.2f, SET_VAR, &is_FL, 0, 1, INT, NULL, NULL);
|
||||
int btnSD = button_create_onoff("sudden death",210,210,32, -0.25f, -0.65f, 0.5f, 0.2f, SET_VAR, &is_SD, 0, 1, INT, NULL, NULL);
|
||||
int exit = button_create_onoff("exit", 128, 128, 128, -0.25f, -0.95f, 0.5f, 0.2f, WARP, &welcome_start_i, 0, 1, INT, update_values, NULL);
|
||||
|
||||
interface_link_button(modMenuId, btnDT);
|
||||
interface_link_button(modMenuId, btnHR);
|
||||
interface_link_button(modMenuId, btnFL);
|
||||
interface_link_button(modMenuId, btnSD);
|
||||
interface_link_button(modMenuId, exit);
|
||||
|
||||
return modMenuId;
|
||||
}
|
|
@ -70,5 +70,6 @@ int build_text_box(char* msg, int red, int green, int blue);
|
|||
int build_lock_box(char* msg, int red, int green, int blue);
|
||||
|
||||
int build_creative_warp();
|
||||
int build_mod_menu();
|
||||
|
||||
#endif
|
|
@ -207,4 +207,9 @@ extern mathRes mathResult;
|
|||
extern int creativeWarpTarget;
|
||||
extern int creativeIntID;
|
||||
|
||||
extern double time_dilation; extern int is_DT;
|
||||
extern double damage_scaling; extern int is_HR;
|
||||
extern double bounding_mult; extern int is_FL;
|
||||
extern int is_SD;
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue