fixed read_float incorrectly reading when -1.0 < x < 0.0 and updated textures
|
@ -21,6 +21,7 @@
|
||||||
"png.h": "c",
|
"png.h": "c",
|
||||||
"stdlib.h": "c",
|
"stdlib.h": "c",
|
||||||
"stb_image.h": "c",
|
"stb_image.h": "c",
|
||||||
"string.h": "c"
|
"string.h": "c",
|
||||||
|
"unistd.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ Blocks :
|
||||||
[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]
|
||||||
|
|
||||||
Entities:
|
Entities:
|
||||||
[-0.5 , 5.0, -0.5 , 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 0 , 10, 0, 0]
|
[-0.5 , 2.0, -0.5 , 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 0 , 5, 0, 0]
|
||||||
[-11.0, 0.0, -1.0 , 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1 , 0, 6, welcome here, 222, 222, 222]
|
[-11.0, 0.0, -1.0 , 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1 , 0, 6, welcome here, 222, 222, 222]
|
||||||
[9.0 , 0.0, -1.0 , 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 128, 1 , 0, 6, collect coins to advance, 222, 222, 111]
|
[9.0 , 0.0, -1.0 , 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 128, 1 , 0, 6, collect coins to advance, 222, 222, 111]
|
||||||
[-1.0 , 0.0, -11.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 128, 128, 1 , 0, 6, if HP goes to 0 its game over, 222, 222, 111]
|
[-1.0 , 0.0, -11.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 128, 128, 1 , 0, 6, if HP goes to 0 its game over, 222, 222, 111]
|
||||||
|
|
|
@ -14,6 +14,7 @@ Entities :
|
||||||
[ 1.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[ 1.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, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[-2.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
[ 1.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[ 1.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
|
[-0.5, 8.0, -0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255 128, 2, 0, 0]
|
||||||
[-2.0, 1.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 5, 0.0, 0.0, 13.7, 0.0, 0.0, 12.0]
|
[-2.0, 1.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 5, 0.0, 0.0, 13.7, 0.0, 0.0, 12.0]
|
||||||
[-2.0, 15.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 5, 0.0, 0.0, 13.7, 0.0, 0.0, 12.5]
|
[-2.0, 15.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 5, 0.0, 0.0, 13.7, 0.0, 0.0, 12.5]
|
||||||
[-13.0, 7.5, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 7.5, 0.0, 0.0, 10.0, 0.0]
|
[-13.0, 7.5, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 7.5, 0.0, 0.0, 10.0, 0.0]
|
||||||
|
|
|
@ -14,6 +14,7 @@ Entities :
|
||||||
[ 1.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[ 1.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, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[-2.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
[ 1.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[ 1.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
|
[-0.5, 8.0, -0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255 128, 2, 0, 0]
|
||||||
[-2.0, 1.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 5, 13.7, 0.0, 0.0, 12.0, 0.0, 0.0]
|
[-2.0, 1.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 5, 13.7, 0.0, 0.0, 12.0, 0.0, 0.0]
|
||||||
[-2.0, 15.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 5, 13.7, 0.0, 0.0, 12.5, 0.0, 0.0]
|
[-2.0, 15.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 5, 13.7, 0.0, 0.0, 12.5, 0.0, 0.0]
|
||||||
[-2.0, 7.5, -13.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 7.5, 0.0, 0.0, 10.0, 0.0]
|
[-2.0, 7.5, -13.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 7.5, 0.0, 0.0, 10.0, 0.0]
|
||||||
|
|
|
@ -14,6 +14,7 @@ Entities :
|
||||||
[ 1.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[ 1.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, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[-2.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
[ 1.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[ 1.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
|
[-0.5, 8.0, -0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255 128, 2, 0, 0]
|
||||||
[-2.0, 1.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 4, 0.0, 0.0, 13.7, 1, 1, 0]
|
[-2.0, 1.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 4, 0.0, 0.0, 13.7, 1, 1, 0]
|
||||||
[-2.0, 15.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 4, 0.0, 0.0, 13.7, 1, 1, 180]
|
[-2.0, 15.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 4, 0.0, 0.0, 13.7, 1, 1, 180]
|
||||||
[-13.0, 7.5, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 0.0, 7.5, 0.0, 4, 3, 90]
|
[-13.0, 7.5, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 0.0, 7.5, 0.0, 4, 3, 90]
|
||||||
|
|
|
@ -14,6 +14,7 @@ Entities :
|
||||||
[ 1.0, 16.2, -2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[ 1.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, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[-2.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
[ 1.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
[ 1.0, 16.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 2, 0, 0]
|
||||||
|
[-0.5, 8.0, -0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255 128, 2, 0, 0]
|
||||||
[-2.0, 1.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 4, 13.7, 0.0, 0.0, 1, 1, 0]
|
[-2.0, 1.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 4, 13.7, 0.0, 0.0, 1, 1, 0]
|
||||||
[-2.0, 15.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 4, 13.7, 0.0, 0.0, 1, 1, 180]
|
[-2.0, 15.0, -2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 4, 13.7, 0.0, 0.0, 1, 1, 180]
|
||||||
[-2.0, 7.5, -13.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 0.0, 7.5, 0.0, 4, 3, 90]
|
[-2.0, 7.5, -13.0, 4.0, 1.0, 4.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 0.0, 7.5, 0.0, 4, 3, 90]
|
||||||
|
|
|
@ -16,44 +16,3 @@ Weight :
|
||||||
0
|
0
|
||||||
|
|
||||||
$
|
$
|
||||||
blocks:
|
|
||||||
[x, y, z, w, h, d, rhz, rvt, r, g, b]
|
|
||||||
|
|
||||||
teleporters:
|
|
||||||
[x, y, z, w, h, d, rhz, rvt, r, g, b, dest_chx, dest_chy]
|
|
||||||
|
|
||||||
entities:
|
|
||||||
[x, y, z, w, h, d, rhz, rvt, r, g, b, hp, damage, entityType ..]
|
|
||||||
// Entity types are :
|
|
||||||
// 0 (coin) -> damage equals the coin's value
|
|
||||||
// 1 (still explosive)
|
|
||||||
// 2 (seeking explosive)
|
|
||||||
// 3 (shooting still explosive)
|
|
||||||
// if entityType = 4 (moving platform)
|
|
||||||
[.. amplitude_x, amplitude_y, amplitude_z, mult, divd, phase] with
|
|
||||||
amplitude_{x,y,z} = double[>= 0.0]
|
|
||||||
{mult,divd} = int
|
|
||||||
{phase} = int[0, 360]
|
|
||||||
|
|
||||||
// else if entityType = 5 (linear moving platform)
|
|
||||||
[.. amplitude_x, amplitude_y, amplitude_z, speed_x, speed_y, speed_z] with
|
|
||||||
amplitude_{x,y,z} = double[>= 0.0]
|
|
||||||
speed_{x,y,z} = double
|
|
||||||
|
|
||||||
// else if entityType = 6 (text box)
|
|
||||||
[.. text, tred, tgreen, tblue] with
|
|
||||||
text = {char*}
|
|
||||||
|
|
||||||
// else if entityType = 7 (warp text box)
|
|
||||||
[.. dest_folder, room_count, text, tred, tgreen, tblue] with
|
|
||||||
{dest_folder,text} = {char*} (length <= 50)
|
|
||||||
{r,g,b} = int[0-256]
|
|
||||||
|
|
||||||
|
|
||||||
// else if entityType = 8 (lock box)
|
|
||||||
[.. cost, doPay, tred, tgreen, tblue] with
|
|
||||||
cost = int[> 0] (0 breaks)
|
|
||||||
doPay = {0, 1} (bool)
|
|
||||||
|
|
||||||
else
|
|
||||||
[..]
|
|
BIN
obj/display.o
BIN
obj/entities.o
BIN
obj/generation.o
BIN
obj/main.o
BIN
obj/menus.o
BIN
obj/move.o
After Width: | Height: | Size: 244 KiB |
BIN
res/beat_off.png
Before Width: | Height: | Size: 245 B |
BIN
res/beat_on.png
Before Width: | Height: | Size: 713 B |
After Width: | Height: | Size: 127 KiB |
After Width: | Height: | Size: 24 KiB |
BIN
res/lock.png
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 2.2 KiB |
|
@ -258,3 +258,13 @@ void gl_drawData(unsigned int shaderProg) {
|
||||||
gl_printf(shaderProg, -0.95f, 0.8f, 0.04f, 0.004f, 255, 255, 0, "coins %d", coins);
|
gl_printf(shaderProg, -0.95f, 0.8f, 0.04f, 0.004f, 255, 255, 0, "coins %d", coins);
|
||||||
//gl_drawInteger(shaderProg, player_hp, -0.95f, 0.9f, 0.05f, 255-player_hp/4, player_hp/4, 0, 0.005f, 1);
|
//gl_drawInteger(shaderProg, player_hp, -0.95f, 0.9f, 0.05f, 255-player_hp/4, player_hp/4, 0, 0.005f, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float fadeSideWidth = 0.08f;
|
||||||
|
void gl_drawDamageFadeout(unsigned int shaderProg) {
|
||||||
|
if(dmgCD > 0.0f) {
|
||||||
|
gl_drawRectAlpha(shaderProg, -1.0f , -1.0f , 2.0f, fadeSideWidth, 255, 32, 32, (int)(dmgCD*510.0f));
|
||||||
|
gl_drawRectAlpha(shaderProg, -1.0f , 1.0f-fadeSideWidth, 2.0f, fadeSideWidth, 255, 32, 32, (int)(dmgCD*510.0f));
|
||||||
|
gl_drawRectAlpha(shaderProg, -1.0f , -1.0f+fadeSideWidth, fadeSideWidth, 2.0f*(1.0-fadeSideWidth), 255, 32, 32, (int)(dmgCD*510.0f));
|
||||||
|
gl_drawRectAlpha(shaderProg, 1.0f-fadeSideWidth, -1.0f+fadeSideWidth, fadeSideWidth, 2.0f*(1.0-fadeSideWidth), 255, 32, 32, (int)(dmgCD*510.0f));
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,4 +11,6 @@ void gl_drawData(unsigned int shaderProg);
|
||||||
|
|
||||||
void gl_resetTexture();
|
void gl_resetTexture();
|
||||||
|
|
||||||
|
void gl_drawDamageFadeout(unsigned int shaderProg);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -306,6 +306,7 @@ void align_to(FILE* ptr, char ch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_neg0 = 1;
|
||||||
int read_int(FILE* ptr) {
|
int read_int(FILE* ptr) {
|
||||||
bool is_reading = false;
|
bool is_reading = false;
|
||||||
int buffer = 0;
|
int buffer = 0;
|
||||||
|
@ -318,13 +319,20 @@ int read_int(FILE* ptr) {
|
||||||
is_reading = true;
|
is_reading = true;
|
||||||
buffer = 10*buffer + (int)c - 48;
|
buffer = 10*buffer + (int)c - 48;
|
||||||
} else if(is_reading) {
|
} else if(is_reading) {
|
||||||
/*if(print) {
|
if(sign == -1 && buffer == 0) {
|
||||||
printf("%d; ", buffer*sign);
|
is_neg0 = -1;
|
||||||
}*/
|
} else {
|
||||||
|
is_neg0 = 1;
|
||||||
|
}
|
||||||
return buffer*sign;
|
return buffer*sign;
|
||||||
}
|
}
|
||||||
c = fgetc(ptr);
|
c = fgetc(ptr);
|
||||||
}
|
}
|
||||||
|
if(sign == -1 && buffer == 0) {
|
||||||
|
is_neg0 = -1;
|
||||||
|
} else {
|
||||||
|
is_neg0 = 1;
|
||||||
|
}
|
||||||
return buffer*sign;
|
return buffer*sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,13 +361,14 @@ double sign(double __x) {
|
||||||
|
|
||||||
double read_float(FILE* ptr) {
|
double read_float(FILE* ptr) {
|
||||||
int ent = read_int(ptr);
|
int ent = read_int(ptr);
|
||||||
|
int sn0 = is_neg0;
|
||||||
int frac = read_int(ptr);
|
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 sn0*(ent/abs(ent))*(absf((double)ent) + ((double)frac)/(pow(10.0, (double)ln_baseN(frac, 10))));
|
||||||
} else {
|
} else {
|
||||||
//printf("%d, %d\n", ent, frac);
|
//printf("%d, %d\n", ent, frac);
|
||||||
return ((double)frac)/(pow(10.0, (double)ln_baseN(frac, 10)));
|
return sn0*((double)frac)/(pow(10.0, (double)ln_baseN(frac, 10)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
69
src/main.c
|
@ -303,7 +303,7 @@ const char *fragmentShaderSourceR = "#version 330 core\n"
|
||||||
"}\0";
|
"}\0";
|
||||||
|
|
||||||
typedef enum file_extension {PNG, JPG, JPEG} file_extension;
|
typedef enum file_extension {PNG, JPG, JPEG} file_extension;
|
||||||
void generate_texture(int id, char* filename, file_extension ext) {
|
void generate_texture_2D(int id, char* filename, file_extension ext) {
|
||||||
int widthImg, heightImg, numColCh;
|
int widthImg, heightImg, numColCh;
|
||||||
//unsigned char* bytes = stbi_load("res/container.jpg", &widthImg, &heightImg, &numColCh, 0);
|
//unsigned char* bytes = stbi_load("res/container.jpg", &widthImg, &heightImg, &numColCh, 0);
|
||||||
unsigned char* bytes = stbi_load(filename, &widthImg, &heightImg, &numColCh, 0);
|
unsigned char* bytes = stbi_load(filename, &widthImg, &heightImg, &numColCh, 0);
|
||||||
|
@ -330,6 +330,34 @@ void generate_texture(int id, char* filename, file_extension ext) {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*void generate_texture_3D(int id, char* filename, file_extension ext) {
|
||||||
|
int widthImg, heightImg, depthImg, numColCh;
|
||||||
|
//unsigned char* bytes = stbi_load("res/container.jpg", &widthImg, &heightImg, &numColCh, 0);
|
||||||
|
unsigned char* bytes = stbi_load(filename, &widthImg, &heightImg, &numColCh, 0);
|
||||||
|
if(bytes == 0) {fprintf(stderr, "ERROR : cannot load texture\n"); exit(1);}
|
||||||
|
glGenTextures(1, &textures[id]);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_3D, textures[id]);
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
|
||||||
|
if(ext == JPG || ext == JPEG) {
|
||||||
|
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, widthImg, heightImg, depthImg, 0, GL_RGB, GL_UNSIGNED_BYTE, bytes);
|
||||||
|
glGenerateMipmap(GL_TEXTURE_3D);
|
||||||
|
} else if(ext == PNG) {
|
||||||
|
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, widthImg, heightImg, depthImg, 0, GL_RGBA, GL_UNSIGNED_BYTE, bytes);
|
||||||
|
glGenerateMipmap(GL_TEXTURE_3D);
|
||||||
|
}
|
||||||
|
|
||||||
|
stbi_image_free(bytes);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
}*/
|
||||||
|
|
||||||
int main_alt() {
|
int main_alt() {
|
||||||
// glfw: initialize and configure
|
// glfw: initialize and configure
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
|
@ -362,6 +390,9 @@ int main_alt() {
|
||||||
glCullFace(GL_FRONT);
|
glCullFace(GL_FRONT);
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
//glfwSetMouseButtonCallback(window, mouse_button_callback);
|
//glfwSetMouseButtonCallback(window, mouse_button_callback);
|
||||||
|
|
||||||
init_csts();
|
init_csts();
|
||||||
|
@ -436,18 +467,21 @@ int main_alt() {
|
||||||
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
|
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
|
||||||
// 16 max //
|
// 16 max //
|
||||||
|
|
||||||
//generate_texture(0, "res/container.jpg", "jpg");
|
//generate_texture_2D(0, "res/container.jpg", "jpg");
|
||||||
generate_texture(0, "res/white.png", PNG);
|
generate_texture_2D(0, "res/white.png", PNG);
|
||||||
generate_texture(1, "res/question_block.png", PNG);
|
generate_texture_2D(1, "res/question_block.png", PNG);
|
||||||
generate_texture(2, "res/exclamation_block.png", PNG);
|
generate_texture_2D(2, "res/exclamation_block.png", PNG);
|
||||||
generate_texture(3, "res/money.png", PNG);
|
//generate_texture_2D(3, "res/money.png", PNG);
|
||||||
generate_texture(4, "res/container.jpg", JPG);
|
generate_texture_2D(3, "res/coin2.png", JPG);
|
||||||
generate_texture(5, "res/steel.jpeg", JPEG);
|
generate_texture_2D(4, "res/container.jpg", JPG);
|
||||||
//generate_texture(5, "res/brick.png", JPEG);
|
//generate_texture_2D(4, "res/arrows.png", PNG);
|
||||||
generate_texture(6, "res/gateway.jpeg", JPEG);
|
generate_texture_2D(5, "res/steel.jpeg", JPEG);
|
||||||
generate_texture(7, "res/lock.png", PNG);
|
generate_texture_2D(6, "res/gateway.jpeg", JPEG);
|
||||||
generate_texture(8, "res/beat_on.png", JPG);
|
generate_texture_2D(7, "res/lock.png", PNG);
|
||||||
generate_texture(9, "res/beat_off.png", JPG);
|
//generate_texture_2D(8, "res/beat_on.png", JPG);
|
||||||
|
//generate_texture_2D(9, "res/beat_off.png", JPG);
|
||||||
|
generate_texture_2D(8, "res/sq_full.png", PNG);
|
||||||
|
generate_texture_2D(9, "res/sq_dotted.png", PNG);
|
||||||
|
|
||||||
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
|
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
|
||||||
|
|
||||||
|
@ -535,7 +569,7 @@ int main_alt() {
|
||||||
while(!glfwWindowShouldClose(window) && player_hp > 0) {
|
while(!glfwWindowShouldClose(window) && player_hp > 0) {
|
||||||
// input
|
// input
|
||||||
// -----
|
// -----
|
||||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
glClearColor(0.2f, 0.3f, 0.3f, 0.5f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
triCount = 0;
|
triCount = 0;
|
||||||
|
|
||||||
|
@ -564,6 +598,8 @@ int main_alt() {
|
||||||
gl_drawInteger(shaderProgramR, triCount, 0.0f, 0.92f, 0.04f, 128, 128, 128, 0.005f, 1);
|
gl_drawInteger(shaderProgramR, triCount, 0.0f, 0.92f, 0.04f, 128, 128, 128, 0.005f, 1);
|
||||||
gl_drawData(shaderProgramR);
|
gl_drawData(shaderProgramR);
|
||||||
|
|
||||||
|
gl_drawDamageFadeout(shaderProgramR);
|
||||||
|
|
||||||
if(!isInMenu(window, shaderProgramR)) {
|
if(!isInMenu(window, shaderProgramR)) {
|
||||||
processInput(window, delta);
|
processInput(window, delta);
|
||||||
if(gamemode == 0) {
|
if(gamemode == 0) {
|
||||||
|
@ -581,6 +617,11 @@ int main_alt() {
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
|
dmgCD = maxf(dmgCD - delta, 0.0f);
|
||||||
|
if(lastDmg != player_hp) {
|
||||||
|
lastDmg = player_hp;
|
||||||
|
dmgCD = 0.5f;
|
||||||
|
}
|
||||||
finish = clock();
|
finish = clock();
|
||||||
delta = slp_time+((float)finish - (float)origin)/CLOCKS_PER_SEC;
|
delta = slp_time+((float)finish - (float)origin)/CLOCKS_PER_SEC;
|
||||||
deltad = slp_time+((double)finish - (double)origin)/CLOCKS_PER_SEC;
|
deltad = slp_time+((double)finish - (double)origin)/CLOCKS_PER_SEC;
|
||||||
|
|
22
src/menus.c
|
@ -8,7 +8,7 @@
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <glad/glad.h>
|
//#include <glad/glad.h>
|
||||||
#include "../include/glad/glad.h"
|
#include "../include/glad/glad.h"
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <cglm/cglm.h>
|
#include <cglm/cglm.h>
|
||||||
|
@ -47,7 +47,25 @@ void gl_drawRect(unsigned int fragShader, float x, float y, float w, float h, in
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(fragShader, "scale"), 1, GL_FALSE, (float*)scale);
|
glUniformMatrix4fv(glGetUniformLocation(fragShader, "scale"), 1, GL_FALSE, (float*)scale);
|
||||||
glUniformMatrix4fv(glGetUniformLocation(fragShader, "slide"), 1, GL_FALSE, (float*)slide);
|
glUniformMatrix4fv(glGetUniformLocation(fragShader, "slide"), 1, GL_FALSE, (float*)slide);
|
||||||
glUniform4f(glGetUniformLocation(fragShader, "u_color2"), r/255.0f, g/255.0f, b/255.0f, 0.5f);
|
glUniform4f(glGetUniformLocation(fragShader, "u_color2"), r/255.0f, g/255.0f, b/255.0f, 1.0f);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gl_drawRectAlpha(unsigned int fragShader, float x, float y, float w, float h, int r, int g, int b, int a) {
|
||||||
|
glm_mat4_identity(scale);
|
||||||
|
glm_mat4_identity(slide);
|
||||||
|
|
||||||
|
scale[0][0] = w;
|
||||||
|
scale[1][1] = h;
|
||||||
|
scale[2][2] = 0.5f+incr;
|
||||||
|
incr += 0.000001f;
|
||||||
|
|
||||||
|
glm_translate(slide, (vec3){x+w/2, y+h/2, 0.0f});
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(fragShader, "scale"), 1, GL_FALSE, (float*)scale);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(fragShader, "slide"), 1, GL_FALSE, (float*)slide);
|
||||||
|
glUniform4f(glGetUniformLocation(fragShader, "u_color2"), r/255.0f, g/255.0f, b/255.0f, a/255.0f);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ typedef struct 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);
|
||||||
|
void gl_drawRectAlpha(unsigned int fragShader, float x, float y, float w, float h, int r, int g, int b, int a);
|
||||||
void gl_initDrawRect(unsigned int shaderProgram);
|
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);
|
||||||
|
|
|
@ -61,6 +61,9 @@ double room_depth;
|
||||||
|
|
||||||
double sq2;
|
double sq2;
|
||||||
|
|
||||||
|
float dmgCD;
|
||||||
|
int lastDmg;
|
||||||
|
|
||||||
void init_csts() {
|
void init_csts() {
|
||||||
camx = 2.0;
|
camx = 2.0;
|
||||||
camy = 5.0;
|
camy = 5.0;
|
||||||
|
@ -83,6 +86,9 @@ void init_csts() {
|
||||||
draw_type = 0;
|
draw_type = 0;
|
||||||
fade_dmg = 0;
|
fade_dmg = 0;
|
||||||
|
|
||||||
|
dmgCD = 0.0f;
|
||||||
|
lastDmg = player_hp;
|
||||||
|
|
||||||
stop_evetything = false;
|
stop_evetything = false;
|
||||||
tan_fov = tan((fov * 3.14159 / 180.0) / 2.0);
|
tan_fov = tan((fov * 3.14159 / 180.0) / 2.0);
|
||||||
sq2 = sqrt(2);
|
sq2 = sqrt(2);
|
||||||
|
|
|
@ -187,4 +187,7 @@ extern bool is_one_room;
|
||||||
|
|
||||||
extern unsigned int textures[16];
|
extern unsigned int textures[16];
|
||||||
|
|
||||||
|
extern float dmgCD;
|
||||||
|
extern int lastDmg;
|
||||||
|
|
||||||
#endif
|
#endif
|