ball

package
v0.0.0-...-da99c14 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BallList []*Ball

BallList is the global slice of balls

Functions

func Add

func Add(b *Ball) error

Add adds a ball to global list

func Boundary

func Boundary(b *Ball, minx, maxx, miny, maxy, factor float64) error

Boundary checks if ball should bounce within a rectangle (invert direction) Calculation based on collision with fixed surface Coefficent of restitution set by factor (if 1 elastic collision)

func Collide

func Collide(b1, b2 *Ball)

Collide updates balls based on collision to other balls Calculation based on elastic collision with equal mass

func Print

func Print(screen *ebiten.Image, b *Ball) error

Print a ball taking the radius into account

func Remove

func Remove(index int) error

Remove removes ball from global list Function does not keep order of balls

Types

type Ball

type Ball struct {
	Obj           *objects.Object
	Image         *ebiten.Image
	Radius, Scale float64
	Active        bool
}

Ball consist of an Object and image representation

func New

func New(x, y, vx, vy, scale float64, img *ebiten.Image) (*Ball, error)

New is a constructor for Ball struct

Jump to

Keyboard shortcuts

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