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
3b0b54ac
Commit
3b0b54ac
authored
Jan 16, 2022
by
Rennarde
Browse files
Add transparency
parent
f9d41712
Changes
5
Hide whitespace changes
Inline
Side-by-side
Extension/LifeCycle/lifecycle.go
deleted
100644 → 0
View file @
f9d41712
package
lifeycycle
import
(
//"project-particles/config"
"project-particles/particles"
)
func
Life
(
Part
*
Particle
)
{
*
Part
.
Life
=
*
Part
.
Life
-
1
if
*
Part
.
Life
<
0
{
*
Part
.
Overflow
=
true
}
}
\ No newline at end of file
Extension/
LifeCycle/
life.json
→
Extension/life.json
View file @
3b0b54ac
...
...
@@ -8,10 +8,12 @@
"RandomSpawn"
:
true
,
"SpawnX"
:
400
,
"SpawnY"
:
400
,
"SpawnRate"
:
0
,
"SpawnRate"
:
0.
0
,
"SpeedLimit"
:
[
0
,
0
,
0
,
0
],
"Colors"
:
[
1
,
1
,
1
,
1
,
1
,
1
],
"Colors"
:
[
0
,
1
,
0
,
1
,
0
,
1
],
"Gravity"
:
false
,
"GravityCenter"
:
false
,
"NumCycle"
:
300
"NumCycle"
:
600
,
"LifeOpt"
:
"fade"
,
"Death"
:
true
}
\ No newline at end of file
config/type.go
View file @
3b0b54ac
...
...
@@ -20,6 +20,8 @@ type Config struct {
Colors
[]
float64
Gravity
,
GravityCenter
bool
NumCycle
int
LifeOpt
string
Death
bool
}
var
General
Config
main.go
View file @
3b0b54ac
...
...
@@ -52,7 +52,7 @@ func commands() {
Aliases
:
[]
string
{
"l"
},
Usage
:
"Give particule a
\"
Life Cycle
\"
"
,
Action
:
func
(
c
*
cli
.
Context
)
{
ExecPart
(
"./Extension/
Wesh
.json"
)
ExecPart
(
"./Extension/
life
.json"
)
},
},
}
...
...
particles/update.go
View file @
3b0b54ac
package
particles
import
"project-particles/config"
import
(
"project-particles/config"
)
// Update mets à jour l'état du système de particules (c'est-à-dire l'état de
// chacune des particules) à chaque pas de temps. Elle est appellée exactement
...
...
@@ -10,14 +12,29 @@ import "project-particles/config"
func
Nettoyage
(
tab
[]
Particle
)
([]
Particle
){
for
i
:=
0
;
i
<
len
(
tab
);
i
++
{
if
int
(
tab
[
i
]
.
PositionX
)
>
config
.
General
.
WindowSizeX
||
int
(
tab
[
i
]
.
PositionX
)
<
10
0
||
int
(
tab
[
i
]
.
PositionY
)
>
config
.
General
.
WindowSizeY
||
int
(
tab
[
i
]
.
PositionY
)
<
-
10
{
if
int
(
tab
[
i
]
.
PositionX
)
>
config
.
General
.
WindowSizeX
||
int
(
tab
[
i
]
.
PositionX
)
<
0
||
int
(
tab
[
i
]
.
PositionY
)
>
config
.
General
.
WindowSizeY
||
int
(
tab
[
i
]
.
PositionY
)
<
-
10
{
tab
[
i
]
.
Overflow
=
true
}
}
return
tab
}
func
UpdateCycle
(
Part
Particle
)
(
Particle
)
{
Part
.
Life
=
Part
.
Life
-
1
if
config
.
General
.
Death
&&
Part
.
Life
<
0
{
Part
.
Overflow
=
true
}
// if config.General.LifeOpt == "white" {
// Part.ColorRed += (1-Part.ColorRed)*(1-(float64(Part.Life) / float64(config.General.NumCycle)))
// Part.ColorBlue += (1-Part.ColorBlue)*(1-(float64(Part.Life) / float64(config.General.NumCycle)))
// Part.ColorGreen += (1-Part.ColorGreen)*(1-(float64(Part.Life) / float64(config.General.NumCycle)))
// fmt.Println(Part.ColorRed,Part.ColorBlue,Part.ColorGreen)
// }
if
config
.
General
.
LifeOpt
==
"fade"
{
Part
.
Opacity
=
(
float64
(
Part
.
Life
)
/
float64
(
config
.
General
.
NumCycle
))
}
return
Part
}
func
gravite
(
p
Particle
)
(
Particle
){
if
p
.
SpeedY
>
0
{
...
...
@@ -88,8 +105,6 @@ func spirale(p Particle) (Particle){
return
p
}
func
(
s
*
System
)
Update
()
{
s
.
Content
=
Nettoyage
(
s
.
Content
)
...
...
@@ -102,7 +117,12 @@ func (s *System) Update() {
if
config
.
General
.
GravityCenter
{
s
.
Content
[
i
]
=
spirale
(
s
.
Content
[
i
])
}
if
config
.
General
.
NumCycle
>
0
{
s
.
Content
[
i
]
=
UpdateCycle
(
s
.
Content
[
i
])
}
}
NbSpawn
:=
config
.
General
.
SpawnRate
+
s
.
SpawBuffer
for
i
:=
0
;
i
<
int
(
NbSpawn
);
i
++
{
...
...
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