Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GAME INSA PROJECT
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
3EII INFO LKCH
GAME INSA PROJECT
Commits
83be1695
Commit
83be1695
authored
4 years ago
by
Le-Bao-Tin.Ha
Browse files
Options
Downloads
Patches
Plain Diff
Ameliorer -> version 0.8
parent
ba191e70
No related branches found
No related tags found
4 merge requests
!8
Modele
,
!7
Modele
,
!6
Modele
,
!5
Modele Version 1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GAME/include/GAME.h
+3
-3
3 additions, 3 deletions
GAME/include/GAME.h
GAME/src/GAME.c
+57
-18
57 additions, 18 deletions
GAME/src/GAME.c
with
60 additions
and
21 deletions
GAME/include/GAME.h
+
3
−
3
View file @
83be1695
...
...
@@ -13,10 +13,10 @@
#include
"map.h"
#include
"DS.h"
int
testposition
(
Personnage
*
pers
,
Prof
*
prof
,
DS
*
exam
,
MAP
*
map
);
// return 0 if nothing, 1 if wall, 2 if exam, 3 if prof, 4 if bounds
int
testposition
(
Personnage
*
pers
,
Prof
*
prof
,
DS
*
exam
,
MAP
*
map
,
int
,
int
,
int
,
int
);
// return 0 if nothing, 1 if wall, 2 if exam, 3 if prof, 4 if bounds
int
testboundscol
(
Personnage
*
pers
);
int
testprofcol
(
Personnage
*
pers
,
Prof
*
prof
);
int
testmapcol
(
Personnage
*
pers
,
MAP
*
map
,
DS
*
exam
);
int
testprofcol
(
Personnage
*
pers
,
Prof
*
prof
,
int
x_A
,
int
y_A
,
int
x_B
,
int
y_B
);
int
testmapcol
(
Personnage
*
pers
,
MAP
*
map
,
DS
*
exam
,
int
x_A
,
int
y_A
,
int
x_B
,
int
y_B
);
#endif
/*INSAGAME_GAME_H*/
This diff is collapsed.
Click to expand it.
GAME/src/GAME.c
+
57
−
18
View file @
83be1695
...
...
@@ -12,12 +12,41 @@
#define WINDOW_WIDTH (700)
#define WINDOW_HEIGHT (700)
int
testposition
(
Personnage
*
pers
,
Prof
*
prof
,
DS
*
exam
,
MAP
*
map
){
int
testposition
(
Personnage
*
pers
,
Prof
*
prof
,
DS
*
exam
,
MAP
*
map
,
int
up
,
int
down
,
int
left
,
int
right
){
int
x_A
=
0
,
x_B
=
0
,
y_A
=
0
,
y_B
=
0
;
//calculer les points
if
(
up
&&
!
down
)
{
x_A
=
pers
->
x_pers
;
y_A
=
pers
->
y_pers
;
x_B
=
pers
->
x_pers
+
pers
->
larg_pers
;
y_B
=
pers
->
y_pers
;
}
if
(
down
&&
!
up
)
{
x_A
=
pers
->
x_pers
;
y_A
=
pers
->
y_pers
+
pers
->
long_pers
;
x_B
=
pers
->
x_pers
+
pers
->
larg_pers
;
y_B
=
pers
->
y_pers
+
pers
->
long_pers
;
}
if
(
left
&&
!
right
)
{
x_A
=
pers
->
x_pers
;
y_A
=
pers
->
y_pers
;
x_B
=
pers
->
x_pers
;
y_B
=
pers
->
y_pers
+
pers
->
long_pers
;
}
if
(
right
&&
!
left
)
{
x_A
=
pers
->
x_pers
+
pers
->
larg_pers
;
y_A
=
pers
->
y_pers
;
x_B
=
pers
->
x_pers
+
pers
->
larg_pers
;
y_B
=
pers
->
y_pers
+
pers
->
long_pers
;
}
//test variables
int
testbounds
=
testboundscol
(
pers
);
;
int
testprof
=
testprofcol
(
pers
,
prof
);
int
testmap
=
testmapcol
(
pers
,
map
,
exam
);
// = 0 if nothing , 1 if wall, 2 if exam
int
testprof
=
testprofcol
(
pers
,
prof
,
x_A
,
y_A
,
x_B
,
y_B
);
//test bounds collision
...
...
@@ -30,7 +59,7 @@ int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map){
//return the map test position
return
testmapcol
(
pers
,
map
,
exam
);
return
testmapcol
(
pers
,
map
,
exam
,
x_A
,
y_A
,
x_B
,
y_B
);
// = 0 if nothing , 1 if wall, 2 if exam
}
...
...
@@ -41,33 +70,43 @@ int testboundscol(Personnage * pers){
return
0
;
}
int
testprofcol
(
Personnage
*
pers
,
Prof
*
prof
){
//calculer milieu
int
x_milieu
=
pers
->
x_pers
+
(
pers
->
larg_pers
/
2
);
int
y_milieu
=
pers
->
y_pers
+
(
pers
->
long_pers
/
2
);
int
testprofcol
(
Personnage
*
pers
,
Prof
*
prof
,
int
x_A
,
int
y_A
,
int
x_B
,
int
y_B
){
//test position vs prof
if
((
x_
milieu
>
prof
->
x_prof
)
&&
(
x_
milieu
<
prof
->
x_prof
+
prof
->
larg_prof
))
{
if
((
y_
milieu
>
prof
->
y_prof
)
&&
(
y_
milieu
<
prof
->
y_prof
+
prof
->
long_prof
))
{
if
((
x_
A
>
prof
->
x_prof
)
&&
(
x_
A
<
prof
->
x_prof
+
prof
->
larg_prof
))
{
if
((
y_
A
>
prof
->
y_prof
)
&&
(
y_
A
<
prof
->
y_prof
+
prof
->
long_prof
))
{
return
1
;
}
}
if
((
x_B
>
prof
->
x_prof
)
&&
(
x_B
<
prof
->
x_prof
+
prof
->
larg_prof
))
{
if
((
y_B
>
prof
->
y_prof
)
&&
(
y_B
<
prof
->
y_prof
+
prof
->
long_prof
))
{
return
1
;
}
}
return
0
;
}
int
testmapcol
(
Personnage
*
pers
,
MAP
*
map
,
DS
*
exam
){
//calculer milieu
int
x_milieu
=
pers
->
x_pers
+
(
pers
->
larg_pers
/
2
);
int
y_milieu
=
pers
->
y_pers
+
(
pers
->
long_pers
/
2
);
int
testmapcol
(
Personnage
*
pers
,
MAP
*
map
,
DS
*
exam
,
int
x_A
,
int
y_A
,
int
x_B
,
int
y_B
){
if
(
map
->
functional
[
y_
milieu
][
x_milieu
]
==
2
){
//if zone exams
if
(
map
->
functional
[
y_
A
][
x_A
]
==
2
){
//if zone exams
//test exam collision
if
((
x_
milieu
>
exam
->
x_DS
)
&&
(
x_
milieu
<
exam
->
x_DS
+
exam
->
larg_DS
))
{
if
((
x_
A
>
exam
->
x_DS
)
&&
(
x_
A
<
exam
->
x_DS
+
exam
->
larg_DS
))
{
return
2
;
}
}
else
if
(
map
->
functional
[
y_milieu
][
x_milieu
]
==
1
){
//if zone wall
else
if
(
map
->
functional
[
y_A
][
x_A
]
==
1
){
//if zone wall
return
1
;
}
if
(
map
->
functional
[
y_B
][
x_B
]
==
2
){
//if zone exams
//test exam collision
if
((
x_B
>
exam
->
x_DS
)
&&
(
x_B
<
exam
->
x_DS
+
exam
->
larg_DS
))
{
return
2
;
}
}
else
if
(
map
->
functional
[
y_B
][
x_B
]
==
1
){
//if zone wall
return
1
;
}
return
0
;
//if nothing
...
...
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