game_math

package
v0.0.0-...-71ffa5d Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollisionReactionBallBall

func CollisionReactionBallBall(collider1, collider2 collider, weight1, weight2, pf1, pf2, x2, y2 float64)

func Cos

func Cos(radian float64) float64

Cos(x) = 1 - x^2 / 2! + x^4 / 4! - x^6 / 6! To infinity...

func DegToRadian

func DegToRadian(angle float64) float64

func Factorial

func Factorial(n float64) float64

func GetAnchorWeapon

func GetAnchorWeapon(weaponXAttach, weaponYAttach, slotXAttach, slotYAttach int) (float64, float64, int, int)

func GetBetweenAngle

func GetBetweenAngle(x, y, targetX, targetY float64) float64

func GetBetweenDist

func GetBetweenDist(fromX, fromY, toX, toY int) float64

func GetBetweenDistFloat

func GetBetweenDistFloat(fromX, fromY, toX, toY float64) float64

func GetMaxDistBallisticWeapon

func GetMaxDistBallisticWeapon(speed, targetLvl, startLvlBullet, radian float64, weaponType string, g float64) float64

func GetRangeRand

func GetRangeRand(min, max int) int

func GetReachAngle

func GetReachAngle(xPlace, yPlace, xTarget, yTarget int, targetLvl, startLvlBullet, speed float64, artillery bool, weaponType string, g float64) float64

func GetWeaponFirePosition

func GetWeaponFirePosition(ownerX, ownerY, ownerScale int, ownerRotate float64, gunRotate float64, weaponXAttach, weaponYAttach int,
	weaponFirePositions []*coordinate.Coordinate, slotXAttach, slotYAttach float64, firePosition int) *position.Positions

func GetWeaponFirePositions

func GetWeaponFirePositions(ownerX, ownerY, ownerScale int, ownerRotate float64, gunRotate float64, weaponXAttach, weaponYAttach int,
	weaponFirePositions []*coordinate.Coordinate, slotXAttach, slotYAttach float64) []*position.Positions

func GetWeaponPosInMap

func GetWeaponPosInMap(ownerX, ownerY, ownerScale int, slotXAttach, slotYAttach, rotate float64) (int, int)

func GetWeaponSlotAttachPoint

func GetWeaponSlotAttachPoint(slotXAttach, slotYAttach, rotate float64, ownerScale int) (float64, float64)

func GetZBulletByX

func GetZBulletByX(startZ, startRadian, x, speed float64, weaponType string, gravity float64) float64

func GetZBulletByXPath

func GetZBulletByXPath(startZ, startRadian, speed float64, startX, startY, currentX, currentY int, ammoType string, gravity float64) float64

func IntersectVectorToCircle

func IntersectVectorToCircle(a, b, centerCircle *Point, radius int) (intersect bool, x1, y1, x2, y2 float64)

func PointInVector

func PointInVector(a, b *Point, x, y float64) bool

func PrepareAngle

func PrepareAngle(angle *float64)

func RadianToDeg

func RadianToDeg(radian float64) float64

func Rotate

func Rotate(unitRotate, needRotate *float64, step float64) float64

func RotatePoint

func RotatePoint(x, y, x0, y0, rotate float64) (newX, newY float64)

func ShortestBetweenAngle

func ShortestBetweenAngle(angle1, angle2 float64) int

func Sin

func Sin(radian float64) float64

Sin(x) = x - x^3 / 3! + x^5 / 5! - x^7/7! To infinity...

func SpeedAndAngleToVelocity

func SpeedAndAngleToVelocity(speed float64, radian float64) (float64, float64)

func VectorToAngleBySpeed

func VectorToAngleBySpeed(x1, y1, speed, angle float64) (int, int)

Types

type Point

type Point struct {
	X float64
	Y float64
}

func VectorSub

func VectorSub(p1, p2 *Point) *Point

type Polygon

type Polygon struct {
	RotateSides []*SideRec `json:"-"`

	CenterX, CenterY float64
	Angle            float64
	// contains filtered or unexported fields
}

func GetCenterRect

func GetCenterRect(x, y, height, width float64) *Polygon

func GetRect

func GetRect(x, y, height, width float64) *Polygon

func (*Polygon) DetectCollisionRectToCircle

func (r *Polygon) DetectCollisionRectToCircle(centerCircle *Point, radius int) bool

func (*Polygon) DetectCollisionRectToRect

func (r *Polygon) DetectCollisionRectToRect(r2 *Polygon) bool

func (*Polygon) DetectPointInRectangle

func (r *Polygon) DetectPointInRectangle(x, y float64) bool

func (*Polygon) GetAngle

func (r *Polygon) GetAngle() float64

func (*Polygon) GetCenter

func (r *Polygon) GetCenter() (float64, float64)

func (*Polygon) GetRotateSides

func (r *Polygon) GetRotateSides() []*SideRec

func (*Polygon) Rotate

func (r *Polygon) Rotate(rotate float64)

func (*Polygon) UpdateCenterRect

func (r *Polygon) UpdateCenterRect(x, y, height, width float64) *Polygon

type SideRec

type SideRec struct {
	XY1 *Point `json:"xy_1"`
	XY2 *Point `json:"xy_2"`
}

type Vector

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

func (*Vector) Add

func (v *Vector) Add(vec *Vector) *Vector

func (*Vector) Copy

func (v *Vector) Copy() *Vector

func (*Vector) Len

func (v *Vector) Len() float64

func (*Vector) LenSqrt

func (v *Vector) LenSqrt() float64

func (*Vector) Norm

func (v *Vector) Norm() *Vector

func (*Vector) Resize

func (v *Vector) Resize(len float64) *Vector

func (*Vector) Scale

func (v *Vector) Scale(fac float64) *Vector

func (*Vector) Sub

func (v *Vector) Sub(vec *Vector) *Vector

func (*Vector) VecTo

func (v *Vector) VecTo(vec *Vector) *Vector

Jump to

Keyboard shortcuts

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