topdown

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: Unlicense Imports: 3 Imported by: 0

README

topdown

Top-down 2D Game Engine made in Go with Ebiten

Documentation

Index

Constants

View Source
const PointSchemaStr = `` /* 359-byte string literal not displayed */

PointSchemaStr is the JSON schema for a point.

View Source
const SizeSchemaStr = `` /* 392-byte string literal not displayed */

SizeSchemaStr is the JSON schema for a size.

View Source
const VectorSchemaStr = `` /* 325-byte string literal not displayed */

VectorSchemaStr is the JSON schema for a vector.

Variables

This section is empty.

Functions

This section is empty.

Types

type Number added in v0.2.0

type Number interface {
	constraints.Float | constraints.Integer
}

Number constrains type to float or integer.

type Point added in v0.2.0

type Point[T Number] struct {
	X T `json:"x"`
	Y T `json:"y"`
}

Point is a 2D point.

func ParseIntPoint added in v0.3.0

func ParseIntPoint(s string) (Point[int], error)

func Pt added in v0.2.0

func Pt[T Number](x, y T) Point[T]

Pt makes a new point.

func (Point[T]) Add added in v0.2.0

func (p Point[T]) Add(other Point[T]) Point[T]

Add makes a new point by adding the given and current points.

func (Point[T]) Equal added in v0.2.0

func (p Point[T]) Equal(other Point[T]) bool

Equal checks for equal X and Y values.

func (Point[T]) In added in v0.2.0

func (p Point[T]) In(r Rectangle[T]) bool

In checks if the current point is in the given rectangle.

func (Point[T]) String added in v0.2.0

func (p Point[T]) String() string

String makes a string representing the point.

func (Point[T]) Sub added in v0.2.0

func (p Point[T]) Sub(other Point[T]) Point[T]

Add makes a new point by subtracting the given point from the current point.

type Rectangle added in v0.2.0

type Rectangle[T Number] struct {
	Min, Max Point[T]
}

Rectangle is a generic version of image.Rectangle.

func Rect added in v0.2.0

func Rect[T Number](x0, y0, x1, y1 T) Rectangle[T]

func (Rectangle[T]) Add added in v0.2.0

func (r Rectangle[T]) Add(p Point[T]) Rectangle[T]

Add returns the rectangle r translated by p.

func (Rectangle[T]) Canon added in v0.2.0

func (r Rectangle[T]) Canon() Rectangle[T]

Canon returns the canonical version of r. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.

func (Rectangle[T]) Center added in v0.5.0

func (r Rectangle[T]) Center() Point[T]

Size returns the rectangle center point.

func (Rectangle[T]) Dx added in v0.2.0

func (r Rectangle[T]) Dx() T

Dx returns r's width.

func (Rectangle[T]) Dy added in v0.2.0

func (r Rectangle[T]) Dy() T

Dy returns r's height.

func (Rectangle[T]) Empty added in v0.2.0

func (r Rectangle[T]) Empty() bool

Empty reports whether the rectangle contains no points.

func (Rectangle[T]) Eq added in v0.2.0

func (r Rectangle[T]) Eq(s Rectangle[T]) bool

Eq reports whether r and s contain the same set of points. All empty rectangles are considered equal.

func (Rectangle[T]) In added in v0.2.0

func (r Rectangle[T]) In(s Rectangle[T]) bool

In reports whether every point in r is in s.

func (Rectangle[T]) Inset added in v0.2.0

func (r Rectangle[T]) Inset(n T) Rectangle[T]

Inset returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than 2*n then an empty rectangle near the center of r will be returned.

func (Rectangle[T]) Intersect added in v0.2.0

func (r Rectangle[T]) Intersect(s Rectangle[T]) Rectangle[T]

Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.

func (Rectangle[T]) Overlaps added in v0.2.0

func (r Rectangle[T]) Overlaps(s Rectangle[T]) bool

Overlaps reports whether r and s have a non-empty intersection.

func (Rectangle[T]) Size added in v0.2.0

func (r Rectangle[T]) Size() Size[T]

Size returns r's width and height.

func (Rectangle[T]) String added in v0.2.0

func (r Rectangle[T]) String() string

String returns a string representation of r like "(3,4)-(6,5)".

func (Rectangle[T]) Sub added in v0.2.0

func (r Rectangle[T]) Sub(p Point[T]) Rectangle[T]

Sub returns the rectangle r translated by -p.

func (Rectangle[T]) Union added in v0.2.0

func (r Rectangle[T]) Union(s Rectangle[T]) Rectangle[T]

Union returns the smallest rectangle that contains both r and s.

type Size

type Size[T Number] struct {
	Width  T `json:"w"`
	Height T `json:"h"`
}

Size is a 2D size.

func Sz added in v0.2.0

func Sz[T Number](w, h T) Size[T]

Sz makes a new size.

func (Size[T]) Center added in v0.2.0

func (s Size[T]) Center() Point[T]

Center makes a point that would be at the center of a rectangle with the current size, starting at (0,0).

func (Size[T]) Equal added in v0.2.0

func (s Size[T]) Equal(other Size[T]) bool

Equal checks for equal width and height values.

func (Size[T]) String added in v0.2.0

func (s Size[T]) String() string

String makes a string representing the size.

type Vector

type Vector struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Vector is a 2D vector.

func Vec added in v0.2.0

func Vec(x, y float64) Vector

Vec makes a new vector value.

func (Vector) Add

func (v Vector) Add(w Vector) Vector

Add makes a new vector with the vectors added.

func (Vector) AsPoint added in v0.2.0

func (v Vector) AsPoint() Point[float64]

AsPoint make a point from the vector.

func (Vector) Equal

func (v Vector) Equal(w Vector) bool

Equal checks for equal X and Y values.

func (Vector) Magnitude

func (v Vector) Magnitude() float64

Magnitude returns the vector magnitude.

func (Vector) Multiply

func (v Vector) Multiply(scale float64) Vector

Multiply makes a new vector with scaled X and Y.

func (Vector) Pair

func (v Vector) Pair() (float64, float64)

Pair gets the vector X-Y pair.

func (Vector) Resize

func (v Vector) Resize(newMag float64) Vector

Resize makes a new vector resized to the given magnitude.

func (Vector) Unit

func (v Vector) Unit() Vector

Unit makes a new vector resized to a magnitude of 1.

func (Vector) Zero

func (v Vector) Zero() bool

Zero returns true if X and Y are 0.

Directories

Path Synopsis
mock_animation
Package mock_animation is a generated GoMock package.
Package mock_animation is a generated GoMock package.
mock_control
Package mock_control is a generated GoMock package.
Package mock_control is a generated GoMock package.
mock_drawing
Package mock_drawing is a generated GoMock package.
Package mock_drawing is a generated GoMock package.
mock_engine
Package mock_engine is a generated GoMock package.
Package mock_engine is a generated GoMock package.
examples
mock_fileindex
Package mock_fileindex is a generated GoMock package.
Package mock_fileindex is a generated GoMock package.
mock_movecollide
Package mock_movecollide is a generated GoMock package.
Package mock_movecollide is a generated GoMock package.
mock_resource
Package mock_resource is a generated GoMock package.
Package mock_resource is a generated GoMock package.

Jump to

Keyboard shortcuts

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