game

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Light berryVariant = iota
	Medium
	Dark
)
View Source
const (
	WindowWidth  = 1920
	WindowHeight = 1080
	TPS          = 60
)
View Source
const (
	TPGM = TPS

	MinsPerHour   = 60
	HoursPerDay   = 20
	DaysPerMonth  = 10
	MonthsPerYear = 8

	SolsticeMonthsOffset = 1
)

Variables

View Source
var (
	NightAmbientLightColor = color.RGBA{115, 100, 135, 255}
	DayAmbientLightColor   = color.RGBA{255, 255, 255, 255}

	BackgroundColor = color.RGBA{58, 112, 82, 255}

	InclineColor = color.RGBA{117, 88, 69, 255}
	RiverColor   = color.RGBA{72, 122, 173, 255}
	LineartColor = color.RGBA{26, 26, 26, 255}
)

Functions

func DefaultHitboxOverlaps added in v0.0.2

func DefaultHitboxOverlaps(layer GameContext, mine HasHitbox, other []image.Rectangle) (bool, error)

func GetAmbientLight added in v0.0.3

func GetAmbientLight(time Time) color.Color

func NewBasicTerrainElement added in v0.0.2

func NewBasicTerrainElement(x int, y int, dx int, dy int) (returnVal image.Rectangle)

Types

type Berry added in v0.1.0

type Berry struct {
	// contains filtered or unexported fields
}

func NewBerry added in v0.1.0

func NewBerry(game *Game, position image.Point) (*Berry, error)

func (Berry) DrawAt added in v0.1.0

func (b Berry) DrawAt(screen *ebiten.Image, pos image.Point) error

func (Berry) GetHitbox added in v0.1.0

func (b Berry) GetHitbox(layer GameContext) ([]image.Rectangle, error)

func (Berry) GetTexture added in v0.1.0

func (b Berry) GetTexture() (*ebiten.Image, error)

func (Berry) GetZ added in v0.1.0

func (b Berry) GetZ() (int, error)

func (Berry) Origin added in v0.1.0

func (b Berry) Origin(GameContext) (image.Point, error)

func (Berry) Overlaps added in v0.1.0

func (b Berry) Overlaps(layer GameContext, other []image.Rectangle) (bool, error)

func (*Berry) SetCooldown added in v0.1.0

func (b *Berry) SetCooldown(tickOnThisInterval bool)

func (Berry) Size added in v0.1.0

func (b Berry) Size(GameContext) (image.Point, error)

func (*Berry) Update added in v0.1.0

func (b *Berry) Update() error

type Climbable

type Climbable interface {
	HasHitbox

	GetClimbSpeed() float64
}

type DepthAwareDrawable

type DepthAwareDrawable interface {
	Drawable

	GetZ() (int, error)
}

type Drawable

type Drawable interface {
	HasHitbox

	DrawAt(*ebiten.Image, image.Point) error
}

type Game

type Game struct {
	// contains filtered or unexported fields
}

func NewGame

func NewGame() (*Game, error)

func (Game) Draw

func (g Game) Draw(screen *ebiten.Image)

func (Game) GenerateFrame added in v0.1.1

func (g Game) GenerateFrame() (*ebiten.Image, error)

func (Game) Layout

func (g Game) Layout(actualWidth, actualHeight int) (screenWidth, screenHeight int)

func (*Game) Run

func (g *Game) Run() error

func (*Game) Update

func (g *Game) Update() (err error)

type GameContext

type GameContext int
const (
	Render GameContext = iota
	Lighting
	Collision
	Interaction
)

type HasHitbox

type HasHitbox interface {
	// Most objects run a direct call to DefaultHitboxOverlaps.
	// This is basically here incase of non-rectangle hitboxes
	// like circles
	Overlaps(GameContext, []image.Rectangle) (bool, error)
	Origin(GameContext) (image.Point, error)
	Size(GameContext) (image.Point, error)
	GetHitbox(GameContext) ([]image.Rectangle, error)
}

type Incline

type Incline struct {
	// contains filtered or unexported fields
}

func NewIncline added in v0.1.1

func NewIncline(hitbox image.Rectangle) *Incline

func (*Incline) DrawAt

func (i *Incline) DrawAt(screen *ebiten.Image, pos image.Point) error

func (Incline) GetClimbSpeed

func (i Incline) GetClimbSpeed() float64

func (Incline) GetHitbox added in v0.0.2

func (i Incline) GetHitbox(layer GameContext) ([]image.Rectangle, error)

func (Incline) GetZ

func (i Incline) GetZ() (int, error)

func (Incline) Origin added in v0.0.2

func (i Incline) Origin(GameContext) (image.Point, error)

func (Incline) Overlaps added in v0.0.2

func (i Incline) Overlaps(layer GameContext, other []image.Rectangle) (bool, error)

func (Incline) Size added in v0.0.2

func (i Incline) Size(GameContext) (image.Point, error)

type InputHandler added in v0.1.0

type InputHandler struct {
	// contains filtered or unexported fields
}

func NewInputHandler added in v0.1.0

func NewInputHandler() InputHandler

func (InputHandler) ForwardsImpulse added in v0.1.0

func (p InputHandler) ForwardsImpulse() float64

func (InputHandler) IsClimbing added in v0.1.0

func (p InputHandler) IsClimbing() bool

func (InputHandler) IsJumping added in v0.1.0

func (p InputHandler) IsJumping() bool

func (InputHandler) LeftImpulse added in v0.1.0

func (p InputHandler) LeftImpulse() float64

type Lamp

type Lamp struct {
	// contains filtered or unexported fields
}

func NewLamp

func NewLamp() Lamp

func (Lamp) DrawLighting

func (l Lamp) DrawLighting(lightingLayer *ebiten.Image, pos image.Point) error

func (Lamp) GetHitbox added in v0.0.2

func (l Lamp) GetHitbox(layer GameContext) ([]image.Rectangle, error)

func (Lamp) Origin added in v0.0.2

func (l Lamp) Origin(GameContext) (image.Point, error)

func (Lamp) Overlaps added in v0.0.2

func (l Lamp) Overlaps(layer GameContext, other []image.Rectangle) (bool, error)

func (Lamp) Size added in v0.0.2

func (l Lamp) Size(GameContext) (image.Point, error)

type Lightable

type Lightable interface {
	HasHitbox

	DrawLighting(*ebiten.Image, image.Point) error
}

type OffsetImage added in v0.1.1

type OffsetImage struct {
	Image  *ebiten.Image
	Offset image.Point
}

func ApplyLineart added in v0.0.2

func ApplyLineart(oldImgSeg *ebiten.Image, fullObj HasHitbox, thisSeg image.Rectangle) (*OffsetImage, error)

Takes an image and adds lineart to all sides of it before returning the new image. The image given should be a single rect out of the full object so that it can be computed seperately. The new offset from the original image is also returned so the image can be seemlessly inserted.(This is useful for keeping it in line with hitboxes)

func (*OffsetImage) DrawAt added in v0.1.1

func (l *OffsetImage) DrawAt(screen *ebiten.Image, pos image.Point)

type Player

type Player struct {
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(game *Game) Player

func (Player) DrawAt

func (p Player) DrawAt(screen *ebiten.Image, pos image.Point) error

func (Player) GetHitbox added in v0.0.2

func (p Player) GetHitbox(layer GameContext) ([]image.Rectangle, error)

func (Player) GetSmallestJump added in v0.0.2

func (p Player) GetSmallestJump(jumpables []HasHitbox) (image.Point, bool, error)

func (Player) GetZ

func (p Player) GetZ() (int, error)

func (Player) Origin added in v0.0.2

func (p Player) Origin(layer GameContext) (image.Point, error)

func (Player) Overlaps added in v0.0.2

func (p Player) Overlaps(layer GameContext, other []image.Rectangle) (bool, error)

func (Player) Size added in v0.0.2

func (p Player) Size(layer GameContext) (image.Point, error)

func (*Player) Update

func (p *Player) Update() (err error)

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func NewRenderer

func NewRenderer(game *Game) Renderer

func (*Renderer) Render

func (r *Renderer) Render(mapElements []DepthAwareDrawable, lights []Lightable, hudElements []Drawable) (*ebiten.Image, error)

type River

type River struct {
	// contains filtered or unexported fields
}

func NewRiver added in v0.1.1

func NewRiver(hitbox ...image.Rectangle) *River

func (River) DrawAt

func (r River) DrawAt(screen *ebiten.Image, pos image.Point) error

func (River) GetHitbox added in v0.0.2

func (r River) GetHitbox(layer GameContext) ([]image.Rectangle, error)

func (River) GetZ

func (r River) GetZ() (int, error)

func (River) Origin added in v0.0.2

func (r River) Origin(layer GameContext) (image.Point, error)

func (River) Overlaps added in v0.0.2

func (r River) Overlaps(layer GameContext, other []image.Rectangle) (bool, error)

func (River) Size added in v0.0.2

func (r River) Size(layer GameContext) (image.Point, error)

type Season added in v0.0.3

type Season int
const (
	Spring Season = iota
	Summer
	Autumn
	Winter
)

func GetSeason added in v0.0.3

func GetSeason(monthInYear int) (Season, error)

Returns a Season from a month in the year. The parsed month should be 1-indexed so 0 in invalid.

Any value provided outside of the range 1-8 will return an error

func (Season) String added in v0.0.3

func (s Season) String() string

type TextAlignment added in v0.0.3

type TextAlignment int
const (
	// Position doesn't get automatically controlled
	// and needs to be done separately
	Free TextAlignment = iota
	// Automatically adjust the position of the text
	// to be centred at the top of the screen
	TopCentre
)

type TextElement

type TextElement struct {
	Contents  string
	Alignment TextAlignment
	Font      assets.Font
	Scale     int
	// contains filtered or unexported fields
}

func NewTextElement added in v0.1.1

func NewTextElement(contents string, alignment TextAlignment, font assets.Font, scale int) TextElement

func (*TextElement) DrawAt

func (t *TextElement) DrawAt(screen *ebiten.Image, pos image.Point) error

func (TextElement) GetHitbox added in v0.0.2

func (t TextElement) GetHitbox(layer GameContext) ([]image.Rectangle, error)

func (TextElement) Origin added in v0.0.2

func (t TextElement) Origin(GameContext) (image.Point, error)

func (TextElement) Overlaps added in v0.0.2

func (t TextElement) Overlaps(layer GameContext, other []image.Rectangle) (bool, error)

func (TextElement) Size added in v0.0.2

func (*TextElement) Update added in v0.0.2

func (t *TextElement) Update()

type Time

type Time int

func (Time) Days added in v0.1.0

func (t Time) Days() int

func (Time) DaysThroughYear added in v0.1.0

func (t Time) DaysThroughYear() int

func (Time) Hours added in v0.1.0

func (t Time) Hours() int

func (Time) HoursThroughMonth added in v0.1.0

func (t Time) HoursThroughMonth() int

func (Time) Months added in v0.1.0

func (t Time) Months() int

func (Time) MonthsThroughYear added in v0.1.0

func (t Time) MonthsThroughYear() int

func (Time) String

func (t Time) String() string

func (Time) ThroughDay added in v0.1.0

func (t Time) ThroughDay() float64

func (Time) ThroughMonth added in v0.1.0

func (t Time) ThroughMonth() float64

func (*Time) Tick

func (t *Time) Tick()

func (Time) TicksThroughDay added in v0.1.0

func (t Time) TicksThroughDay() int

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

func NewTree

func NewTree() Tree

func (Tree) DrawAt

func (t Tree) DrawAt(screen *ebiten.Image, pos image.Point) error

func (Tree) GetHitbox added in v0.0.2

func (t Tree) GetHitbox(layer GameContext) ([]image.Rectangle, error)

func (Tree) GetZ

func (t Tree) GetZ() (int, error)

func (Tree) Origin added in v0.0.2

func (t Tree) Origin(GameContext) (image.Point, error)

func (Tree) Overlaps added in v0.0.2

func (t Tree) Overlaps(layer GameContext, other []image.Rectangle) (bool, error)

func (Tree) Size added in v0.0.2

func (t Tree) Size(GameContext) (image.Point, error)

type Viewport

type Viewport struct {
	// contains filtered or unexported fields
}

func NewViewport

func NewViewport() Viewport

func (Viewport) DrawToHUD

func (v Viewport) DrawToHUD(hudLayer *ebiten.Image, drawable Drawable) error

func (Viewport) DrawToLighting

func (v Viewport) DrawToLighting(lightingLayer *ebiten.Image, lightable Lightable) error

func (Viewport) DrawToMap

func (v Viewport) DrawToMap(mapLayer *ebiten.Image, drawable Drawable) error

func (Viewport) GetHitbox added in v0.0.2

func (v Viewport) GetHitbox(layer GameContext) ([]image.Rectangle, error)

func (Viewport) Origin added in v0.0.2

func (v Viewport) Origin(layer GameContext) (image.Point, error)

func (Viewport) Overlaps added in v0.0.2

func (v Viewport) Overlaps(layer GameContext, other []image.Rectangle) (bool, error)

func (Viewport) Size added in v0.0.2

func (v Viewport) Size(layer GameContext) (image.Point, error)

func (*Viewport) UpdatePosition

func (v *Viewport) UpdatePosition(player Player) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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