automated snapshot
This commit is contained in:
39
main.go
39
main.go
@@ -150,7 +150,7 @@ type FieldLayer struct {
|
||||
}
|
||||
|
||||
func (s *FieldLayer) Update(ctx *RenderCtx) {
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
func (s *FieldLayer) Draw(ctx *RenderCtx) {
|
||||
@@ -171,30 +171,45 @@ func (s *FieldLayer) IsDirty() bool {
|
||||
type ContourLayer struct {
|
||||
field Field
|
||||
actors []*Actor
|
||||
rng *rand.Rand
|
||||
sourceWidth int
|
||||
sourceHeight int
|
||||
}
|
||||
|
||||
func NewContourLayer(rng *rand.Rand, field Field, sourceWidth int, sourceHeight int) ContourLayer {
|
||||
|
||||
actors := make([]*Actor, 20000)
|
||||
for i := range len(actors) {
|
||||
x := rng.Int() % sourceWidth
|
||||
y := rng.Int() % sourceHeight
|
||||
actors[i] =
|
||||
actors := make([]*Actor, 0)
|
||||
|
||||
layer := ContourLayer {
|
||||
rng: rng,
|
||||
field: field,
|
||||
actors: actors,
|
||||
sourceWidth: sourceWidth,
|
||||
sourceHeight: sourceHeight,
|
||||
}
|
||||
|
||||
layer.AddActors(1)
|
||||
|
||||
return layer
|
||||
}
|
||||
|
||||
func (s *ContourLayer) AddActors(n int) {
|
||||
for range n {
|
||||
x := s.rng.Int() % s.sourceWidth
|
||||
y := s.rng.Int() % s.sourceHeight
|
||||
newActor :=
|
||||
&Actor {
|
||||
position: rl.Vector2{X: float32(x), Y: float32(y)},
|
||||
field: field,
|
||||
field: s.field,
|
||||
stepSize: 1,
|
||||
color: rl.NewColor(11, 35, 176, 100),
|
||||
}
|
||||
}
|
||||
|
||||
return ContourLayer{
|
||||
actors: actors,
|
||||
s.actors = append(s.actors, newActor)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ContourLayer) Update(ctx *RenderCtx) {
|
||||
;
|
||||
s.AddActors(100) // parameterize
|
||||
}
|
||||
|
||||
func (s *ContourLayer) Draw(ctx *RenderCtx) {
|
||||
|
||||
Reference in New Issue
Block a user