Commit 3b0b54ac authored by Rennarde's avatar Rennarde
Browse files

Add transparency

parent 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
......@@ -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
......@@ -20,6 +20,8 @@ type Config struct {
Colors []float64
Gravity, GravityCenter bool
NumCycle int
LifeOpt string
Death bool
}
var General Config
......@@ -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")
},
},
}
......
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) < 100 || 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++ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment