Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
But 1 Semestre 2
SAE Particule
Commits
939faf4a
Commit
939faf4a
authored
Jan 14, 2022
by
Léo TRANCHET
Browse files
modivication de la fonction Nettoyage
parent
d173bfbc
Changes
5
Hide whitespace changes
Inline
Side-by-side
config.json
View file @
939faf4a
...
...
@@ -4,14 +4,13 @@
"WindowSizeY"
:
600
,
"ParticleImage"
:
"assets/particle.png"
,
"Debug"
:
true
,
"InitNumParticles"
:
10
,
"InitNumParticles"
:
10
0000
,
"RandomSpawn"
:
true
,
"SpawnX"
:
400
,
"SpawnY"
:
400
,
"SpawnRate"
:
0
,
"SpeedLimit"
:
[
0
,
0
,
0
,
0
],
"Colors"
:
[
1
,
1
,
1
,
1
,
1
,
1
],
"SpeedLimit"
:
[
-1
,
1
,
-1
,
1
],
"Colors"
:
[
0
,
1
,
0
,
1
,
0
,
1
],
"Gravity"
:
false
,
"GravityCenter"
:
false
,
//
"LifeCycle"
:
0
"GravityCenter"
:
false
}
\ No newline at end of file
draw.go
View file @
939faf4a
...
...
@@ -15,12 +15,16 @@ import (
func
(
g
*
game
)
Draw
(
screen
*
ebiten
.
Image
)
{
for
_
,
p
:=
range
g
.
system
.
Content
{
options
:=
ebiten
.
DrawImageOptions
{}
options
.
GeoM
.
Rotate
(
p
.
Rotation
)
options
.
GeoM
.
Scale
(
p
.
ScaleX
,
p
.
ScaleY
)
options
.
GeoM
.
Translate
(
p
.
PositionX
,
p
.
PositionY
)
options
.
ColorM
.
Scale
(
p
.
ColorRed
,
p
.
ColorGreen
,
p
.
ColorBlue
,
p
.
Opacity
)
screen
.
DrawImage
(
assets
.
ParticleImage
,
&
options
)
if
p
.
Overflow
{
continue
}
else
{
options
:=
ebiten
.
DrawImageOptions
{}
options
.
GeoM
.
Rotate
(
p
.
Rotation
)
options
.
GeoM
.
Scale
(
p
.
ScaleX
,
p
.
ScaleY
)
options
.
GeoM
.
Translate
(
p
.
PositionX
,
p
.
PositionY
)
options
.
ColorM
.
Scale
(
p
.
ColorRed
,
p
.
ColorGreen
,
p
.
ColorBlue
,
p
.
Opacity
)
screen
.
DrawImage
(
assets
.
ParticleImage
,
&
options
)
}
}
if
config
.
General
.
Debug
{
...
...
particles/new.go
View file @
939faf4a
...
...
@@ -30,6 +30,7 @@ func GenPart() (Particle) { // Crée une particule avec Px,Py comme position
Opacity
:
1
,
SpeedX
:
config
.
General
.
SpeedLimit
[
0
]
+
rand
.
Float64
()
*
(
config
.
General
.
SpeedLimit
[
1
]
-
config
.
General
.
SpeedLimit
[
0
]),
SpeedY
:
config
.
General
.
SpeedLimit
[
2
]
+
rand
.
Float64
()
*
(
config
.
General
.
SpeedLimit
[
3
]
-
config
.
General
.
SpeedLimit
[
2
]),
Overflow
:
false
,
}
}
...
...
particles/type.go
View file @
939faf4a
...
...
@@ -22,4 +22,5 @@ type Particle struct {
SpeedX
,
SpeedY
float64
Gravity
bool
GravityCenter
bool
Overflow
bool
}
particles/update.go
View file @
939faf4a
...
...
@@ -8,13 +8,10 @@ import "project-particles/config"
// projet.
// C'est à vous de développer cette fonction.
func
Nettoyage
(
tab
[]
*
Particle
)
([]
*
Particle
){
maxi
:=
float64
(
config
.
General
.
WindowSizeX
)
mini
:=
float64
(
config
.
General
.
WindowSizeY
)
func
Nettoyage
(
tab
[]
Particle
)
([]
Particle
){
for
i
:=
0
;
i
<
len
(
tab
);
i
++
{
if
tab
[
i
]
.
PositionX
>
maxi
||
tab
[
i
]
.
PositionX
<
0
||
tab
[
i
]
.
PositionY
>
mini
||
tab
[
i
]
.
PositionY
<
-
10
{
tab
=
append
(
tab
[
:
i
],
tab
[
i
+
1
:
]
...
)
i
=
i
-
1
if
int
(
tab
[
i
]
.
PositionX
)
>
config
.
General
.
WindowSizeX
||
int
(
tab
[
i
]
.
PositionX
)
<
100
||
int
(
tab
[
i
]
.
PositionY
)
>
config
.
General
.
WindowSizeY
||
int
(
tab
[
i
]
.
PositionY
)
<
-
10
{
tab
[
i
]
.
Overflow
=
true
}
}
return
tab
...
...
@@ -94,15 +91,7 @@ func spirale(p Particle) (Particle){
func
(
s
*
System
)
Update
()
{
var
tabPointeursParticle
[]
*
Particle
for
i
:=
0
;
i
<
len
(
s
.
Content
);
i
++
{
tabPointeursParticle
=
append
(
tabPointeursParticle
,
&
s
.
Content
[
i
])
}
tabPointeursParticle
=
Nettoyage
(
tabPointeursParticle
)
s
.
Content
=
[]
Particle
{}
for
i
:=
0
;
i
<
len
(
tabPointeursParticle
);
i
++
{
s
.
Content
=
append
(
s
.
Content
,
*
tabPointeursParticle
[
i
])
}
s
.
Content
=
Nettoyage
(
s
.
Content
)
for
i
:=
0
;
i
<
len
(
s
.
Content
);
i
++
{
s
.
Content
[
i
]
.
PositionX
+=
s
.
Content
[
i
]
.
SpeedX
...
...
@@ -115,10 +104,10 @@ func (s *System) Update() {
}
}
NbSpaw
:=
config
.
General
.
SpawnRate
+
s
.
SpawBuffer
for
i
:=
0
;
i
<
int
(
NbSpaw
);
i
++
{
NbSpaw
n
:=
config
.
General
.
SpawnRate
+
s
.
SpawBuffer
for
i
:=
0
;
i
<
int
(
NbSpaw
n
);
i
++
{
s
.
Content
=
append
(
s
.
Content
,
GenPart
())
}
s
.
SpawBuffer
=
NbSpaw
-
float64
(
int
(
NbSpaw
))
s
.
SpawBuffer
=
NbSpaw
n
-
float64
(
int
(
NbSpaw
n
))
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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