|
|
|
@ -1,4 +1,5 @@
@@ -1,4 +1,5 @@
|
|
|
|
|
#include "game.h" |
|
|
|
|
#include "draw.h" |
|
|
|
|
#include <SDL2/SDL_scancode.h> |
|
|
|
|
#include <SDL2/SDL_timer.h> |
|
|
|
|
#include <SDL2/SDL_ttf.h> |
|
|
|
@ -101,7 +102,7 @@ int load_score_times(char *filename) {
@@ -101,7 +102,7 @@ int load_score_times(char *filename) {
|
|
|
|
|
fn = malloc(fnlen); |
|
|
|
|
snprintf(fn, fnlen, "%s-%s", filename, lvl_str); |
|
|
|
|
|
|
|
|
|
printf("%d, lvl_str %s fn %s\n", level, lvl_str, fn); |
|
|
|
|
//printf("%d, lvl_str %s fn %s\n", level, lvl_str, fn);
|
|
|
|
|
|
|
|
|
|
FILE *f = fopen(fn, "r"); |
|
|
|
|
// unload existing score times
|
|
|
|
@ -116,7 +117,7 @@ int load_score_times(char *filename) {
@@ -116,7 +117,7 @@ int load_score_times(char *filename) {
|
|
|
|
|
fseek(f, 0L, SEEK_END); |
|
|
|
|
long sz = ftell(f); |
|
|
|
|
fseek(f, 0L, SEEK_SET); |
|
|
|
|
char *text = malloc((sz + 1) * (sizeof(char)));
|
|
|
|
|
char *text = calloc((sz + 1), (sizeof(char)));
|
|
|
|
|
|
|
|
|
|
// read file
|
|
|
|
|
fread(text,sizeof(char),sz, f);
|
|
|
|
@ -697,7 +698,7 @@ void next_level() {
@@ -697,7 +698,7 @@ void next_level() {
|
|
|
|
|
destroy_physics_collection(&world.uniques_index[ROOM_W]->room->floor); |
|
|
|
|
destroy_environment(&world.uniques_index[ROOM_W]->room->env); |
|
|
|
|
|
|
|
|
|
level *= 7;; |
|
|
|
|
level += 1;; |
|
|
|
|
get_floor_ceiling(); |
|
|
|
|
load_score_times("saves/times"); |
|
|
|
|
|
|
|
|
@ -709,8 +710,11 @@ void next_level() {
@@ -709,8 +710,11 @@ void next_level() {
|
|
|
|
|
|
|
|
|
|
quality = 100; |
|
|
|
|
level_timer_update(true); |
|
|
|
|
SDL_UnlockMutex(player.physics->lock); |
|
|
|
|
|
|
|
|
|
viewport_pos.x = player.physics->position.x - width / 2; |
|
|
|
|
viewport_pos.y = player.physics->position.y - height / 2; |
|
|
|
|
|
|
|
|
|
SDL_UnlockMutex(player.physics->lock); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int get_floor_ceiling() { |
|
|
|
@ -1532,8 +1536,8 @@ void get_room(void) {
@@ -1532,8 +1536,8 @@ void get_room(void) {
|
|
|
|
|
|
|
|
|
|
FloorPoly *ceil = generate_floor_simple(floorsize, false, 1000); |
|
|
|
|
|
|
|
|
|
printf("floor: %f %f\n", polys[2].left.x, polys[2].left.y); |
|
|
|
|
printf("ceil: %f %f\n", ceil[2].left.x, ceil[2].left.y); |
|
|
|
|
// printf("floor: %f %f\n", polys[2].left.x, polys[2].left.y);
|
|
|
|
|
// printf("ceil: %f %f\n", ceil[2].left.x, ceil[2].left.y);
|
|
|
|
|
|
|
|
|
|
Floor* ceiling = calloc(1, sizeof(Floor)); |
|
|
|
|
ceiling->polys = ceil; |
|
|
|
@ -1563,7 +1567,7 @@ void startgame(SDL_Renderer * ren) {
@@ -1563,7 +1567,7 @@ void startgame(SDL_Renderer * ren) {
|
|
|
|
|
|
|
|
|
|
debug_ren = ren; |
|
|
|
|
|
|
|
|
|
level = 31; |
|
|
|
|
level = 0; |
|
|
|
|
|
|
|
|
|
save_times_lst = (struct sg_times_list){}; |
|
|
|
|
load_score_times("saves/times"); |
|
|
|
@ -1591,6 +1595,8 @@ void startgame(SDL_Renderer * ren) {
@@ -1591,6 +1595,8 @@ void startgame(SDL_Renderer * ren) {
|
|
|
|
|
|
|
|
|
|
level_timer_update(true); |
|
|
|
|
game_paused = 0; |
|
|
|
|
viewport_pos.x = player.physics->position.x - width / 2; |
|
|
|
|
viewport_pos.y = player.physics->position.y - height / 2; |
|
|
|
|
//get_room();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1669,7 +1675,6 @@ int get_rand(int seed) {
@@ -1669,7 +1675,6 @@ int get_rand(int seed) {
|
|
|
|
|
const unsigned m = (1 << 31) - 1; |
|
|
|
|
const unsigned initial_n = 1; |
|
|
|
|
const unsigned a = 48271; |
|
|
|
|
|
|
|
|
|
static unsigned n = initial_n; |
|
|
|
|
|
|
|
|
|
if (seed != 0) { |
|
|
|
|