Commit c2115dab authored by Léo TRANCHET's avatar Léo TRANCHET
Browse files

modification de la fonction de nettoyage

wq
:wq
wk
parent dd8f957e
......@@ -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 {
......
......@@ -27,6 +27,7 @@ func GenPart() (Particle) { // Crée une particule avec Px,Py comme position
ColorRed: rand.Float64(), ColorGreen: rand.Float64(), ColorBlue: rand.Float64(),
Opacity: 1,
SpeedX: (-1+rand.Float64()*2), SpeedY: (-1+rand.Float64()*2),
Overflow: false,
}
}
......
......@@ -20,4 +20,5 @@ type Particle struct {
Opacity float64
// Vitesse des particules sur leurs axe X,Y respectifs
SpeedX,SpeedY float64
Overflow bool
}
......@@ -9,10 +9,12 @@ import "project-particles/config"
// C'est à vous de développer cette fonction.
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{
tab[i] = tab[len(tab)-1]
i = i -1
tab = tab[:len(tab)-1]
if int(tab[i].PositionX) > config.General.WindowSizeX || int(tab[i].PositionX) < -10 || int(tab[i].PositionY) > config.General.WindowSizeY || int(tab[i].PositionY) < -10{
tab[i].Overflow = true
//tab[i] = tab[len(tab)-1]
//i = i -1
//tab = tab[:len(tab)-1]
}
}
return tab
......
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