yasamsim

package
v0.0.0-...-a481a7d Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2018 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Assets struct {
	Sounds map[string][]byte
	Images map[string][]byte
}
View Source
var (
	Images map[string]*ebiten.Image
)

Functions

func EuclideanCollision

func EuclideanCollision(ax, ay, bx, by, l float64) bool

func LevelMapToPlayerStageCoordinate

func LevelMapToPlayerStageCoordinate(level string) (stageX, stageY stageCoordinate, err error)

func NewGame

func NewGame() *game

func NewRange

func NewRange(small, large float64) float64Range

NewRange creates a float64Range out of two float64. It doesn't care about order, as it figures out which of the provided values is small and which is large for you.

Fun fact: floats sounds like פלוץ.

func RectangleCollision

func RectangleCollision(a, b RectangleLocationGetter) bool

Types

type Crate

type Crate struct {
	// contains filtered or unexported fields
}

func (Crate) DX

func (v Crate) DX() float64

func (Crate) DY

func (v Crate) DY() float64

func (Crate) DZ

func (v Crate) DZ() float64

func (Crate) Draw

func (c Crate) Draw(screen *ebiten.Image) error

func (*Crate) HandleInput

func (c *Crate) HandleInput(g *game)

func (Crate) Height

func (c Crate) Height() int

func (Crate) HorizontalRange

func (s Crate) HorizontalRange() float64Range

func (Crate) LeftSide

func (s Crate) LeftSide() float64

func (Crate) LowerSide

func (s Crate) LowerSide() float64

func (Crate) RectangleCollision

func (p Crate) RectangleCollision(e RectangleLocationGetter) bool

RectangleCollision checks if the calling Projectile and the provided Entity overlap in their rectangles.

LowX
|   HighX
|   |
+---+..    ..+---+ -- LowY
|p..|..    ..|..p|
|.+---+    +---+.|
|.|.|.|    |.|.|.|
+-|-+.|    |.+-|-+ -- HighY
..|..e|    |e..|..
..+---+    +---+..

..+---+    +---+..
..|...|    |...|..
+-|-+.|    |.+-|-+
|.|.|.|    |.|.|.|
|.+---+    +---+.|
|...|..    ..|...|
+---+..    ..+---+

func (Crate) RightSide

func (s Crate) RightSide() float64

func (Crate) SetDX

func (v Crate) SetDX(dx float64)

func (Crate) SetDY

func (v Crate) SetDY(dy float64)

func (Crate) SetDZ

func (v Crate) SetDZ(dz float64)

func (*Crate) SetLeftSide

func (l *Crate) SetLeftSide(x float64)

func (*Crate) SetLowerSide

func (l *Crate) SetLowerSide(y float64)

func (*Crate) SetRightSide

func (l *Crate) SetRightSide(x float64)

func (*Crate) SetToBeDestroyed

func (d *Crate) SetToBeDestroyed()

func (*Crate) SetUpperSide

func (l *Crate) SetUpperSide(y float64)

func (*Crate) SetX

func (l *Crate) SetX(x float64)

func (*Crate) SetY

func (l *Crate) SetY(y float64)

func (*Crate) Step

func (c *Crate) Step(g *game)

func (Crate) ToBeDestroyed

func (d Crate) ToBeDestroyed() bool

func (Crate) UpperSide

func (s Crate) UpperSide() float64

func (Crate) VerticalRange

func (s Crate) VerticalRange() float64Range

func (Crate) Width

func (c Crate) Width() int

func (Crate) X

func (s Crate) X() float64

func (Crate) Y

func (s Crate) Y() float64

type Destroyabler

type Destroyabler interface {
	ToBeDestroyed() bool
	SetToBeDestroyed()
}

type Drawer

type Drawer interface {
	Draw(*ebiten.Image) error
	SortKey() float64
}

type Entities

type Entities []Entity

func (Entities) FilterDestroyed

func (es Entities) FilterDestroyed() Entities

func (Entities) Len

func (es Entities) Len() int

func (Entities) Less

func (es Entities) Less(i, j int) bool

func (Entities) Step

func (es Entities) Step(g *game)

func (Entities) Swap

func (es Entities) Swap(i, j int)

type GameState

type GameState interface {
	HandleInput()
	Step()
	Draw(screen *ebiten.Image) error
}

type Kharedi

type Kharedi struct {
	// contains filtered or unexported fields
}

func (Kharedi) Draw

func (k Kharedi) Draw(screen *ebiten.Image) error

func (*Kharedi) Fall

func (c *Kharedi) Fall()

func (Kharedi) FindBlockings

func (c Kharedi) FindBlockings(ss []RectangleLocationGetter) (
	blockedOnRight,
	blockedOnUp,
	blockedOnLeft,
	blockedOnDown bool,
)

func (*Kharedi) HandleInput

func (c *Kharedi) HandleInput(g *game)

func (Kharedi) Height

func (s Kharedi) Height() int

func (*Kharedi) SetToBeDestroyed

func (d *Kharedi) SetToBeDestroyed()

func (*Kharedi) Step

func (k *Kharedi) Step(g *game)

func (Kharedi) ToBeDestroyed

func (d Kharedi) ToBeDestroyed() bool

func (Kharedi) Width

func (s Kharedi) Width() int

type LocationGetter

type LocationGetter interface {
	X() float64
	Y() float64
	Z() float64
}

type LocationSetter

type LocationSetter interface {
	SetX(float64)
	SetY(float64)
	SetZ(float64)
}

type Player

type Player struct {
	// contains filtered or unexported fields
}

func (Player) Draw

func (c Player) Draw(screen *ebiten.Image) error

func (*Player) Fall

func (c *Player) Fall()

func (Player) FindBlockings

func (c Player) FindBlockings(ss []RectangleLocationGetter) (
	blockedOnRight,
	blockedOnUp,
	blockedOnLeft,
	blockedOnDown bool,
)

func (*Player) HandleInput

func (c *Player) HandleInput(g *game)

func (*Player) SetToBeDestroyed

func (d *Player) SetToBeDestroyed()

func (*Player) Step

func (c *Player) Step(g *game)

func (Player) ToBeDestroyed

func (d Player) ToBeDestroyed() bool

type Projectile

type Projectile struct {
	// contains filtered or unexported fields
}

func (Projectile) DX

func (v Projectile) DX() float64

func (Projectile) DY

func (v Projectile) DY() float64

func (Projectile) DZ

func (v Projectile) DZ() float64

func (Projectile) Draw

func (p Projectile) Draw(screen *ebiten.Image) error

func (Projectile) HandleInput

func (p Projectile) HandleInput(g *game)

func (Projectile) Height

func (p Projectile) Height() float64

func (Projectile) HorizontalRange

func (s Projectile) HorizontalRange() float64Range

func (Projectile) IsProjectile

func (p Projectile) IsProjectile() bool
func CircleCollision(ax, ay, bx, by, tresholdDistance float64) bool {
	distanceBetweenPoints := math.Sqrt(math.Pow(ax-bx, 2) + math.Pow(ay-by, 2))
	if distanceBetweenPoints <= tresholdDistance {
		return true
	}
	return false
}

func (Projectile) LeftSide

func (s Projectile) LeftSide() float64

func (Projectile) LowerSide

func (s Projectile) LowerSide() float64

func (Projectile) RectangleCollision

func (p Projectile) RectangleCollision(e RectangleLocationGetter) bool

RectangleCollision checks if the calling Projectile and the provided Entity overlap in their rectangles.

LowX
|   HighX
|   |
+---+..    ..+---+ -- LowY
|p..|..    ..|..p|
|.+---+    +---+.|
|.|.|.|    |.|.|.|
+-|-+.|    |.+-|-+ -- HighY
..|..e|    |e..|..
..+---+    +---+..

..+---+    +---+..
..|...|    |...|..
+-|-+.|    |.+-|-+
|.|.|.|    |.|.|.|
|.+---+    +---+.|
|...|..    ..|...|
+---+..    ..+---+

func (Projectile) RightSide

func (s Projectile) RightSide() float64

func (Projectile) SetDX

func (v Projectile) SetDX(dx float64)

func (Projectile) SetDY

func (v Projectile) SetDY(dy float64)

func (Projectile) SetDZ

func (v Projectile) SetDZ(dz float64)

func (*Projectile) SetLeftSide

func (l *Projectile) SetLeftSide(x float64)

func (*Projectile) SetLowerSide

func (l *Projectile) SetLowerSide(y float64)

func (*Projectile) SetRightSide

func (l *Projectile) SetRightSide(x float64)

func (*Projectile) SetToBeDestroyed

func (d *Projectile) SetToBeDestroyed()

func (*Projectile) SetUpperSide

func (l *Projectile) SetUpperSide(y float64)

func (*Projectile) SetX

func (l *Projectile) SetX(x float64)

func (*Projectile) SetY

func (l *Projectile) SetY(y float64)

func (*Projectile) Step

func (p *Projectile) Step(g *game)

func (Projectile) ToBeDestroyed

func (d Projectile) ToBeDestroyed() bool

func (Projectile) UpperSide

func (s Projectile) UpperSide() float64

func (Projectile) VerticalRange

func (s Projectile) VerticalRange() float64Range

func (Projectile) Width

func (p Projectile) Width() float64

func (Projectile) X

func (s Projectile) X() float64

func (Projectile) Y

func (s Projectile) Y() float64

type Projectiler

type Projectiler interface {
	IsProjectile() bool
}

type RectangleLocationGetter

type RectangleLocationGetter interface {
	X() float64
	Y() float64

	UpperSide() float64
	LowerSide() float64
	LeftSide() float64
	RightSide() float64

	VerticalRange() float64Range
	HorizontalRange() float64Range
}

type RectangleLocationSetter

type RectangleLocationSetter interface {
	SetUpperSide(float64)
	SetLowerSide(float64)
	SetLeftSide(float64)
	SetRightSide(float64)

	SetX(float64)
	SetY(float64)
}

type RectangleMover

type RectangleMover interface {
	RectangleLocationGetter
	VelocityGetter
}

type Sprite

type Sprite interface {
	Image() *ebiten.Image
	Width() int
	Height() int
}

type VelocityGetter

type VelocityGetter interface {
	DX() float64
	DY() float64
	DZ() float64
}

type VelocitySetter

type VelocitySetter interface {
	SetDX(float64)
	SetDY(float64)
	SetDZ(float64)
}

type Wall

type Wall struct {
	// contains filtered or unexported fields
}

func LevelMapToWalls

func LevelMapToWalls(level string) []Wall

func (Wall) Draw

func (p Wall) Draw(screen *ebiten.Image) error

func (Wall) HorizontalRange

func (s Wall) HorizontalRange() float64Range

func (Wall) LeftSide

func (s Wall) LeftSide() float64

func (Wall) LowerSide

func (s Wall) LowerSide() float64

func (Wall) RectangleCollision

func (p Wall) RectangleCollision(e RectangleLocationGetter) bool

RectangleCollision checks if the calling Projectile and the provided Entity overlap in their rectangles.

LowX
|   HighX
|   |
+---+..    ..+---+ -- LowY
|p..|..    ..|..p|
|.+---+    +---+.|
|.|.|.|    |.|.|.|
+-|-+.|    |.+-|-+ -- HighY
..|..e|    |e..|..
..+---+    +---+..

..+---+    +---+..
..|...|    |...|..
+-|-+.|    |.+-|-+
|.|.|.|    |.|.|.|
|.+---+    +---+.|
|...|..    ..|...|
+---+..    ..+---+

func (Wall) RightSide

func (s Wall) RightSide() float64

func (*Wall) SetLeftSide

func (l *Wall) SetLeftSide(x float64)

func (*Wall) SetLowerSide

func (l *Wall) SetLowerSide(y float64)

func (*Wall) SetRightSide

func (l *Wall) SetRightSide(x float64)

func (*Wall) SetUpperSide

func (l *Wall) SetUpperSide(y float64)

func (*Wall) SetX

func (l *Wall) SetX(x float64)

func (*Wall) SetY

func (l *Wall) SetY(y float64)

func (*Wall) Step

func (p *Wall) Step(g *game)

func (Wall) UpperSide

func (s Wall) UpperSide() float64

func (Wall) VerticalRange

func (s Wall) VerticalRange() float64Range

func (Wall) X

func (s Wall) X() float64

func (Wall) Y

func (s Wall) Y() float64

Jump to

Keyboard shortcuts

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