Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jumpNrun
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wise2023_jumpnrun
jumpNrun
Commits
39dc1a35
Commit
39dc1a35
authored
1 year ago
by
Janos
Browse files
Options
Downloads
Patches
Plain Diff
kleinere Fehlerbehebungen
parent
68e891b8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
auto.c
+4
-4
4 additions, 4 deletions
auto.c
gameLoop.h
+1
-0
1 addition, 0 deletions
gameLoop.h
map.c
+7
-2
7 additions, 2 deletions
map.c
map.h
+1
-0
1 addition, 0 deletions
map.h
output.c
+8
-8
8 additions, 8 deletions
output.c
output.h
+1
-1
1 addition, 1 deletion
output.h
with
22 additions
and
15 deletions
auto.c
+
4
−
4
View file @
39dc1a35
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
gameLoop.h
+
1
−
0
View file @
39dc1a35
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
map.c
+
7
−
2
View file @
39dc1a35
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
map.h
+
1
−
0
View file @
39dc1a35
...
...
@@ -3,6 +3,7 @@
#include
<stdbool.h>
#include
<stdlib.h>
#include
<stdio.h>
#include
<SDL.h>
#include
<SDL_render.h>
#include
"auto.h"
...
...
This diff is collapsed.
Click to expand it.
output.c
+
8
−
8
View file @
39dc1a35
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
output.h
+
1
−
1
View file @
39dc1a35
...
...
@@ -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
*
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment