From b6692783a625547117f0d702b299872ff07f9255 Mon Sep 17 00:00:00 2001 From: Janos <janol55@zedat.fu-berlin.de> Date: Thu, 21 Mar 2024 16:36:40 +0100 Subject: [PATCH] Bugfix --- auto.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/auto.c b/auto.c index 62e3a7f..b16879d 100644 --- a/auto.c +++ b/auto.c @@ -15,6 +15,7 @@ struct Car* init_car(int speed,int width,int height,int pred_pos,int pred_width, perror("kein Speicherplatz"); } + int min_distance; int distance; int p = rand() % 10; @@ -31,13 +32,19 @@ struct Car* init_car(int speed,int width,int height,int pred_pos,int pred_width, }else{ distance = 25; } + if (speed < 0){ + b->x_pos = pred_pos + pred_width + distance; + }else{ + b->x_pos = pred_pos - b->width - distance; + } + }else{ b->width = width; b->height = height; - if (t == coin || t == coin_gathered) + if (t == coin || t == coin_gathered){ b->type = car; - else{ + }else{ b->type = t; } if (pred_width == 0){ // kein Vorgänger @@ -54,15 +61,14 @@ struct Car* init_car(int speed,int width,int height,int pred_pos,int pred_width, min_distance = 50 * abs(speed) + 50; distance = (rand() % 500) + min_distance; } - } - } - if (speed < 0){ - b->x_pos = pred_pos + pred_width + distance; - }else{ - b->x_pos = pred_pos - b->width - distance; + if (speed < 0){ + b->x_pos = pred_pos + pred_width + distance; + }else{ + b->x_pos = pred_pos - b->width - distance; + } + } } - return(b); } -- GitLab