diff --git a/README.md b/README.md index a40771b..6f6d39f 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,10 @@ entities: -> 0 (coin) -> damage equals the coin's value -> 1 (non-moving explosive) -> 2 (seeking explosive) - -> 3 (shooting non-moving explosive) + -> 3 (shooting, maybe moving explosive) + [.. proj_speed, shoot_speed, shot_freq, shot_ttl] with + {all} = double[>= 0.0] + -> 4 (moving platform) [.. amplitude_x, amplitude_y, amplitude_z, mult, divd, phase] with *<- extra arguments at the end of []* amplitude_{x,y,z} = double[>= 0.0] diff --git a/bin/back b/bin/back index 1326990..2660016 100755 Binary files a/bin/back and b/bin/back differ diff --git a/levels/level_02/room_0 b/levels/level_02/room_0 index eb1406b..ff9d7e5 100644 --- a/levels/level_02/room_0 +++ b/levels/level_02/room_0 @@ -2,8 +2,9 @@ Blocks : [-16.0, -1.0, -16.0,32.0, 1.0, 32.0, 0.0, 0.0, 128, 128, 128] [ -4.0,-10.0, -4.0, 8.0, 2.0, 8.0, 0.0, 0.0, 128, 128, 128] -[ -4.0, -6.5, -2.0, 2.0, 1.0, 2.0, 0.0, 0.3, 128, 128, 128] -[ -4.0, -6.5, 2.0, 2.0, 1.0, 2.0, 0.3, 0.0, 128, 128, 128] +[ -4.0, -6.5, -2.0, 2.0, 1.0, 2.0, 0.0, 0.3, 128, 128, 128] +[ -4.0, -6.5, 2.0, 2.0, 1.0, 2.0, 0.3, 0.0, 128, 128, 128] +[-18.0, 10.0, -16.0, 3.0, 1.0,32.0, 0.0, 0.4, 255, 255, 255] [ -6.0, 10.0, 0.0, 6.0, 2.0, 2.0, 0.0, 0.0, 32, 192, 32] // cp1 diff --git a/obj/entities.o b/obj/entities.o index 6eb3673..09b4633 100644 Binary files a/obj/entities.o and b/obj/entities.o differ diff --git a/obj/generation.o b/obj/generation.o index cb2daee..7d78f89 100644 Binary files a/obj/generation.o and b/obj/generation.o differ diff --git a/obj/main.o b/obj/main.o index 3982c64..5d91f5e 100644 Binary files a/obj/main.o and b/obj/main.o differ diff --git a/obj/proj.o b/obj/proj.o index f20b1d6..37bb340 100644 Binary files a/obj/proj.o and b/obj/proj.o differ diff --git a/res/tnt.png b/res/tnt.png new file mode 100644 index 0000000..4b82ae7 Binary files /dev/null and b/res/tnt.png differ diff --git a/src/entities.c b/src/entities.c index 5675733..df7c733 100644 --- a/src/entities.c +++ b/src/entities.c @@ -77,17 +77,40 @@ void speen(double x, double y, double z, double w, double h, double d, double hz ret->hz_angle += ((double)dtime)*1.5; } +// metad1 = main proj speed +// metad2 = shot proj speed +// metad2 = shot proj freq +// metad2 = shot proj time to live void speen2(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) { - ret->hz_angle += ((double)dtime)*2.5; + ret->hz_angle += ((double)dtime)*ent->metad3; if((int)(5.0*ret->hz_angle) != (int)(5.0*(ret->hz_angle - ((double)dtime)*22.5))) { double dx = (x+w/2 - (camx-choffx)); double dy = (y+h/2 - (camy)); double dz = (z+d/2 - (camz-choffz)); double total = sqrt(dx*dx + dy*dy + dz*dz); - dx = 110.0*dx/total; - dy = 110.0*dy/total; - dz = 110.0*dz/total; - appendProj(x+w/2+choffx, y+h/2, z+d/2+choffz, 0.1, 0.1, 0.1, -dx, -dy, -dz, 0.0, 0.0, 0.0, 255, 0, 0, 10, 3.0); + dx = ent->metad2*dx/total; + dy = ent->metad2*dy/total; + dz = ent->metad2*dz/total; + appendProj(x+w/2+choffx, y+h/2, z+d/2+choffz, 0.1, 0.1, 0.1, -dx, -dy, -dz, 0.0, 0.0, 0.0, 255, 0, 0, 10, ent->metad4); + } + double dx = (x+w/2 - (camx-choffx)); + double dy = (y+h/2 - (camy)); + double dz = (z+d/2 - (camz-choffz)); + double total = sqrt(dx*dx + dy*dy + dz*dz); + dx = ent->metad1*dx/total; + dy = ent->metad1*dy/total; + dz = ent->metad1*dz/total; + ret->x -= dtime*dx; + if(is_colliding_with_map(ret) || is_colliding_with_tp(ret)) { + ret->x += dtime*dx; + } + ret->y -= dtime*dy; + if(is_colliding_with_map(ret) || is_colliding_with_tp(ret)) { + ret->y += dtime*dy; + } + ret->z -= dtime*dz; + if(is_colliding_with_map(ret) || is_colliding_with_tp(ret)) { + ret->z += dtime*dz; } } @@ -277,9 +300,9 @@ void go_to_player(double x, double y, double z, double w, double h, double d, do if(is_colliding_with_map(ret) || is_colliding_with_tp(ret)) { ret->z += dtime*dz; } - if((int)(ret->x+ret->y+ret->z) != (int)(ret->x+ret->y+ret->z-dx-dy-dz)) { + //if((int)(ret->x+ret->y+ret->z) != (int)(ret->x+ret->y+ret->z-dx-dy-dz)) { - } + //} } void explodeOnHit(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) { diff --git a/src/generation.c b/src/generation.c index 8783857..bc75d22 100644 --- a/src/generation.c +++ b/src/generation.c @@ -51,26 +51,26 @@ void init_ent_generator(int n) { hashtbl_entities[0].onDeath = NULL; hashtbl_entities[1].id = 1; - hashtbl_entities[1].tex = 0; - hashtbl_entities[1].tex2 = 0; + hashtbl_entities[1].tex = 13; + hashtbl_entities[1].tex2 = 13; hashtbl_entities[1].name = "ExplosiveStill"; - hashtbl_entities[1].updatePos = &speen2; + hashtbl_entities[1].updatePos = NULL; hashtbl_entities[1].onHit = &explodeOnHit; hashtbl_entities[1].onDeath = NULL; hashtbl_entities[2].id = 2; - hashtbl_entities[2].tex = 0; - hashtbl_entities[2].tex2 = 0; + hashtbl_entities[2].tex = 13; + hashtbl_entities[2].tex2 = 13; 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].tex2 = 0; + hashtbl_entities[3].tex = 13; + hashtbl_entities[3].tex2 = 13; hashtbl_entities[3].name = "ExplosiveShoot"; - hashtbl_entities[3].updatePos = &speen3; + hashtbl_entities[3].updatePos = &speen2; hashtbl_entities[3].onHit = &explodeOnHit; hashtbl_entities[3].onDeath = NULL; @@ -452,7 +452,16 @@ void parse_one_room(int id, char* filename) { pool[id].area->ents[k]->metad7 = entry->metad7; pool[id].area->ents[k]->metad8 = entry->metad8; pool[id].area->ents[k]->metad9 = entry->metad9; - if(entry->id == 4) { + if(entry->id == 3) { + double pspd = read_float(ptr); + double bspd = read_float(ptr); + double bfreq = read_float(ptr); + double bttl = read_float(ptr); + pool[id].area->ents[k]->metad1 = pspd; + pool[id].area->ents[k]->metad2 = bspd; + pool[id].area->ents[k]->metad3 = bfreq; + pool[id].area->ents[k]->metad4 = bttl; + } else if(entry->id == 4) { // sine platform double ccw = read_float(ptr); double cch = read_float(ptr); diff --git a/src/main.c b/src/main.c index 1e98fdc..479525d 100644 --- a/src/main.c +++ b/src/main.c @@ -40,8 +40,9 @@ bool jPress = false; bool gPress = false; bool rPress = false; bool pPress = false; +bool kPress = false; -unsigned int textures[16]; +unsigned int textures[32]; bool paused = false; bool hardReset = true; @@ -49,6 +50,10 @@ bool hardReset = true; double oldx, oldy, oldz; int oldchx, oldchy; +int kodami[10] = {GLFW_KEY_UP, GLFW_KEY_UP, GLFW_KEY_DOWN, GLFW_KEY_DOWN, GLFW_KEY_LEFT, GLFW_KEY_RIGHT, GLFW_KEY_LEFT, GLFW_KEY_RIGHT, GLFW_KEY_B, GLFW_KEY_A}; +int kodid = 0; +bool kodhit = false; + void reset_everything(GLFWwindow *window, int count, char* folder) { oldx = camx; oldy = camy; @@ -136,6 +141,23 @@ void processInput(GLFWwindow *window, float dtime) { glfwSetWindowShouldClose(window, true); } + // kodami + if(!kodhit) { + if(kodid == 10) { + kodhit = true; + player_hp += 1500; + } else if(glfwGetKey(window, kodami[kodid]) == GLFW_PRESS) { + if(!kPress) { + kPress = true; + kodid += 1; + //printf("%d\n", kodid); + } + } else { + kPress = false; + //kodid = 0; + } + } + // horizontal movement bool pressed = false; if(!paused) { @@ -525,6 +547,7 @@ int main_alt() { 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); + generate_texture_2D(13, "res/tnt.png", PNG); printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout); @@ -692,8 +715,10 @@ int main_alt() { dmgCD = maxf(dmgCD - delta, 0.0f); if(lastDmg != player_hp) { + if(lastDmg > player_hp) { + dmgCD = 0.5f; + } lastDmg = player_hp; - dmgCD = 0.5f; } delta = (float)(interval_s + maxf(0.0f, interval_s-(calc_T))); deltad = (double)delta; diff --git a/src/proj.c b/src/proj.c index 3ddc754..966f465 100644 --- a/src/proj.c +++ b/src/proj.c @@ -94,7 +94,7 @@ void move_cube(cube_0* cb, double dx, double dy, double dz) { void updateProj(float dtime) { //printf("%d\n", bullets_id); for(int k = 0; k < bullets_id; k++) { - *(bullets[k].ttl) -= 50.0*(double)dtime; + *(bullets[k].ttl) -= (double)dtime; if(*(bullets[k].ttl) <= 0.0 || is_colliding_with_map(bullets[k].pos) || is_colliding_with_tp(bullets[k].pos)) { removeProj(k); k -= 1; diff --git a/src/structure.h b/src/structure.h index db87f9b..04a47cd 100644 --- a/src/structure.h +++ b/src/structure.h @@ -187,7 +187,7 @@ extern int loc_tex; extern bool is_one_room; -extern unsigned int textures[16]; +extern unsigned int textures[32]; extern float dmgCD; extern int lastDmg; diff --git a/templates/room_0 b/templates/room_0 index fe1fea2..fce8ded 100644 --- a/templates/room_0 +++ b/templates/room_0 @@ -13,6 +13,8 @@ Teleporters : [9.0, 1.0, 4.0, 1.0, 4.0, 2.0, 0.0, 0.0, 0, 0, 255; 0, 1] Entities : +[1.0, -6.0, 3.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 1, 32, 1] +[1.0, -3.0, 3.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 1, 32, 3, 0.0, 4.0, 1.0, 1.0] [-1.0, 13.0, -1.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.5, 1.5, 0] [-1.0, 16.0, -1.0, 2.0, 1.0, 2.0, 0.0, 0.0, 128, 128, 128, 1, 0, 11, 4, 1.75] [-1.0, 19.0, -1.0, 2.0, 1.0, 2.0, 0.0, 0.0, 128, 128, 128, 1, 0, 12, 4, 1] @@ -21,29 +23,4 @@ Entities : Weight : 50 -$ -entities: -[x, y, z, w, h, d, rhz, rvt, red, green, blue, hp, damage, entityType ..] - -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] with - text = {char*} - -else if entityType = 7 (warp text box) - [.. dest_folder, room_count, text, r, g, b] with - {dest_folder,text} = {char*} (length <= 50) - {r,g,b} = int[0-256] - -else - [..] \ No newline at end of file +$ \ No newline at end of file diff --git a/templates/room_2 b/templates/room_2 index b26670f..a88b81c 100644 --- a/templates/room_2 +++ b/templates/room_2 @@ -14,10 +14,8 @@ Teleporters : [-5.0, 1.0, 9.0, 10.0, 2.0, 1.0, 0.0, 0.0, 0, 0, 255; 0, 1] Entities : -[3.0, 3.0, 3.0, 0.5, 0.5, 0.5, 0.0, 0.0, 255, 192, 0, 1, 0, 3] [-3.0, 3.0, 3.0, 0.5, 0.5, 0.5, 0.0, 0.0, 193, 192, 0, 1, 0, 0] [3.0, 3.0, -3.0, 0.5, 0.5, 0.5, 0.0, 0.0, 193, 192, 0, 1, 0, 0] -[-3.0, 3.0, -3.0, 0.5, 0.5, 0.5, 0.0, 0.0, 255, 192, 0, 1, 0, 3] Weight : 50