Compare commits

..

No commits in common. "5a2f68c741f2b16b783e0d9808140c493a0decd0" and "0bb2d0da9fb86bf8d51be09b555f6b7391e497c5" have entirely different histories.

31 changed files with 74 additions and 8149 deletions

View File

@ -17,9 +17,6 @@
"entities.h": "c",
"menus.h": "c",
"structure.h": "c",
"limits.h": "c",
"png.h": "c",
"stdlib.h": "c",
"stb_image.h": "c"
"limits.h": "c"
}
}

View File

@ -1,6 +1,6 @@
CC = gcc
FLAGS = -Wall -Wextra -g
LFLAGS = -lm src/glad.c -ldl -lglfw -lcglm -lpng -lSOIL
LFLAGS = -lm src/glad.c -ldl -lglfw -lcglm
all: bin/back

BIN
bin/back

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -9,6 +9,7 @@
#include <time.h>
#include "hash.h"
#include "structure.h"
#include "base.h"
int ln_baseN(int n, int b) {

View File

@ -9,6 +9,7 @@
#include <time.h>
#include "hash.h"
#include "structure.h"
#include "base.h"
#include "move.h"
#include "entities.h"

View File

@ -12,6 +12,7 @@
#include <cglm/cglm.h>
#include "hash.h"
#include "structure.h"
#include "base.h"
#include "move.h"
#include "menus.h"
@ -26,13 +27,12 @@ int MAX_SIZE = 8192 ;
int* drawOrder ;
int loc_scale;
int loc_model;
int loc_view;
int loc_proj;
GLint loc_scale;
GLint loc_model;
GLint loc_view;
GLint loc_proj;
int loc_frag;
int loc_tex;
GLint loc_frag;
void init_draworder() {
drawOrder = malloc(sizeof(int)*6) ;
@ -79,51 +79,51 @@ double right = 1.0 ;
mat4 model, view, projection;
mat4 scale;
float vertices[180];
float vertices[108];
// -x ; +x ; -y ; +y ; -z ; +z //
void init_vertices() {
vertices[0] = -0.5f; vertices[1] = -0.5f; vertices[2] = -0.5f; vertices[3] = 0.0; vertices[4] = 1.0;
vertices[5] = -0.5f; vertices[6] = 0.5f; vertices[7] = -0.5f; vertices[8] = 0.0; vertices[9] = 0.0;
vertices[10] = -0.5f; vertices[11] = 0.5f; vertices[12] = 0.5f; vertices[13] = 1.0; vertices[14] = 0.0;
vertices[15] = -0.5f; vertices[16] = -0.5f; vertices[17] = -0.5f; vertices[18] = 0.0; vertices[19] = 1.0;
vertices[20] = -0.5f; vertices[21] = 0.5f; vertices[22] = 0.5f; vertices[23] = 1.0; vertices[24] = 0.0;
vertices[25] = -0.5f; vertices[26] = -0.5f; vertices[27] = 0.5f; vertices[28] = 1.0; vertices[29] = 1.0;
vertices[0] = -0.5f; vertices[1] = -0.5f; vertices[2] = -0.5f;
vertices[3] = -0.5f; vertices[4] = 0.5f; vertices[5] = -0.5f;
vertices[6] = -0.5f; vertices[7] = 0.5f; vertices[8] = 0.5f;
vertices[9] = -0.5f; vertices[10] = -0.5f; vertices[11] = -0.5f;
vertices[12] = -0.5f; vertices[13] = 0.5f; vertices[14] = 0.5f;
vertices[15] = -0.5f; vertices[16] = -0.5f; vertices[17] = 0.5f;
vertices[30] = 0.5f; vertices[31] = -0.5f; vertices[32] = -0.5f; vertices[33] = 1.0; vertices[34] = 1.0;
vertices[35] = 0.5f; vertices[36] = 0.5f; vertices[37] = 0.5f; vertices[38] = 0.0; vertices[39] = 0.0;
vertices[40] = 0.5f; vertices[41] = 0.5f; vertices[42] = -0.5f; vertices[43] = 1.0; vertices[44] = 0.0;
vertices[45] = 0.5f; vertices[46] = -0.5f; vertices[47] = -0.5f; vertices[48] = 1.0; vertices[49] = 1.0;
vertices[50] = 0.5f; vertices[51] = -0.5f; vertices[52] = 0.5f; vertices[53] = 0.0; vertices[54] = 1.0;
vertices[55] = 0.5f; vertices[56] = 0.5f; vertices[57] = 0.5f; vertices[58] = 0.0; vertices[59] = 0.0;
vertices[18] = 0.5f; vertices[19] = -0.5f; vertices[20] = -0.5f;
vertices[21] = 0.5f; vertices[22] = 0.5f; vertices[23] = 0.5f;
vertices[24] = 0.5f; vertices[25] = 0.5f; vertices[26] = -0.5f;
vertices[27] = 0.5f; vertices[28] = -0.5f; vertices[29] = -0.5f;
vertices[30] = 0.5f; vertices[31] = -0.5f; vertices[32] = 0.5f;
vertices[33] = 0.5f; vertices[34] = 0.5f; vertices[35] = 0.5f;
vertices[60] = -0.5f; vertices[61] = -0.5f; vertices[62] = -0.5f; vertices[63] = 0.0; vertices[64] = 1.0;
vertices[65] = 0.5f; vertices[66] = -0.5f; vertices[67] = 0.5f; vertices[68] = 1.0; vertices[69] = 0.0;
vertices[70] = 0.5f; vertices[71] = -0.5f; vertices[72] = -0.5f; vertices[73] = 0.0; vertices[74] = 0.0;
vertices[75] = -0.5f; vertices[76] = -0.5f; vertices[77] = -0.5f; vertices[78] = 0.0; vertices[79] = 1.0;
vertices[80] = -0.5f; vertices[81] = -0.5f; vertices[82] = 0.5f; vertices[83] = 1.0; vertices[84] = 1.0;
vertices[85] = 0.5f; vertices[86] = -0.5f; vertices[87] = 0.5f; vertices[88] = 1.0; vertices[89] = 0.0;
vertices[36] = -0.5f; vertices[37] = -0.5f; vertices[38] = -0.5f;
vertices[39] = 0.5f; vertices[40] = -0.5f; vertices[41] = 0.5f;
vertices[42] = 0.5f; vertices[43] = -0.5f; vertices[44] = -0.5f;
vertices[45] = -0.5f; vertices[46] = -0.5f; vertices[47] = -0.5f;
vertices[48] = -0.5f; vertices[49] = -0.5f; vertices[50] = 0.5f;
vertices[51] = 0.5f; vertices[52] = -0.5f; vertices[53] = 0.5f;
vertices[90] = -0.5f; vertices[91] = 0.5f; vertices[92] = -0.5f; vertices[93] = 1.0; vertices[94] = 1.0;
vertices[95] = 0.5f; vertices[96] = 0.5f; vertices[97] = -0.5f; vertices[98] = 1.0; vertices[99] = 0.0;
vertices[100] = 0.5f; vertices[101] = 0.5f; vertices[102] = 0.5f; vertices[103] = 0.0; vertices[104] = 0.0;
vertices[105] = -0.5f; vertices[106] = 0.5f; vertices[107] = -0.5f; vertices[108] = 1.0; vertices[109] = 1.0;
vertices[110] = 0.5f; vertices[111] = 0.5f; vertices[112] = 0.5f; vertices[113] = 0.0; vertices[114] = 0.0;
vertices[115] = -0.5f; vertices[116] = 0.5f; vertices[117] = 0.5f; vertices[118] = 0.0; vertices[119] = 1.0;
vertices[54] = -0.5f; vertices[55] = 0.5f; vertices[56] = -0.5f;
vertices[57] = 0.5f; vertices[58] = 0.5f; vertices[59] = -0.5f;
vertices[60] = 0.5f; vertices[61] = 0.5f; vertices[62] = 0.5f;
vertices[63] = -0.5f; vertices[64] = 0.5f; vertices[65] = -0.5f;
vertices[66] = 0.5f; vertices[67] = 0.5f; vertices[68] = 0.5f;
vertices[69] = -0.5f; vertices[70] = 0.5f; vertices[71] = 0.5f;
vertices[120] = -0.5f; vertices[121] = -0.5f; vertices[122] = -0.5f; vertices[123] = 1.0; vertices[124] = 1.0;
vertices[125] = 0.5f; vertices[126] = -0.5f; vertices[127] = -0.5f; vertices[128] = 0.0; vertices[129] = 1.0;
vertices[130] = 0.5f; vertices[131] = 0.5f; vertices[132] = -0.5f; vertices[133] = 0.0; vertices[134] = 0.0;
vertices[135] = -0.5f; vertices[136] = -0.5f; vertices[137] = -0.5f; vertices[138] = 1.0; vertices[139] = 1.0;
vertices[140] = 0.5f; vertices[141] = 0.5f; vertices[142] = -0.5f; vertices[143] = 0.0; vertices[144] = 0.0;
vertices[145] = -0.5f; vertices[146] = 0.5f; vertices[147] = -0.5f; vertices[148] = 1.0; vertices[149] = 0.0;
vertices[72] = -0.5f; vertices[73] = -0.5f; vertices[74] = -0.5f;
vertices[75] = 0.5f; vertices[76] = -0.5f; vertices[77] = -0.5f;
vertices[78] = 0.5f; vertices[79] = 0.5f; vertices[80] = -0.5f;
vertices[81] = -0.5f; vertices[82] = -0.5f; vertices[83] = -0.5f;
vertices[84] = 0.5f; vertices[85] = 0.5f; vertices[86] = -0.5f;
vertices[87] = -0.5f; vertices[88] = 0.5f; vertices[89] = -0.5f;
vertices[150] = -0.5f; vertices[151] = -0.5f; vertices[152] = 0.5f; vertices[153] = 0.0; vertices[154] = 1.0;
vertices[155] = 0.5f; vertices[156] = 0.5f; vertices[157] = 0.5f; vertices[158] = 1.0; vertices[159] = 0.0;
vertices[160] = 0.5f; vertices[161] = -0.5f; vertices[162] = 0.5f; vertices[163] = 1.0; vertices[164] = 1.0;
vertices[165] = -0.5f; vertices[166] = -0.5f; vertices[167] = 0.5f; vertices[168] = 0.0; vertices[169] = 1.0;
vertices[170] = -0.5f; vertices[171] = 0.5f; vertices[172] = 0.5f; vertices[173] = 0.0; vertices[174] = 0.0;
vertices[175] = 0.5f; vertices[176] = 0.5f; vertices[177] = 0.5f; vertices[178] = 1.0; vertices[179] = 0.0;
vertices[90] = -0.5f; vertices[91] = -0.5f; vertices[92] = 0.5f;
vertices[93] = 0.5f; vertices[94] = 0.5f; vertices[95] = 0.5f;
vertices[96] = 0.5f; vertices[97] = -0.5f; vertices[98] = 0.5f;
vertices[99] = -0.5f; vertices[100] = -0.5f; vertices[101] = 0.5f;
vertices[102] = -0.5f; vertices[103] = 0.5f; vertices[104] = 0.5f;
vertices[105] = 0.5f; vertices[106] = 0.5f; vertices[107] = 0.5f;
}
void gl_renderCube(unsigned int shaderProgram, unsigned int fragmentShader, unsigned int VAO, unsigned int VBO, cube_0* c, double offx, double offy, double offz) {
@ -144,7 +144,6 @@ void gl_renderCube(unsigned int shaderProgram, unsigned int fragmentShader, unsi
glUniform4f(loc_frag, c->red/255.0f, c->green/255.0f, c->blue/255.0f, 1.0f);
glDrawArrays(GL_TRIANGLES, 0, 36);
//glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0);
triCount += 12;
}
@ -163,8 +162,6 @@ bool is_visible(cube_0* cb, double offx, double offy, double offz) {
void gl_renderAll(unsigned int shaderProgram, unsigned int fragmentShader, unsigned int VAO, unsigned int VBO, room* rtd, double offx, double offy, double offz) {
if(rtd != NULL) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures[0]);
for(int k = 0; k < rtd->map_size; k++) {
if(is_visible(rtd->map[k], offx, offy, offz)) {
gl_renderCube(shaderProgram, fragmentShader, VAO, VBO, rtd->map[k], offx, offy, offz);
@ -177,8 +174,6 @@ void gl_renderAll(unsigned int shaderProgram, unsigned int fragmentShader, unsig
}
for(int k = 0; k < rtd->ent_len; k++) {
if(is_visible(rtd->ents[k]->pos, offx, offy, offz)) {
//printf("%d\n", rtd->ents[k]->tex);
glBindTexture(GL_TEXTURE_2D, textures[rtd->ents[k]->tex]);
gl_renderCube(shaderProgram, fragmentShader, VAO, VBO, rtd->ents[k]->pos, offx, offy, offz);
}
}
@ -230,4 +225,14 @@ void gl_drawData(unsigned int shaderProg) {
gl_printf(shaderProg, -0.95f, 0.9f, 0.04f, 0.004f, 255-player_hp/4, player_hp/4, 0, "HP %d", player_hp);
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);
}
void read_ppm(char* filename) {
FILE* ptr = fopen(filename, "r");
char c = fgetc(ptr);
while(c != EOF) {
printf("%c\n", c);
}
printf("\n");
fclose(ptr);
}

View File

@ -10,4 +10,6 @@ void init_vertices();
void gl_drawData(unsigned int shaderProg);
void read_ppm(char* filename);
#endif

View File

@ -7,14 +7,11 @@
#include <termios.h>
#include <limits.h>
#include <time.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <cglm/cglm.h>
#include "hash.h"
#include "structure.h"
#include "base.h"
#include "display.h"
#include "menus.h"
#include "proj.h"
#include "entities.h"

View File

@ -10,6 +10,7 @@
#include <string.h>
#include "hash.h"
#include "structure.h"
#include "base.h"
#include "entities.h"
#include "generation.h"
@ -41,56 +42,48 @@ void init_ent_generator(int n) {
}
hashtbl_entities[0].id = 0;
hashtbl_entities[0].tex = 0;
hashtbl_entities[0].name = "Coin"; // 0 = default
hashtbl_entities[0].updatePos = &speen;
hashtbl_entities[0].onHit = &money;
hashtbl_entities[0].onDeath = NULL;
hashtbl_entities[1].id = 1;
hashtbl_entities[1].tex = 0;
hashtbl_entities[1].name = "ExplosiveStill";
hashtbl_entities[1].updatePos = &speen2;
hashtbl_entities[1].onHit = &explodeOnHit;
hashtbl_entities[1].onDeath = NULL;
hashtbl_entities[2].id = 2;
hashtbl_entities[2].tex = 0;
hashtbl_entities[2].name = "ExplosiveSeek";
hashtbl_entities[2].updatePos = &go_to_player;
hashtbl_entities[2].onHit = &explodeOnHit;
hashtbl_entities[2].onDeath = NULL;
hashtbl_entities[3].id = 3;
hashtbl_entities[3].tex = 0;
hashtbl_entities[3].name = "ExplosiveShoot";
hashtbl_entities[3].updatePos = &speen3;
hashtbl_entities[3].onHit = &explodeOnHit;
hashtbl_entities[3].onDeath = NULL;
hashtbl_entities[4].id = 4;
hashtbl_entities[4].tex = 0;
hashtbl_entities[4].name = "SinePlatform";
hashtbl_entities[4].updatePos = &moving_xyz;
hashtbl_entities[4].onHit = &translatePlayer;
hashtbl_entities[4].onDeath = NULL;
hashtbl_entities[5].id = 5;
hashtbl_entities[5].tex = 0;
hashtbl_entities[5].name = "LinePlatform";
hashtbl_entities[5].updatePos = &moving_xyz_line;
hashtbl_entities[5].onHit = &translatePlayerLine;
hashtbl_entities[5].onDeath = NULL;
hashtbl_entities[6].id = 6;
hashtbl_entities[6].tex = 1;
hashtbl_entities[6].name = "TextBox";
hashtbl_entities[6].updatePos = NULL;
hashtbl_entities[6].onHit = &pop_text;
hashtbl_entities[6].onDeath = NULL;
hashtbl_entities[7].id = 7;
hashtbl_entities[7].tex = 0;
hashtbl_entities[7].name = "WarpBox";
hashtbl_entities[7].updatePos = NULL;
hashtbl_entities[7].onHit = &pop_and_tp;
@ -139,8 +132,6 @@ void copy_room(room* src, room* dest, int chx, int chy) {
for(int k = 0; k < src->ent_len; k++) {
dest->ents[k] = malloc(sizeof(entity));
dest->ents[k]->damage = src->ents[k]->damage;
dest->ents[k]->tex = src->ents[k]->tex;
//printf("!! %d !!\n", dest->ents [k]->tex);
dest->ents[k]->hitpoints = malloc(sizeof(int));
dest->ents[k]->metai1 = src->ents[k]->metai1;
dest->ents[k]->metai2 = src->ents[k]->metai2;
@ -209,7 +200,6 @@ void build_starting_chunk(int chx, int chy) {
for(int k = 0; k < 32; k++) {
new->ents[k] = malloc(sizeof(entity));
new->ents[k]->hitpoints = malloc(sizeof(int));
new->ents[k]->tex = 0;
new->ents[k]->pos = malloc(sizeof(cube_0));
};
new->ent_len = 1;
@ -357,7 +347,6 @@ void parse_one_room(int id, char* filename) {
pool[id].area->ents[k] = malloc(sizeof(entity));
pool[id].area->ents[k]->hitpoints = malloc(sizeof(int));
pool[id].area->ents[k]->pos = malloc(sizeof(cube_0));
pool[id].area->ents[k]->tex = 0;
}
pool[id].area->ent_len = nent;
pool[id].area->ent_memlen = nmemlen;
@ -427,10 +416,8 @@ void parse_one_room(int id, char* filename) {
if(entry == NULL) {
entry = get_entry(0);
}
//printf(">>><>>>>><> %d\n", entry->tex);
fill_cube_0(pool[id].area->ents[k]->pos, cx, cy, cz, cw, ch, cd, chz, cvt, red, green, blue);
pool[id].area->ents[k]->damage = dmg;
pool[id].area->ents[k]->tex = entry->tex;
*(pool[id].area->ents[k]->hitpoints) = hp;
pool[id].area->ents[k]->updatePos = entry->updatePos;
pool[id].area->ents[k]->onHit = entry->onHit ;
@ -648,17 +635,14 @@ void generate_nearby_chunks(int render_dist) {
void free_pool() {
for(int k0 = 0; k0 < pool_size; k0++) {
printf("%d/%d\n", 1+k0, pool_size); fflush(stdout);
printf("%d/%d\n", 1+k0, pool_size);
for(int k = 0; k < pool[k0].area->map_size; k++) {
printf("%d-%d\n", k, pool[k0].area->map_size);
free(pool[k0].area->map[k]);
}
printf("...\n"); fflush(stdout);
for(int k = 0; k < pool[k0].area->tps_size; k++) {
free(pool[k0].area->tps[k]->hitbox);
free(pool[k0].area->tps[k]);
}
printf("...\n"); fflush(stdout);
for(int k = 0; k < pool[k0].area->ent_memlen; k++) {
if(pool[k0].area->ents[k]->metai3 == -727) { // 6 and 7 //
//free(pool[k0].area->ents[k]->metach1);
@ -671,7 +655,6 @@ void free_pool() {
free(pool[k0].area->ents[k]->pos);
free(pool[k0].area->ents[k]);
}
printf("...\n"); fflush(stdout);
free(pool[k0].area->ents);
free(pool[k0].area->tps);
free(pool[k0].area->map);

View File

@ -33,8 +33,6 @@ typedef struct fct_entry {
double metad9;
char* metach1;
char* metach2;
int tex;
} fct_entry ;
extern int build_text_box(char* msg, int red, int green, int blue);

View File

@ -8,6 +8,7 @@
#include <limits.h>
#include <time.h>
#include "structure.h"
#include "hash.h"
// ------------------------------------------------------------------------------------------------------- //

View File

@ -4,7 +4,6 @@
#ifndef HASH_H
#define HASH_H
#include "structure.h"
#include <stdbool.h>

View File

@ -10,12 +10,8 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#endif
#include "hash.h"
#include "structure.h"
#include "base.h"
#include "move.h"
#include "menus.h"
@ -37,8 +33,6 @@ double jPress = false;
double gPress = false;
double rPress = false;
unsigned int textures[16];
void reset_everything(GLFWwindow *window, int count, char* folder) {
/*hashtbl_free(visited);
free_proj();
@ -111,8 +105,6 @@ void reset_everything(GLFWwindow *window, int count, char* folder) {
interface_set(-1);
generate_nearby_chunks(1);
printf("-------------------------------- Done 5 --------------------------------\n");
}
void processInput(GLFWwindow *window, float dtime) {
@ -256,32 +248,26 @@ void processInput(GLFWwindow *window, float dtime) {
//printf("-----\n");
switchRoom = false;
reset_everything(window, newRoomCount, newRoomName);
//free(newRoomName);
free(newRoomName);
}
}
const char *vertexShaderSource = "#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
"layout (location = 1) in vec2 aTex;\n"
"uniform mat4 scale;\n"
"uniform mat4 model;\n"
"uniform mat4 view;\n"
"uniform mat4 projection;\n"
"out vec2 texCoord;\n"
"void main() {\n"
" gl_Position = projection * view * model * scale * vec4(aPos, 1.0);\n"
" texCoord = aTex;\n"
"}\0";
// Fragment Shader Source
const char *fragmentShaderSource = "#version 330 core\n"
"uniform vec4 u_color;\n"
"out vec4 FragColor;\n"
"in vec2 texCoord;\n"
"uniform sampler2D tex0;\n"
"void main() {\n"
// " FragColor = u_color;\n"
" FragColor = texture(tex0, texCoord) * u_color;\n"
" FragColor = u_color;\n"
"}\0";
const char *vertexShaderSourceR = "#version 330 core\n"
@ -299,34 +285,6 @@ const char *fragmentShaderSourceR = "#version 330 core\n"
" FragColor = u_color2;\n"
"}\0";
typedef enum file_extension {PNG, JPG, JPEG} file_extension;
void generate_texture(int id, char* filename, file_extension ext) {
int widthImg, heightImg, 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_2D, textures[id]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
if(ext == JPG || ext == JPEG) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, widthImg, heightImg, 0, GL_RGB, GL_UNSIGNED_BYTE, bytes);
glGenerateMipmap(GL_TEXTURE_2D);
} else if(ext == PNG) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, widthImg, heightImg, 0, GL_RGBA, GL_UNSIGNED_BYTE, bytes);
glGenerateMipmap(GL_TEXTURE_2D);
}
stbi_image_free(bytes);
glBindTexture(GL_TEXTURE_2D, 0);
}
int main_alt() {
// glfw: initialize and configure
// ------------------------------
@ -422,21 +380,8 @@ int main_alt() {
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// position attribute
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
// texture coord attribute
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3*sizeof(float)));
glEnableVertexAttribArray(1);
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
//generate_texture(0, "res/container.jpg", "jpg");
generate_texture(0, "res/white.png", PNG);
generate_texture(1, "res/question_block.png", PNG);
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
// ---------------------------------------------------------------------------------------------------------------------------------------------- //
// ---------------------------------------------------------------------------------------------------------------------------------------------- //
@ -515,10 +460,6 @@ int main_alt() {
clock_t finish = clock();
clock_t origin = clock();
loc_tex = glGetUniformLocation(shaderProgram, "tex0");
glUseProgram(shaderProgram);
glUniform1i(loc_tex, 0);
while(!glfwWindowShouldClose(window) && player_hp > 0) {
// input
// -----
@ -530,9 +471,8 @@ int main_alt() {
generate_nearby_chunks(1);
fflush(stdout);
glUseProgram(shaderProgram);
// draw the map
glUseProgram(shaderProgram);
glBindVertexArray(VAO);
gl_initRender(shaderProgram, shaderProgram, VAO, VBO);
@ -588,8 +528,6 @@ int main_alt() {
// ------------------------------------------------------------------------
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &VBO);
glDeleteTextures(1, &textures[0]);
glDeleteTextures(1, &textures[1]);
glDeleteProgram(shaderProgram);
// glfw: terminate, clearing all previously allocated GLFW resources.
@ -606,6 +544,6 @@ int main(int argc, char** argv) {
newRoomCount = 7;
switchRoom = false;
newRoomName = "templates/";
//read_png_file("res/question_block.png");
//read_ppm("res/smb-2.ppm");
return main_alt();
}

View File

@ -14,6 +14,7 @@
#include <cglm/cglm.h>
#include "hash.h"
#include "structure.h"
#include "base.h"
#include "entities.h"
#include "menus.h"

View File

@ -9,6 +9,7 @@
#include <time.h>
#include "hash.h"
#include "structure.h"
#include "base.h"
#include "entities.h"
#include "proj.h"

View File

@ -8,6 +8,7 @@
#include <limits.h>
#include <time.h>
#include "structure.h"
#include "hash.h"
#include "base.h"
#include "move.h"

File diff suppressed because it is too large Load Diff

View File

@ -59,8 +59,6 @@ typedef struct entity {
char* metach1;
char* metach2;
int tex;
int damage;
int* hitpoints;
} entity;
@ -150,7 +148,7 @@ extern double creative_speed;
extern double min_dist;
// ---------------------------------------------------------------------------------------------------- //
extern float vertices[180];
extern float vertices[108];
extern float rectDefault[18];
extern int triCount;
@ -172,14 +170,4 @@ extern char* newRoomName;
extern int newRoomCount;
extern bool switchRoom;
extern int loc_scale;
extern int loc_model;
extern int loc_view;
extern int loc_proj;
extern int loc_frag;
extern int loc_tex;
extern unsigned int textures[16];
#endif

View File

@ -11,7 +11,7 @@ Teleporters :
[-5.0, 1.0, 9.0, 10.0, 2.0, 1.0, 0.0, 0.0, 0, 0, 255; 0, 1]
Entities :
[-1.0, 1.0, -1.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 6, hey look a text box, 200, 200, 200]
[-1.0, 1.0, -1.0, 2.0, 2.0, 2.0, 0.0, 0.0, 0, 0, 0, 1, 0, 6, hey look a text box, 200, 200, 200]
Weight :
50