Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProjetZZ1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc BERET
ProjetZZ1
Commits
c6631086
Commit
c6631086
authored
Jun 27, 2022
by
belkhiritaha
Browse files
Options
Downloads
Patches
Plain Diff
affichage des murs derrière les murs transparents
parent
2044d917
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
travail_de_groupe/jeu_appren_par_renfo/src/render.c
+68
-26
68 additions, 26 deletions
travail_de_groupe/jeu_appren_par_renfo/src/render.c
with
68 additions
and
26 deletions
travail_de_groupe/jeu_appren_par_renfo/src/render.c
+
68
−
26
View file @
c6631086
...
...
@@ -80,11 +80,38 @@ void endSDL(){
SDL_Quit
();
}
void
drawRayColumn
(
float
ra
,
float
distT
,
int
r
,
int
isTransparent
,
int
direction
){
float
ca
=
player
.
angle
-
ra
;
if
(
ca
<
0
)
ca
+=
2
*
pi
;
if
(
ca
>
2
*
pi
)
ca
-=
2
*
pi
;
distT
=
distT
*
cos
(
ca
);
float
lineH
=
(
screenDimension
.
h
/
2
)
/
distT
;
rect
.
x
=
r
;
rect
.
y
=
(
screenDimension
.
h
/
2
+
player
.
viewAngle
)
-
lineH
;
rect
.
w
=
1
;
rect
.
h
=
(
2
*
screenDimension
.
w
*
lineH
/
20
);
if
(
isTransparent
){
rect
.
h
*=
0
.
75
;
rect
.
y
-=
rect
.
h
/
3
;
}
if
(
direction
){
SDL_SetRenderDrawColor
(
renderer
,
255
*
(
1
-
isTransparent
),
255
,
0
,
255
*
(
1
-
isTransparent
));
}
else
{
SDL_SetRenderDrawColor
(
renderer
,
0
,
255
,
255
,
255
*
(
1
-
isTransparent
));
}
SDL_RenderFillRect
(
renderer
,
&
rect
);
SDL_SetRenderDrawColor
(
renderer
,
0
,
0
,
0
,
255
);
}
void
drawRays
(
int
map
[][
MAP_WIDTH
]){
// ray casting variables
float
htexture
;
int
r
,
mx
,
my
,
dof
;
double
rx
,
ry
,
xo
,
yo
,
distT
;
double
rx
,
ry
,
rx2
,
ry2
,
xo
,
yo
,
distT
,
distT2
;
double
ra
;
mx
=
0
;
my
=
0
;
...
...
@@ -195,22 +222,48 @@ void drawRays(int map[][MAP_WIDTH]){
}
}
int
direction
,
direction2
;
if
(
foundTransparentWallV
){
if
(
disH
<
disV2
){
rx
=
hx2
;
ry
=
hy2
;
distT
=
disH2
;
SDL_SetRenderDrawColor
(
renderer
,
255
,
255
,
0
,
255
)
;
direction
=
0
;
}
else
{
rx
=
vx2
;
ry
=
vy2
;
distT
=
disV2
;
SDL_SetRenderDrawColor
(
renderer
,
255
,
255
,
0
,
255
)
;
direction
=
1
;
}
if
(
foundSolidWallV
){
printf
(
"found solid wall
\n
"
);
if
(
disH
<
disV
){
rx2
=
hx
;
ry2
=
hy
;
distT2
=
disH
;
direction2
=
0
;
}
else
{
rx2
=
vx
;
ry2
=
vy
;
distT2
=
disV
;
direction2
=
1
;
}
}
if
(
foundSolidWallH
){
if
(
disH
<
disV
){
rx2
=
hx
;
ry2
=
hy
;
distT2
=
disH
;
direction2
=
0
;
}
else
{
rx2
=
vx
;
ry2
=
vy
;
distT2
=
disV
;
direction2
=
1
;
}
}
}
...
...
@@ -219,13 +272,13 @@ void drawRays(int map[][MAP_WIDTH]){
rx
=
hx
;
ry
=
hy
;
distT
=
disH
;
SDL_SetRenderDrawColor
(
renderer
,
255
,
0
,
0
,
255
)
;
direction
=
0
;
}
else
{
rx
=
vx
;
ry
=
vy
;
distT
=
disV
;
SDL_SetRenderDrawColor
(
renderer
,
0
,
255
,
255
,
255
)
;
direction
=
1
;
}
}
...
...
@@ -234,27 +287,16 @@ void drawRays(int map[][MAP_WIDTH]){
if
(
ra
>
2
*
pi
)
ra
-=
2
*
pi
;
if
(
ra
<
0
)
ra
+=
2
*
pi
;
// draw column
float
ca
=
player
.
angle
-
ra
;
if
(
ca
<
0
)
ca
+=
2
*
pi
;
if
(
ca
>
2
*
pi
)
ca
-=
2
*
pi
;
distT
=
distT
*
cos
(
ca
);
float
lineH
=
(
screenDimension
.
h
/
2
)
/
distT
;
rect
.
x
=
r
;
rect
.
y
=
(
screenDimension
.
h
/
2
+
player
.
viewAngle
)
-
lineH
;
rect
.
w
=
1
;
rect
.
h
=
(
2
*
screenDimension
.
w
*
lineH
/
20
);
// draw ray
drawRayColumn
(
ra
,
distT
,
r
,
foundTransparentWallV
,
direction
);
if
(
foundTransparentWallV
){
rect
.
h
*=
1
.
75
;
rect
.
y
-=
rect
.
h
/
3
;
if
(
foundSolidWallV
){
drawRayColumn
(
ra
,
distT2
,
r
,
0
,
direction2
);
}
else
{
drawRayColumn
(
ra
,
distT2
,
r
,
0
,
direction
);
}
}
SDL_RenderFillRect
(
renderer
,
&
rect
);
SDL_SetRenderDrawColor
(
renderer
,
0
,
0
,
0
,
255
);
// draw the ray in the minimap
addRayToList
(
rx
,
ry
);
...
...
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