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
71b4bfa7
Commit
71b4bfa7
authored
1 year ago
by
Michael
Browse files
Options
Downloads
Patches
Plain Diff
added commentary to output.c
parent
7c698a5d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
output.c
+14
-2
14 additions, 2 deletions
output.c
with
14 additions
and
2 deletions
output.c
+
14
−
2
View file @
71b4bfa7
#include
"output.h"
#include
"output.h"
//V: renderer exists, enum row_type is correct and not renamed, correct y coordinates are transferred
//N: img corresponding to row_type is set to coordinates: x: 0 to 900 y: y to y+100 and displayed via renderer
int
paste_row
(
SDL_Renderer
*
renderer
,
int
y
,
enum
row
row_type
){
int
paste_row
(
SDL_Renderer
*
renderer
,
int
y
,
enum
row
row_type
){
SDL_Rect
destination
=
{
SDL_Rect
destination
=
{
...
@@ -60,7 +62,10 @@ int paste_row(SDL_Renderer* renderer, int y, enum row row_type){
...
@@ -60,7 +62,10 @@ int paste_row(SDL_Renderer* renderer, int y, enum row row_type){
return
0
;
return
0
;
}
}
//V renderer exists, correct x, y coordinates and width and height and speed and type of car is passed on
//N: car is set to correct variables and displayed in renderer with correct image and direction
int
paste_car
(
SDL_Renderer
*
renderer
,
int
x
,
int
y
,
int
width
,
int
height
,
int
speed
,
enum
vehicle
type
)
{
int
paste_car
(
SDL_Renderer
*
renderer
,
int
x
,
int
y
,
int
width
,
int
height
,
int
speed
,
enum
vehicle
type
)
{
//Prevents cars from being displayed at the wrong position
int
offset
=
20
;
int
offset
=
20
;
if
(
type
==
coin
){
if
(
type
==
coin
){
...
@@ -73,6 +78,8 @@ int paste_car(SDL_Renderer* renderer, int x, int y, int width, int height,int sp
...
@@ -73,6 +78,8 @@ int paste_car(SDL_Renderer* renderer, int x, int y, int width, int height,int sp
.
w
=
width
,
.
w
=
width
,
.
h
=
height
};
.
h
=
height
};
//correct "car" type is displayed
//could be implemented like above with switch case
if
(
type
==
boat
){
if
(
type
==
boat
){
if
(
SDL_RenderCopy
(
renderer
,
img_plank
,
NULL
,
&
rect
)
!=
0
)
{
if
(
SDL_RenderCopy
(
renderer
,
img_plank
,
NULL
,
&
rect
)
!=
0
)
{
SDL_Log
(
"Bild konnte nicht kopiert werden! SDL_Error Error: %s
\n
"
,
SDL_GetError
());
SDL_Log
(
"Bild konnte nicht kopiert werden! SDL_Error Error: %s
\n
"
,
SDL_GetError
());
...
@@ -123,7 +130,9 @@ int paste_car(SDL_Renderer* renderer, int x, int y, int width, int height,int sp
...
@@ -123,7 +130,9 @@ int paste_car(SDL_Renderer* renderer, int x, int y, int width, int height,int sp
return
(
0
);
return
(
0
);
}
}
//used to calculate width of score display
//V: score exists
//N: returns int corresponding to digits of score
int
func_digits
(
int
score
){
int
func_digits
(
int
score
){
if
(
score
==
0
)
if
(
score
==
0
)
return
(
1
);
return
(
1
);
...
@@ -135,6 +144,8 @@ int func_digits(int score){
...
@@ -135,6 +144,8 @@ int func_digits(int score){
return
(
i
);
return
(
i
);
}
}
//V: renderer exists
//N: current playerhighscore is displayed in white in the upper right corner
int
paste_score
(
SDL_Renderer
*
renderer
)
{
int
paste_score
(
SDL_Renderer
*
renderer
)
{
int
digits
=
func_digits
(
playerhighscore
);
int
digits
=
func_digits
(
playerhighscore
);
...
@@ -157,7 +168,8 @@ int paste_score (SDL_Renderer* renderer) {
...
@@ -157,7 +168,8 @@ int paste_score (SDL_Renderer* renderer) {
return
-
1
;
return
-
1
;
}
}
char
output
[
5
];
char
output
[
10
];
//max displayable score has 10 digits
sprintf
(
output
,
"%d"
,
playerhighscore
);
sprintf
(
output
,
"%d"
,
playerhighscore
);
SDL_Surface
*
surfaceMessage
=
SDL_Surface
*
surfaceMessage
=
TTF_RenderText_Blended_Wrapped
(
font
,
output
,
(
SDL_Color
)
{
225
,
225
,
225
,
255
},
4
*
200
);
TTF_RenderText_Blended_Wrapped
(
font
,
output
,
(
SDL_Color
)
{
225
,
225
,
225
,
255
},
4
*
200
);
...
...
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