44 lines
930 B
Go
44 lines
930 B
Go
package main
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
rl "github.com/gen2brain/raylib-go/raylib"
|
|
)
|
|
|
|
type paint struct {
|
|
time float32
|
|
location rl.Vector2
|
|
}
|
|
|
|
func drawPaint() {
|
|
if debug {
|
|
t := strconv.Itoa(len(paints))
|
|
rl.DrawText(t, 10, 10, 40, rl.Black)
|
|
}
|
|
for index, paintI := range paints {
|
|
if len(paints) <= index {
|
|
continue
|
|
}
|
|
|
|
if paintI.time > 1 {
|
|
paints[index] = paint{time: paintI.time - 1, location: paintI.location}
|
|
rl.DrawRectangleV(rl.Vector2Subtract(paintI.location, cameraPos), rl.Vector2{X: ballRadius - 2, Y: ballRadius - 2}, rl.NewColor(ballColor.R, ballColor.G, ballColor.B, uint8(paintI.time)))
|
|
continue
|
|
}
|
|
paints = removePaint(paints, index)
|
|
}
|
|
}
|
|
|
|
func draw() {
|
|
paintedPaint := paint{255, ballPos}
|
|
paints = append(paints, paintedPaint)
|
|
}
|
|
|
|
func removePaint(slice []paint, index int) []paint {
|
|
if len(slice) <= 2 {
|
|
return make([]paint, 0)
|
|
}
|
|
return append(slice[:index], slice[index+1:]...)
|
|
}
|