field

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
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) DrawBack added in v0.0.5

func (g *Goal) DrawBack(screen *ebiten.Image)

func (*Goal) DrawFront added in v0.0.5

func (g *Goal) DrawFront(screen *ebiten.Image)

func (*Goal) Initialize added in v0.0.5

func (g *Goal) Initialize(bkImg, frImg *ebiten.Image, pos *view.Vector, vel *view.Vector)

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

func (*Goal) Update added in v0.0.5

func (g *Goal) Update(scrollV *view.Vector)

Update updates the position and velocity of this object.

args:
 scrollV: the velocity to scroll field parts.

type LaneType added in v0.0.5

type LaneType string
const (
	PrairieLane LaneType = "PrairieLane"
)

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 NewLanes added in v0.0.5

func NewLanes(lType LaneType) *Lanes

func (*Lanes) Draw added in v0.0.5

func (l *Lanes) Draw(screen *ebiten.Image)

func (*Lanes) GetLaneHeights added in v0.0.5

func (l *Lanes) GetLaneHeights() []float64

func (*Lanes) GetTargetLaneHeight added in v0.0.5

func (l *Lanes) GetTargetLaneHeight() float64

func (*Lanes) GoToLowerLane added in v0.0.5

func (l *Lanes) GoToLowerLane() bool

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

func (l *Lanes) GoToUpperLane() bool

GoToUpperLane sets the upper lane as the destination and returns true if the destination lane exists, false if not.

func (*Lanes) Update added in v0.0.5

func (l *Lanes) Update(scrollV *view.Vector)

type MovableObject added in v0.0.5

type MovableObject interface {
	// SetVelocity sets velocity at which this object will move by itself.
	SetVelocity(vel *view.Vector)
}

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

func (o *Onigiri) Eat() int

Eat eats this food. This func reteruns the value to restore character's stamina.

func (*Onigiri) Initialize added in v0.0.4

func (o *Onigiri) Initialize(img *ebiten.Image, pos *view.Vector, kv float64)

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.

func (*Onigiri) Update added in v0.0.4

func (o *Onigiri) Update(scrollV *view.Vector)

Update updates the position and velocity of this object.

args:
 scrollV: the velocity to scroll this field parts.

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

func (p *Parts) Initialize(img *ebiten.Image, pos *view.Vector, kv float64)

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.

func (*Parts) Update added in v0.0.4

func (p *Parts) Update(scrollV *view.Vector)

Update updates the position and velocity of this object.

args:
 scrollV: the velocity to scroll this field parts.

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

func (r *Rock) Attack(damage float64)

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

func (r *Rock) Initialize(img *ebiten.Image, pos *view.Vector, kv float64)

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

func (r *Rock) IsBroken() bool

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

func (r *Rock) SetHardness(hardness float64)

SetHardness sets the hardness of this obstacle.

func (*Rock) Update added in v0.0.4

func (r *Rock) Update(scrollV *view.Vector)

Update updates the position and velocity of this object.

args:
 scrollV: the velocity to scroll this field parts.

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.

Jump to

Keyboard shortcuts

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