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