Documentation ¶
Index ¶
- Constants
- type Field
- type Food
- type Goal
- type LaneType
- type Lanes
- type MovableObject
- type Obstacle
- type Onigiri
- type Parts
- type PrairieField
- func (p *PrairieField) AttackObstacles(hr *view.HitRectangle, power float64) (int, int)
- func (p *PrairieField) DrawCloser(screen *ebiten.Image)
- func (p *PrairieField) DrawFarther(screen *ebiten.Image)
- func (p *PrairieField) EatFoods(hr *view.HitRectangle) int
- func (p *PrairieField) Initialize(lanes *Lanes, goalX float64)
- func (p *PrairieField) IsCollidedWithObstacles(hr *view.HitRectangle) bool
- func (p *PrairieField) Update(scrollV *view.Vector)
- type Rock
- func (r *Rock) Attack(damage float64)
- func (r *Rock) Draw(screen *ebiten.Image)
- func (r *Rock) Initialize(img *ebiten.Image, pos *view.Vector, kv float64)
- func (r *Rock) IsBroken() bool
- func (r *Rock) IsCollided(rect *view.HitRectangle) bool
- func (r *Rock) SetHardness(hardness float64)
- func (r *Rock) Update(scrollV *view.Vector)
- type ScrollInfo
- type ScrollableObject
- type SingleLane
Constants ¶
const (
// FieldOffset is the offset to make it look like it's on the lane.
FieldOffset = 1.8
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field interface { // Initialize initializes the all of field parts. Initialize(lanes *Lanes, goalX float64) // Update updates the all field parts position with the scroll velocity. Update(scroll *view.Vector) // DrawFarther draws the field parts farther than the player from the user's point of view. DrawFarther(screen *ebiten.Image) // DrawCloser draws the field parts closer than the player from the user's point of view. DrawCloser(screen *ebiten.Image) // IsCollidedWithObstacles returns whether the r is collided with this item. IsCollidedWithObstacles(hr *view.HitRectangle) bool // EatFoods determines if there is a conflict between the player and the food. // If it hits, it returns the stamina gained. EatFoods(hr *view.HitRectangle) int // AttackObstacles attacks obstacles. // If any obstacle is collided or broken, returns the number of collided or broken obstacles. AttackObstacles(hr *view.HitRectangle, power float64) (int, int) }
Field is the interface to draw the field.
type Food ¶ added in v0.0.4
type Food interface { // IsCollided returns whether this obstacle is collided the arg. IsCollided(*view.HitRectangle) bool // Eat eats this food. This func reteruns the value to restore character's stamina. Eat() int }
Food is the interface for filed food item. The character can eat them and restore stamina.
type Goal ¶ added in v0.0.5
type Goal struct {
// contains filtered or unexported fields
}
func (*Goal) Initialize ¶ added in v0.0.5
Initialize initializes the object.
args: bkimg: the image to be drawn at the back of the character. frimg: the image to be drawn at the front of the character. pos: the initial position vel: the velocity to move this object
type Lanes ¶ added in v0.0.5
type Lanes struct {
// contains filtered or unexported fields
}
Lanes not only updates and draws multiple SingleLane objects, but also manages the height of the lane that the character is currently aiming for.
func (*Lanes) GetLaneHeights ¶ added in v0.0.5
func (*Lanes) GetTargetLaneHeight ¶ added in v0.0.5
func (*Lanes) GoToLowerLane ¶ added in v0.0.5
GoToLowerLane sets the lower lane as the destination and returns true if the destination lane exists, false if not.
func (*Lanes) GoToUpperLane ¶ added in v0.0.5
GoToUpperLane sets the upper lane as the destination and returns true if the destination lane exists, false if not.
type MovableObject ¶ added in v0.0.5
type Obstacle ¶ added in v0.0.4
type Obstacle interface { // SetHardness sets the hardness of this obstacle. SetHardness(hardness float64) // Attack attacks this obstacle. // The damage value reduces this obstacle's hardness. Attack(damage float64) // IsBroken returns whether this obstacle was broken. // The broken state means that the hardness is 0 or less. IsBroken() bool // IsCollided returns whether this obstacle is collided the arg. IsCollided(hr *view.HitRectangle) bool }
Obstacle is the obstacles falling on the field.
type Onigiri ¶ added in v0.0.4
type Onigiri struct {
// contains filtered or unexported fields
}
Onigiri is a kind of Food. Delicious!
func (*Onigiri) Draw ¶ added in v0.0.4
func (o *Onigiri) Draw(screen *ebiten.Image)
Draw draws this object to the screen.
func (*Onigiri) Eat ¶ added in v0.0.4
Eat eats this food. This func reteruns the value to restore character's stamina.
func (*Onigiri) Initialize ¶ added in v0.0.4
Initialize initializes the object.
args: img: the image to draw pos: the initial position vel: the velocity to move this object
func (*Onigiri) IsCollided ¶ added in v0.0.4
func (o *Onigiri) IsCollided(hr *view.HitRectangle) bool
IsCollided returns whether this obstacle is collided the arg.
type Parts ¶ added in v0.0.4
type Parts struct {
// contains filtered or unexported fields
}
Parts is the field parts.
func (*Parts) Draw ¶ added in v0.0.4
func (p *Parts) Draw(screen *ebiten.Image)
Draw draws this object to the screen.
func (*Parts) Initialize ¶ added in v0.0.4
Initialize initializes the object.
args: img: the image to draw pos: the initial position vel: the velocity at which this object moves autonomously. kv: the factor to multiply the scroll speed when scrolling.
type PrairieField ¶
type PrairieField struct {
// contains filtered or unexported fields
}
PrairieField is the field of prairie.
func (*PrairieField) AttackObstacles ¶ added in v0.0.5
func (p *PrairieField) AttackObstacles(hr *view.HitRectangle, power float64) (int, int)
func (*PrairieField) DrawCloser ¶ added in v0.0.4
func (p *PrairieField) DrawCloser(screen *ebiten.Image)
DrawCloser draws the closer field part.
func (*PrairieField) DrawFarther ¶ added in v0.0.4
func (p *PrairieField) DrawFarther(screen *ebiten.Image)
DrawFarther draws the farther field parts.
func (*PrairieField) EatFoods ¶ added in v0.0.4
func (p *PrairieField) EatFoods(hr *view.HitRectangle) int
EatFoods determines if there is a conflict between the player and the food. If it hits, it returns the stamina gained.
func (*PrairieField) Initialize ¶
func (p *PrairieField) Initialize(lanes *Lanes, goalX float64)
Initialize initializes all resources to draw.
func (*PrairieField) IsCollidedWithObstacles ¶ added in v0.0.4
func (p *PrairieField) IsCollidedWithObstacles(hr *view.HitRectangle) bool
IsCollidedWithObstacles returns whether the r is collided with this item.
func (*PrairieField) Update ¶
func (p *PrairieField) Update(scrollV *view.Vector)
Update moves viewport for the all field parts.
type Rock ¶ added in v0.0.4
type Rock struct {
// contains filtered or unexported fields
}
Rock is the one of obstacles.
func (*Rock) Attack ¶ added in v0.0.4
Attack attacks this obstacle. The damage value reduces this obstacle's hardness.
func (*Rock) Draw ¶ added in v0.0.4
func (r *Rock) Draw(screen *ebiten.Image)
Draw draws this object to the screen.
func (*Rock) Initialize ¶ added in v0.0.4
Initialize initializes the object.
args: img: the image to draw pos: the initial position vel: the velocity to move this object
func (*Rock) IsBroken ¶ added in v0.0.4
IsBroken returns whether this obstacle was broken. The broken state means that the hardness is 0 or less.
func (*Rock) IsCollided ¶ added in v0.0.4
func (r *Rock) IsCollided(rect *view.HitRectangle) bool
IsCollided returns whether this obstacle is collided the arg.
func (*Rock) SetHardness ¶ added in v0.0.4
SetHardness sets the hardness of this obstacle.
type ScrollInfo ¶ added in v0.0.5
type ScrollInfo struct {
// contains filtered or unexported fields
}
ScrollInfo is the info to initialize the ScrollableObject/
type ScrollableObject ¶ added in v0.0.4
type ScrollableObject interface { // Initialize initializes the object. // args: // img: the image to draw // pos: the initial position // kv: the factor to multiply the scroll speed when scrolling. Initialize(img *ebiten.Image, pos *view.Vector, kv float64) // Update updates the position and velocity of this object. // args: // scrollV: the velocity to scroll field parts. Update(scrollV *view.Vector) // Draw draws this object to the screen. Draw(screen *ebiten.Image) }
ScrollableObject is the object can move
type SingleLane ¶ added in v0.0.5
type SingleLane struct {
// contains filtered or unexported fields
}
SingleLane is the scrollable object to implement the lanes. Mainly for seamlessly updating and drawing locations, and drawing individual lanes.
func (*SingleLane) Draw ¶ added in v0.0.5
func (l *SingleLane) Draw(screen *ebiten.Image)
Draw draws this object to the screen.
func (*SingleLane) Initialize ¶ added in v0.0.5
func (l *SingleLane) Initialize(img *ebiten.Image, pos *view.Vector, vel *view.Vector)
Initialize initializes the object.
args: img: the image to draw pos: the initial position vel: the velocity to move this object
func (*SingleLane) Update ¶ added in v0.0.5
func (l *SingleLane) Update(scrollV *view.Vector)
Update updates the position and velocity of this object.
args: scrollV: the velocity to scroll field parts.