completed level_02

This commit is contained in:
Alexandre 2025-02-27 15:14:56 +01:00
parent c46555e108
commit 89ac335034
12 changed files with 47 additions and 13 deletions

BIN
bin/back

Binary file not shown.

View File

@ -17,14 +17,22 @@ Blocks :
[ 10.0, 18.0, -36.0, 20.0, 2.0, 4.0, 0.0, 0.0, 192, 192, 192]
[ 28.0, 30.0, -36.0, 4.0, 2.0, 4.0, 0.0, 0.0, 32, 192, 32] // cp3
[32.0, 30.0, -35.0, 6.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] // 4 - support
[42.0, 34.0, -35.0, 2.0, 2.0, 8.0, 0.0, 0.0, 192, 192, 192]
[42.0, 34.0, -19.0, 2.0, 2.0, 8.0, 0.0, 0.0, 192, 192, 192]
[42.0, 34.0, -3.0, 2.0, 2.0, 8.0, 0.0, 0.0, 192, 192, 192]
[30.0, 38.0, 3.0, 6.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192]
[7.0, 44.0, 2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 32, 192, 32] // cp4
Entities:
[8.0, 1.0 , 8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 128, 1, 0, 8, 100, 1, 128, 128, 128]
[-8.0, 1.0, 8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 6, get over it, 192, 192, 192]
[8.5, 1.5 , 8.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 7, levels/level_01/, 7, great, 192, 192, 192]
[-3.5, 13.0, 0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 10, 0, 0] // cp1 coin
[-3.5, 23.0, -15.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 10, 0, 0] // cp2 coin
[29.5, 33.0, -34.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 10, 0, 0] // cp3 coin
[-3.5, 23.0, -15.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 20, 0, 0] // cp2 coin
[29.5, 33.0, -34.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 30, 0, 0] // cp3 coin
[ 8.5, 47.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 40, 0, 0] // cp4 coin
[-4.0, 0.0, -13.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.4, 1.4, 0] // 1-1
@ -105,6 +113,16 @@ Entities:
[ 20.0, 28.0, -35.0, 2.0, 2.0, 2.0, 0.71, 0.0, 255, 255, 255, 1, 0, 12, 6, 0]
[ 21.5, 30.0, -35.0, 2.0, 2.0, 2.0, 0.71, 0.0, 255, 255, 255, 1, 0, 12, 7, 0]
[38.0, 32.0, -35.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] // 4 - math
[42.0, 34.0, -24.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5]
[42.0, 34.0, -8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5]
[38.0, 36.0, 3.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5]
[26.0, 40.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5]
[22.0, 41.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5]
[18.0, 42.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5]
[14.0, 43.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5]
Weight :
0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
res/pi.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
res/pi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -182,6 +182,10 @@ void math_block(double x, double y, double z, double w, double h, double d, doub
if(ent->metad1 > -0.9) {
ent->metad1 = maxd(ent->metad1 - (double)dtime, 0.0);
}
if(mathResult == FAILURE && ent->metad1 > 0.1) {
mathResult = IDLE;
ent->metad1 = 0.1;
}
}
void active_math(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) {

View File

@ -147,7 +147,7 @@ void init_ent_generator(int n) {
hashtbl_entities[12].onDeath = NULL;
hashtbl_entities[13].id = 13;
hashtbl_entities[13].tex = 7;
hashtbl_entities[13].tex = 12;
hashtbl_entities[13].tex2 = 9;
hashtbl_entities[13].name = "mathBlock";
hashtbl_entities[13].updatePos = &math_block;
@ -619,6 +619,12 @@ void parse_one_room(int id, char* filename) {
pool[id].area->ents[k]->metai1 = defaultState;
pool[id].area->ents[k]->metad1 = 0.0;
pool[id].area->ents[k]->metad2 = activeTime;
if(defaultState == 0) {
pool[id].area->ents[k]->tex2 = 8;
} else {
pool[id].area->ents[k]->tex2 = 9;
}
} else {
pool[id].area->ents[k]->metai3 = 0;
}

View File

@ -9,6 +9,7 @@
#include <time.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <sys/time.h>
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
@ -523,6 +524,7 @@ int main_alt() {
generate_texture_2D(9, "res/sq_dotted.png", PNG);
generate_texture_2D(10, "res/button_on.png", PNG);
generate_texture_2D(11, "res/button_off.jpg", JPG);
generate_texture_2D(12, "res/pi.png", PNG);
printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout);
@ -595,6 +597,7 @@ int main_alt() {
int fps = 90;
int interval = 1000000/fps;
float interval_s = 1.0f/fps;
double slp_time = 1.0/fps;
float delta = 0.0f;
@ -604,16 +607,19 @@ int main_alt() {
int count = 0;
clock_t finish = clock();
clock_t origin = clock();
struct timeval ogn, fnn;
gettimeofday(&ogn, NULL);
gettimeofday(&fnn, NULL);
loc_tex = glGetUniformLocation(shaderProgram, "tex0");
glUseProgram(shaderProgram);
glUniform1i(loc_tex, 0);
mathSignal = true;
float calc_T = 0.0f;
while(!glfwWindowShouldClose(window) && player_hp > 0) {
gettimeofday(&ogn, NULL);
// input
// -----
glClearColor(0.05f, 0.05f, 0.05f, 1.0f);
@ -679,9 +685,10 @@ int main_alt() {
}
}
finish = clock();
usleep(max(0, interval-(int)(1000000*delta)));
sim_time += deltad;
gettimeofday(&fnn, NULL);
calc_T = (float)((fnn.tv_sec-ogn.tv_sec + (fnn.tv_usec-ogn.tv_usec)/1000000.0f));
usleep(max(0, interval-(int)(1000000*calc_T)));
sim_time += interval_s + maxd(0.0, (double)(interval_s-(calc_T)));
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
glfwSwapBuffers(window);
@ -692,12 +699,11 @@ int main_alt() {
lastDmg = player_hp;
dmgCD = 0.5f;
}
delta = (float)slp_time;//+((float)finish - (float)origin)/CLOCKS_PER_SEC;
deltad = slp_time;//+((double)finish - (double)origin)/CLOCKS_PER_SEC;
delta = (float)(interval_s + maxf(0.0f, interval_s-(calc_T)));
deltad = (double)delta;
if(count%(fps/10)==0) {
real_T = ((float)finish - (float)origin)/CLOCKS_PER_SEC;
real_T = (float)((fnn.tv_sec-ogn.tv_sec + (fnn.tv_usec-ogn.tv_usec)/1000000.0f));
}
origin = clock();
incr = 0.0f;
count++;

View File

@ -23,7 +23,7 @@ double speed = 6.0;
double vtmult = 2.25;
double min_dist = 0.4;
double friction = 0.3;
double gravity_factor = 25.0;
double gravity_factor = 26.0;
// ---------------------------------------------------------------------------------------------------- //
bool is_clipping = false;