Skip to content
Snippets Groups Projects
Commit 39dc1a35 authored by Janos's avatar Janos
Browse files

kleinere Fehlerbehebungen

parent 68e891b8
Branches
Tags
No related merge requests found
......@@ -6,7 +6,7 @@
// -5000 <= pred_pos < 5000 <- Position des Vorgängerautos
// 0 <= pred_width < 500
// Nachbedingung: Ein struct Auto mit den Parametern wurde initialisiert
// Nachbedingung: Ein Auto wurde aus den Parametern initialisiert
struct Car* init_car(int speed,int width,int height,int pred_pos,int pred_width,enum vehicle t){
struct Car *b = malloc(sizeof(*b));
......@@ -165,7 +165,7 @@ int move_car(SDL_Renderer* renderer,struct Row *n){
}
cur->x_pos += n->speed;
paste_car(renderer,cur->x_pos,n->y_pos,cur->width,cur->height,n->speed,cur);
paste_car(renderer,cur->x_pos,n->y_pos,cur->width,cur->height,n->speed,cur->type);
if (cur->next == NULL){
break;
......
......@@ -6,6 +6,7 @@
#include <stdbool.h>
#include <SDL_rect.h>
#include <SDL_render.h>
#include <stdio.h>
//#include "auto.h"
#include "map.h"
//#include "main.h"
......
......@@ -22,6 +22,11 @@ struct LinkedList* init_map(enum vehicle theme){
struct LinkedList *list = malloc(sizeof(*list));
if (list == NULL){
perror("kein Speicherplatz");
}
struct Row *n = grass(true,false,SCREEN_HEIGHT - ROW_SIZE); //helles Gras mit y = 900
list->head = n;
......@@ -46,7 +51,7 @@ struct LinkedList* init_map(enum vehicle theme){
m = track( n->y_pos - ROW_SIZE);
}else if (theme == coin_gathered){
m = grass((i+1)%2,(i*ROW_SIZE + player->y/ROW_SIZE) % 100 == 98,n->y_pos - ROW_SIZE);
m = grass((i+1)%2,false,n->y_pos - ROW_SIZE);
}
n->next = m;
......
......@@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
#include <SDL_render.h>
#include "auto.h"
......
......@@ -60,26 +60,26 @@ int paste_row(SDL_Renderer* renderer, int y, enum row row_type){
return 0;
}
int paste_car(SDL_Renderer* renderer, int x, int y, int width, int height,int speed,struct Car* cur) {
int paste_car(SDL_Renderer* renderer, int x, int y, int width, int height,int speed,enum vehicle type) {
int offset = 20;
if (cur->type == coin){
if (type == coin){
offset = 25;
}
SDL_Rect rect = {
.x = x,
.y = y + offset, // Autos,Züge und Boote werden um 20 Pixel nach unten gesetzt, Münzen 30
.y = y + offset, // Autos,Züge und Boote werden um 20 Pixel nach unten gesetzt, Münzen um 25
.w = width,
.h = height};
if (cur->type == boat){
if (type == boat){
if (SDL_RenderCopy(renderer, img_plank, NULL, &rect) != 0) {
SDL_Log("Bild konnte nicht kopiert werden! SDL_Error Error: %s\n",SDL_GetError());
return(1);
}
return(0);
}else if(cur->type == car){
}else if(type == car){
if (speed > 0) {
if (SDL_RenderCopy(renderer, img_car_trans, NULL, &rect) != 0) {
SDL_Log("Bild konnte nicht kopiert werden! SDL_Error Error: %s\n",SDL_GetError());
......@@ -93,7 +93,7 @@ int paste_car(SDL_Renderer* renderer, int x, int y, int width, int height,int sp
}
return(0);
}
}else if(cur->type == train){
}else if(type == train){
if (speed > 0){
if (SDL_RenderCopy(renderer, img_trainR, NULL, &rect) != 0) {
SDL_Log("Bild konnte nicht kopiert werden! SDL_Error Error: %s\n",SDL_GetError());
......@@ -106,13 +106,13 @@ int paste_car(SDL_Renderer* renderer, int x, int y, int width, int height,int sp
}
}
return(0);
}else if(cur->type == coin){
}else if(type == coin){
if (SDL_RenderCopy(renderer, img_coin, NULL, &rect) != 0) {
SDL_Log("Bild konnte nicht kopiert werden! SDL_Error Error: %s\n",SDL_GetError());
return(1);
}
return(0);
}else if (cur->type == coin_gathered){
}else if (type == coin_gathered){
return(0);
}
if (SDL_RenderFillRect(renderer, &rect) != 0) {
......
......@@ -19,7 +19,7 @@
//Declaration of functions
int paste_row(SDL_Renderer*, int , enum row);
int paste_car(SDL_Renderer*, int, int, int, int,int,struct Car*);
int paste_car(SDL_Renderer*, int, int, int, int,int,enum vehicle);
int paste_score (SDL_Renderer*);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment