Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jean Descamps
projet_IA04
Commits
af416861
Commit
af416861
authored
Dec 31, 2021
by
Louis Soto
Browse files
correctif levels
parent
41a11eff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Boid/flock/flock.go
View file @
af416861
...
...
@@ -3,6 +3,7 @@ package flock
import
(
boid
"gitlab.utc.fr/projet_ia04/Boid/agent/boid"
wall
"gitlab.utc.fr/projet_ia04/Boid/agent/wall"
"gitlab.utc.fr/projet_ia04/Boid/utils/constant"
)
type
Flock
struct
{
...
...
@@ -11,7 +12,7 @@ type Flock struct {
Predators
[]
*
boid
.
Predator
}
func
(
flock
*
Flock
)
Logic
()
{
func
(
flock
*
Flock
)
Logic
(
level
int
)
{
for
_
,
boid
:=
range
flock
.
Boids
{
if
!
boid
.
CheckEdges
()
{
if
!
boid
.
CheckWalls
(
flock
.
Walls
)
{
...
...
@@ -19,6 +20,15 @@ func (flock *Flock) Logic() {
}
}
boid
.
ApplyMovement
()
// Pour éviter que les poissons réussissent à s'échapper des murs de bombes
// dans les niveaux supérieurs ou égal au niveau 4: (le dernier niveau pour le moment)
// Dès que l'on detecte qu'ils ne sont pas où ils devraient être, on les fait réapparaitre au centre
if
level
>=
4
&&
(
boid
.
Position
.
Y
<=
0
||
boid
.
Position
.
Y
>=
float64
(
constant
.
ScreenHeight
))
{
boid
.
Position
.
Y
=
float64
(
constant
.
ScreenHeight
)
/
2
}
}
for
_
,
preda
:=
range
flock
.
Predators
{
if
!
preda
.
CheckEdges
()
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment