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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc BERET
ProjetZZ1
Commits
6ebc4c7e
Commit
6ebc4c7e
authored
2 years ago
by
antoinemeyer5
Browse files
Options
Downloads
Patches
Plain Diff
remise en place des bonnes trajectoires aleatoires et dans la bonne direction
parent
4886f8fb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
travail_de_groupe/jeu_appren_par_renfo/src/ball.c
+1
-1
1 addition, 1 deletion
travail_de_groupe/jeu_appren_par_renfo/src/ball.c
travail_de_groupe/jeu_appren_par_renfo/src/player.c
+19
-31
19 additions, 31 deletions
travail_de_groupe/jeu_appren_par_renfo/src/player.c
with
20 additions
and
32 deletions
travail_de_groupe/jeu_appren_par_renfo/src/ball.c
+
1
−
1
View file @
6ebc4c7e
...
...
@@ -6,7 +6,7 @@ int trajectoireAntoine[NUMBERPOINT_TRAJEC][2];
void
initBall
()
{
ball
.
x
=
5
*
BLOCK_SIZE
;
ball
.
y
=
2
*
BLOCK_SIZE
;
ball
.
y
=
5
*
BLOCK_SIZE
;
ball
.
z
=
player
.
h
/
BLOCK_SIZE
;
ball
.
h
=
0
.
5
*
BLOCK_SIZE
;
ball
.
w
=
0
.
5
*
BLOCK_SIZE
;
...
...
This diff is collapsed.
Click to expand it.
travail_de_groupe/jeu_appren_par_renfo/src/player.c
+
19
−
31
View file @
6ebc4c7e
...
...
@@ -5,6 +5,7 @@ player_t ennemy;
int
*
landingPoint
;
int
*
lastHitPoint
;
int
landingPointIsFind
=
0
;
void
initPlayer
()
{
...
...
@@ -29,15 +30,18 @@ void initPlayer()
player
.
viewAngle
=
0
;
}
int
*
generateLandingPoint
()
int
*
generateLandingPoint
(
int
rxWall
)
{
int
*
landingPoint
=
malloc
(
sizeof
(
int
)
*
2
);
int
randomLength
=
rand
()
%
(
int
)((
MAP_WIDTH
/
2
)
*
BLOCK_SIZE
)
+
(
MAP_WIDTH
/
2
)
*
BLOCK_SIZE
;
int
randomPointX
=
randomLength
*
cos
(
player
.
angle
)
+
player
.
x
;
int
randomPointY
=
randomLength
*
sin
(
player
.
angle
)
+
player
.
y
;
landingPoint
[
0
]
=
randomPointX
/
BLOCK_SIZE
;
srand
(
time
(
NULL
));
int
randomPointX
=
MAP_WIDTH
/
2
+
1
+
rand
()
%
(
rxWall
/
BLOCK_SIZE
-
(
MAP_WIDTH
/
2
));
int
randomPointY
=
-
1
;
landingPoint
[
0
]
=
randomPointX
;
landingPoint
[
1
]
=
randomPointY
/
BLOCK_SIZE
;
// printf("landing point: %d %d\n", landingPoint[0], landingPoint[1]);
landingPointIsFind
=
1
;
return
landingPoint
;
}
...
...
@@ -59,19 +63,6 @@ void freeIntList(int *list)
void
hitBall
()
{
// printf("map edges: %d %d\n", BLOCK_SIZE * MAP_WIDTH/2, BLOCK_SIZE *MAP_HEIGHT/2);
// printf("ray1: %d %d\n", ray1[0], ray1[1]);
int
fermetureAngle
=
2
;
//int angleMin = RD * atan2((MAP_WIDTH+fermetureAngle / 2) * BLOCK_SIZE - player.x, player.y);
//int angleMax = 90 + RD * atan2((MAP_WIDTH+fermetureAngle / 2) * BLOCK_SIZE - player.x, MAP_HEIGHT * BLOCK_SIZE - player.y);
//int currAngle = (int)((player.angle) * RD + 90) % 360;
//printf("player angle: %d\n",(int) ((player.angle) * RD +90) %360);
//printf("angle min: %d\n", angleMin);
//printf("angle max: %d\n", angleMax);
//printf("distance to ball: %f\n", sqrt(pow(ball.x - player.x, 2) + pow(ball.y - player.y, 2))/BLOCK_SIZE);
if
(
sqrt
(
pow
(
player
.
x
-
ball
.
x
,
2
)
+
pow
(
player
.
y
-
ball
.
y
,
2
))
/
BLOCK_SIZE
<
HIT_RANGE
)
{
int
rxWall
,
ryWall
;
...
...
@@ -82,26 +73,23 @@ void hitBall()
if
(
player
.
isHitting
)
{
castSingleRay
(
player
.
angle
,
&
distanceWall
,
&
distanceNet
,
&
rxWall
,
&
ryWall
,
&
rxNet
,
&
ryNet
);
printf
(
"rayWall: %d %d
\n
"
,
rxWall
/
BLOCK_SIZE
,
ryWall
/
BLOCK_SIZE
);
printf
(
"distanceWall: %f
\n
"
,
distanceWall
);
printf
(
"rayNet: %d %d
\n
"
,
rxNet
/
BLOCK_SIZE
,
ryNet
/
BLOCK_SIZE
);
printf
(
"distanceNet: %f
\n
"
,
distanceNet
);
// printf("hit\n");
if
(
rxWall
>
MAP_WIDTH
/
2
)
{
freeIntList
(
landingPoint
);
freeIntList
(
lastHitPoint
);
freeIntList
(
lastHitPoint
);
lastHitPoint
=
allocLastHitPoint
();
//cherche et trouve point de chute, UNE SEULE FOIS!
if
(
landingPointIsFind
==
0
){
freeIntList
(
landingPoint
);
landingPoint
=
generateLandingPoint
(
rxWall
);
printf
(
"landing point: x=%d; y=%d
\n
"
,
landingPoint
[
0
],
landingPoint
[
1
]);
}
lastHitPoint
=
allocLastHitPoint
();
landingPoint
=
generateLandingPoint
();
lastHitPoint
[
0
]
=
ball
.
x
;
lastHitPoint
[
1
]
=
player
.
h
;
/*ball.x = player.x;
ball.y = player.y;
ball.z = player.h;*/
ball
.
angle
=
player
.
angle
;
ball
.
speed
=
2
*
HIT_FORCE
;
ball
.
z
=
player
.
h
;
...
...
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