boid

package
v0.0.0-...-91211bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Teleport

func Teleport(pos, edge float64) float64

Teleport places point on opposite end of the screen when offscreen.

Types

type Arrow

type Arrow struct {
	ImageWidth  int
	ImageHeight int
	SightDis    float64
	SightAngle  float64
	Pos         *v.Vector2D
	Vel         *v.Vector2D
	Accel       *v.Vector2D
	Image       *ebiten.Image
}

func (*Arrow) Apply

func (a *Arrow) Apply(newPos, newVel *v.Vector2D)

func (*Arrow) Coords

func (a *Arrow) Coords() v.Vector2D

func (*Arrow) Draw

func (a *Arrow) Draw(screen *ebiten.Image)

func (*Arrow) Update

func (a *Arrow) Update(sx, sy float64, population []Boid, index int, info chan *Data)

func (*Arrow) Velocity

func (a *Arrow) Velocity() v.Vector2D

type Boid

type Boid interface {
	Update(float64, float64, []Boid, int, chan *Data)
	Draw(*ebiten.Image)
	Coords() v.Vector2D
	Velocity() v.Vector2D
	Apply(*v.Vector2D, *v.Vector2D)
}

type Data

type Data struct {
	Index  int
	NewPos *v.Vector2D
	NewVel *v.Vector2D
}

type Square

type Square struct {
	ImageWidth  int
	ImageHeight int
	SightDis    int
	Pos         *v.Vector2D
	Vel         *v.Vector2D
	Accel       *v.Vector2D
}

func (*Square) Coords

func (s *Square) Coords() v.Vector2D

func (*Square) Draw

func (s *Square) Draw(screen *ebiten.Image)

func (*Square) Update

func (s *Square) Update(sx, sy float64, population []Boid)

func (*Square) Velocity

func (s *Square) Velocity() v.Vector2D

type Triangle

type Triangle struct {
	ImageWidth  int
	ImageHeight int
	SightAngle  float64
	SightDis    int         // Distance that boid can see in front of it
	Theta       float64     // Angle that the Velocity vectors create.
	VelTheta    float64     // Angle that the Acceleration vectors create.
	Top         *v.Vector2D // Vertex of the initial top point
	Left        *v.Vector2D // Vertex of the initial left point
	Right       *v.Vector2D // Vertex of the initial right point
	Vel         *v.Vector2D
	Accel       *v.Vector2D
}

Triangle is an image object for the game screen. It satisfies the boid interface.

func (*Triangle) Add

func (t *Triangle) Add(vector v.Vector2D, points ...*v.Vector2D)

func (*Triangle) Apply

func (t *Triangle) Apply(*v.Vector2D, *v.Vector2D)

func (*Triangle) Coords

func (t *Triangle) Coords() v.Vector2D

func (*Triangle) Draw

func (t *Triangle) Draw(screen *ebiten.Image)

func (*Triangle) TrianglePointsMake

func (t *Triangle) TrianglePointsMake(x, y float64)

TrianglePointsMake uses (x, y) as coordinates of the top. Finds the Right and Left Point using ImageWidth, ImageHeight, and (x, y).

func (*Triangle) Update

func (t *Triangle) Update(sx, sy float64, population []Boid, index int, info chan *Data)

Update gives new values to the vertices and velocity vectors.

func (*Triangle) Velocity

func (t *Triangle) Velocity() v.Vector2D

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL