1
1
Fork 0
Browse Source

level seed tweak

emscriptem
user 3 years ago
parent
commit
d0db8231fb
  1. 1
      src/basic-lib.c
  2. 20
      src/draw.c
  3. 21
      src/game.c
  4. 5
      src/main.c

1
src/basic-lib.c

@ -93,6 +93,5 @@ void get_time(void) { @@ -93,6 +93,5 @@ void get_time(void) {
replace_char(&(newstr[0]), "\n");
printf("%s", newstr);
}

20
src/draw.c

@ -547,28 +547,28 @@ int draw_end_screen(SDL_Renderer *ren) { @@ -547,28 +547,28 @@ int draw_end_screen(SDL_Renderer *ren) {
Vect position = {.x = width/3, .y = height / 4};
draw_text(ren, position, colour, end_str);
position.y += 40;
position.y += 60;
char level_string[250];
snprintf(level_string, 250,"course: %d", level);
draw_text(ren, position, colour, level_string);
position.y += 40;
char qual_str[250];
snprintf(qual_str, 250, "physics quality: %d", quality);
draw_text(ren, position, colour, qual_str);
position.y += 40;
char fastest_time[250];
minutes = fastest / 60000;
seconds = fastest * 0.001;
if (fastest > 0) {
position.y += 40;
snprintf(fastest_time, 250, "old best time: %d:%.4f", minutes, seconds);
draw_text(ren, position, colour, fastest_time);
position.y += 40;
}
char qual_str[250];
snprintf(qual_str, 250, "physics quality: %d", quality);
draw_text(ren, position, colour, qual_str);
position.y += 40;
minutes = level_time / 60000;
seconds = level_time * 0.001;
if (level_time > fastest) {
@ -578,7 +578,7 @@ int draw_end_screen(SDL_Renderer *ren) { @@ -578,7 +578,7 @@ int draw_end_screen(SDL_Renderer *ren) {
snprintf(time_string, 250, "NEW BEST TIME: %d:%.4f", minutes, seconds);
}
Vect position2 = {.x = 3 * width/5, .y = 40 + height / 4};
Vect position2 = {.x = 3 * width/5, .y = 60 + height / 4};
if (fastest > 0) {
//position.y += 40;

21
src/game.c

@ -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) {

5
src/main.c

@ -58,8 +58,8 @@ int physics_loop(void *ptr) { @@ -58,8 +58,8 @@ int physics_loop(void *ptr) {
SDL_LockMutex(player.physics->lock);
game_paused = true;
in_game = true;
next_level();
in_game = true;
SDL_UnlockMutex(player.physics->lock);
SDL_Delay(1000);
game_paused = 0;
@ -103,7 +103,7 @@ int game(void) { @@ -103,7 +103,7 @@ int game(void) {
startgame(ren);
physics_thread = SDL_CreateThread(physics_loop, "Physics", (void *)ren);
physics_thread = SDL_CreateThread(physics_loop, "physics", (void *)ren);
while (!close) {
@ -138,7 +138,6 @@ int game(void) { @@ -138,7 +138,6 @@ int game(void) {
}
int main (int argc, char** argv) {
int err = mkdirat(AT_FDCWD, "saves", 0777);

Loading…
Cancel
Save