world

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

世界

Index

Constants

View Source
const (
	StructureToggleHelp = iota + 1
	StructureBulldozer
	StructureRoad
	StructurePlain
	StationBusStop
)
View Source
const (
	MonthTicks = 144 * 5
	YearTicks  = MonthTicks * 12
	TileSize   = 64

	SidebarWidth = 199

	CameraMinZoom = 0.1
	CameraMaxZoom = 10.0
	GrassTile     = uint32(0)
)

Variables

View Source
var ErrInvalidBuildingNotFit = errors.New("invalid location: building does not fit") // 建設場所が不適
View Source
var ErrLocationOccupied = errors.New("invalid location: space already occupied")
View Source
var ErrNothingToBulldoze = errors.New("nothing to bulldoze") // 取り壊すものがない
View Source
var ErrTileImageNotFound = errors.New("tile image not found")
View Source
var HUDButtons []*HUDButton
View Source
var HelpText = []string{`
Welcome to Mapp!          (1/2)
`, `
This is last page...      (2/2)
`,
}

HelpText lines must be 39 characters or less.

View Source
var StructureCosts = map[int]int{
	StructureBulldozer: 5,
	StructureRoad:      25,
	StationBusStop:     50,
}

実行に必要な額

View Source
var StructureFilePaths = map[int]string{
	StructureBulldozer: "map/bulldozer.tmx",
	StructureRoad:      "map/road.tmx",
	StructurePlain:     "map/plain.tmx",
	StationBusStop:     "map/busstop.tmx",
}

タイルへのファイルパス

View Source
var StructureTooltips = map[int]string{
	StructureToggleHelp: "Help",
	StructureBulldozer:  "Bulldozer",
	StructureRoad:       "Road",
	StationBusStop:      "Bus Stop",
}

ツールチップの文字列

View Source
var World = &GameWorld{
	CamScale:       startingZoom,
	CamScaleTarget: startingZoom,

	TileImages: make(map[uint32]*ebiten.Image),
	ResetGame:  true,
	Level:      NewLevel(256),

	BuildDragX: -1,
	BuildDragY: -1,
	LastBuildX: -1,
	LastBuildY: -1,

	Printer: message.NewPrinter(language.English),
	IsDebug: true,

	PreviewTileType: PlainTile,
}

Functions

func Buildable added in v1.1.0

func Buildable(structureType int, tx int, ty int) bool

タイルによって置ける条件が変わる

func CartesianToIso

func CartesianToIso(x, y float64) (float64, float64)

CartesianToIso transforms cartesian coordinates into isometric coordinates.

func Date

func Date() (month string, year string)

func DrawStructure added in v1.2.0

func DrawStructure(structureType int) *ebiten.Image

func HelpButtonAt

func HelpButtonAt(x, y int) int

func IsoToCartesian

func IsoToCartesian(x, y float64) (float64, float64)

CartesianToIso transforms cartesian coordinates into isometric coordinates.

func IsoToScreen

func IsoToScreen(x, y float64) (float64, float64)

func LevelCoordinatesToScreen

func LevelCoordinatesToScreen(x, y float64) (float64, float64)

func LoadTileset

func LoadTileset() error

func ObjectToRect

func ObjectToRect(o *tiled.Object) image.Rectangle

func Reset

func Reset()

func ScreenToCartesian

func ScreenToCartesian(x, y int) (float64, float64)

func ScreenToIso

func ScreenToIso(x, y int) (float64, float64)

func SetHelpPage

func SetHelpPage(page int)

func SetHoverStructure

func SetHoverStructure(structureType int)

建設を選択中

func ShowBuildCost

func ShowBuildCost(structureType int, cost int)

func ShowMessage

func ShowMessage(message string, duration int)

func StartGame

func StartGame()

func TickMessages

func TickMessages()

メッセージは、建設時などに右上に一時的に出るメッセージのこと

func TooltipText

func TooltipText() string

選択中の建物のツールチップテキストを取得する

func ValidXY

func ValidXY(x, y int) bool

Types

type GameLevel

type GameLevel struct {
	Tiles [][][]*Tile
	// contains filtered or unexported fields
}

levelは高さのことっぽい

func NewLevel

func NewLevel(size int) *GameLevel

func (*GameLevel) AddLayer

func (l *GameLevel) AddLayer()

平面にタイルを敷き詰めた配列を作る

func (*GameLevel) ClearHoverSprites

func (l *GameLevel) ClearHoverSprites()

タイル全体のHoverSpriteフラグをオフにする

type GameWorld

type GameWorld struct {
	Level *GameLevel

	Player entity.Player

	ScreenW, ScreenH int

	IsDebug bool

	GameStarted      bool
	GameStartedTicks int
	GameOver         bool

	PlayerX, PlayerY float64

	CamX, CamY     float64
	CamScale       float64
	CamScaleTarget float64

	HoverStructure         int // 選択中の建設物
	HoverX, HoverY         int
	HoverLastX, HoverLastY int
	HoverValid             bool

	Map *tiled.Map

	TileImages         map[uint32]*ebiten.Image
	TileImagesFirstGID uint32

	ResetGame bool

	GotCursorPosition bool

	EnvironmentSprites int

	HUDUpdated     bool
	HUDButtonRects []image.Rectangle

	HelpUpdated     bool
	HelpPage        int
	HelpButtonRects []image.Rectangle

	Ticks int
	Funds int

	Printer *message.Printer

	Messages      []string // 右上に一時的に表示するメッセージ。MessagesとMessagesTicksのスライスの数は対応している
	MessagesTicks []int    // 右上に一時的に表示するメッセージの残り秒

	BuildDragX int
	BuildDragY int

	LastBuildX int
	LastBuildY int

	PreviewTileType TileType // 選択中の、プレビュー表示するタイルタイプ。TODO: エンティティに移動させる
	// contains filtered or unexported fields
}

func (*GameWorld) SetGameOver

func (w *GameWorld) SetGameOver(vx, vy float64)

type HUDButton

type HUDButton struct {
	Sprite                       *ebiten.Image
	SpriteOffsetX, SpriteOffsetY float64
	Label                        string
	StructureType                int
}

func HUDButtonAt

func HUDButtonAt(x, y int) *HUDButton

指定座標に該当するボタンを返す

type PowerPlant

type PowerPlant struct {
	Type int
	X, Y int
}

type Structure

type Structure struct {
	Type int
	X, Y int
}

func BuildStructure

func BuildStructure(structureType int, hover bool, placeX int, placeY int, internal bool) (*Structure, error)

type Tile

type Tile struct {
	Hover    bool // タイルがプレビュー表示中かどうか。falseが通常時。エンティティに移動させたい
	TileType TileType
}

type TileType added in v1.2.0

type TileType string
const (
	PlainTile   TileType = "plain"    // 平原
	RoadTile    TileType = "road"     // 道路
	BusStopTile TileType = "bus stop" // バス停
)

Jump to

Keyboard shortcuts

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