gamehex

package
v0.0.0-...-ce97658 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

gamehex

Sample project to demonstrate how to use the Ebiten game engine to create a hexagonal game. This is still a work in progress.

alt text

Tileset

The tileset used in this project is from OpenGameArt.org and can be found here: https://opengameart.org/content/hex-tileset-pack

Documentation

Overview

Package gamehex implements an example hexagonal game board and uses ebiten for rendering.

Index

Constants

This section is empty.

Variables

View Source
var (
	//go:embed tiles/HexTilesetv3.png
	Spritesheet_png []byte
)

Functions

This section is empty.

Types

type Game

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

func NewGame

func NewGame() (*Game, error)

NewGame returns a new isometric demo Game.

func (*Game) Draw

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

Draw draws the Game on the screen.

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int)

Layout is called when the Game's layout changes.

func (*Game) Update

func (g *Game) Update() error

Update reads current user input and updates the Game state.

type Level

type Level struct {
	Width  int
	Height int

	Tiles []Tile
	// contains filtered or unexported fields
}

func NewLevel

func NewLevel(width, height int) (*Level, error)

func (*Level) HexTileXYToPixelPos

func (l *Level) HexTileXYToPixelPos(x, y int) (int, int)

HexTilePos returns the center coordinates in pixel for the given hex tile in the hex grid. NOTE: This is the flat top version of the hex grid.

func (*Level) TileAtPos

func (l *Level) TileAtPos(px, py int) (int, int)

TileAtPos returns which tile the given position is in. NOTE: This is the flat top version of the hex grid.

type SpriteSheet

type SpriteSheet struct {
	Grass *ebiten.Image
	Dirt  *ebiten.Image
	Water *ebiten.Image
	Snow  *ebiten.Image
	Trees *ebiten.Image
}

SpriteSheet represents a collection of sprite images.

func LoadSpriteSheet

func LoadSpriteSheet(tileSize int) (*SpriteSheet, error)

LoadSpriteSheet loads the embedded SpriteSheet.

type Tile

type Tile byte

func (Tile) HasTrees

func (t Tile) HasTrees() bool

func (Tile) Type

func (t Tile) Type() TileType

type TileType

type TileType int

TileType represents the type of a tile.

const (
	TileTypeGrass TileType = iota
	TileTypeDirt
	TileTypeWater
	TileTypeSnow
	TileTypeTrees
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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