Documentation ¶
Index ¶
- Constants
- type AgentRegister
- type AgentUnregister
- type Block
- type Physic
- type PhysicBody
- func (pb *PhysicBody) Dimension() Block
- func (pb *PhysicBody) Draw(screen *ebiten.Image)
- func (pb *PhysicBody) DrawBodyBoundaryBox(screen *ebiten.Image)
- func (pb *PhysicBody) Explode()
- func (pb *PhysicBody) ID() string
- func (pb *PhysicBody) Init()
- func (pb *PhysicBody) Intersect(p Physic) bool
- func (pb *PhysicBody) IntersectMultiple(physics map[string]Physic) (string, bool)
- func (pb *PhysicBody) Rotate(rotationAngle float64)
- func (pb *PhysicBody) String() string
- func (pb *PhysicBody) Type() string
- func (pb *PhysicBody) Update()
- func (pb *PhysicBody) UpdateAcceleration(i float64)
- type Position
- type Size
- type Vector
Constants ¶
const ( StarshipAgent string = "starship" AsteroidAgent string = "asteroid" RubbleAgent string = "rubble" BulletAgent string = "bullet" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentRegister ¶
type AgentRegister func(Physic)
AgentRegister is a function to register an agent
type AgentUnregister ¶
AgentUnregister is a function to unregister an agent
type Physic ¶
type Physic interface { // Draw draws the agent on screen. Draw(*ebiten.Image) // Update proceeds the agent state. Update() // Init initializes the physic body. Init() // ID displays physic body unique ID. ID() string // String displays physic body information as a string. String() string // Intersect returns true if the physical body collide another one. // Collision is computed based on Axis-Aligned Bounding Boxes. // https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection Intersect(Physic) bool // IntersectMultiple checks if multiple physical bodies are colliding with the first IntersectMultiple(map[string]Physic) (string, bool) // Dimensions returns physical body dimensions. Dimension() Block // Type returns physical body agent type as a string. Type() string // Explode proceeds the agent explosion and termination. Explode() }
type PhysicBody ¶
type PhysicBody struct { Position AgentType string Log *logrus.Logger Orientation float64 // theta (radian) Size float64 PhysicWidth float64 PhysicHeight float64 ScreenWidth float64 ScreenHeight float64 Velocity Vector Acceleration Vector Register AgentRegister Unregister AgentUnregister Image *ebiten.Image Debug bool // contains filtered or unexported fields }
func (*PhysicBody) Dimension ¶
func (pb *PhysicBody) Dimension() Block
Dimensions returns physical body dimensions.
func (*PhysicBody) Draw ¶
func (pb *PhysicBody) Draw(screen *ebiten.Image)
Draw draws the agent. Draw is called every frame (typically 1/60[s] for 60Hz display).
func (*PhysicBody) DrawBodyBoundaryBox ¶
func (pb *PhysicBody) DrawBodyBoundaryBox(screen *ebiten.Image)
func (*PhysicBody) Explode ¶
func (pb *PhysicBody) Explode()
Explode proceeds the agent explosion and termination.
func (*PhysicBody) Intersect ¶
func (pb *PhysicBody) Intersect(p Physic) bool
Intersect returns true if the physical body collide another one. Collision is computed based on Axis-Aligned Bounding Boxes. https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection
func (*PhysicBody) IntersectMultiple ¶
func (pb *PhysicBody) IntersectMultiple(physics map[string]Physic) (string, bool)
IntersectMultiple checks if multiple physical bodies are colliding with the first
func (*PhysicBody) Rotate ¶
func (pb *PhysicBody) Rotate(rotationAngle float64)
func (*PhysicBody) String ¶
func (pb *PhysicBody) String() string
String displays physic body information as a string.
func (*PhysicBody) Type ¶
func (pb *PhysicBody) Type() string
Type returns physical body agent type as a string.
func (*PhysicBody) Update ¶
func (pb *PhysicBody) Update()
Update proceeds the game state. Update is called every tick (1/60 [s] by default).
func (*PhysicBody) UpdateAcceleration ¶
func (pb *PhysicBody) UpdateAcceleration(i float64)