Better commenting throughout
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/atridad/LilGuy/internal/projectile"
|
||||
)
|
||||
|
||||
// Hero defaults
|
||||
const (
|
||||
defaultRadius = 24.0
|
||||
defaultSpeed = 200.0
|
||||
@@ -36,6 +37,8 @@ const (
|
||||
airFriction = 0.95
|
||||
)
|
||||
|
||||
// Input and bounds
|
||||
|
||||
type Input struct {
|
||||
Left bool
|
||||
Right bool
|
||||
@@ -64,6 +67,8 @@ const (
|
||||
DirRight
|
||||
)
|
||||
|
||||
// Hero state
|
||||
|
||||
type Hero struct {
|
||||
X float64
|
||||
Y float64
|
||||
@@ -155,6 +160,8 @@ func (h *Hero) Update(input Input, dt float64, bounds Bounds) {
|
||||
h.updateAnimation(dt)
|
||||
}
|
||||
|
||||
// Movement and physics
|
||||
|
||||
func (h *Hero) updateMovement(input Input, dt float64, bounds Bounds) {
|
||||
h.VelocityY += gravity * dt
|
||||
if h.VelocityY > maxFallSpeed {
|
||||
@@ -236,6 +243,8 @@ func (h *Hero) updateStamina(input Input, dt float64) {
|
||||
}
|
||||
}
|
||||
|
||||
// Animation
|
||||
|
||||
func (h *Hero) updateAnimation(dt float64) {
|
||||
isMoving := h.isMoving
|
||||
key := animationKey{direction: h.direction, state: animIdle}
|
||||
@@ -275,6 +284,8 @@ func (h *Hero) getVisualState() VisualState {
|
||||
return StateIdle
|
||||
}
|
||||
|
||||
// Rendering
|
||||
|
||||
func (h *Hero) Draw(screen *ebiten.Image) {
|
||||
sprite := h.getCurrentSprite()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user