gm

package
v0.0.0-...-aacbedc Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ErrInstanceNotFound     = "ErrInstanceNotFound"
	ErrBehaviourNotFound    = "ErrBehaviourNotFound"
	ErrParentObjectNotFound = "ErrParentObjectNotFound"
)
View Source
const (
	// If you develop game for mobile it's better to use this default size (if portrait)
	DefaultCanvasW int = 372 // safe zone area is 270 pixel (based on 20:9), which is pixel 51-321
	DefaultCanvasH int = 600 // safe zone area is 496 pixel (based on 4:3), which is pixel 52-548

)

Variables

This section is empty.

Functions

func DelObject

func DelObject(obj Object)

Delete an Instance from Game and destroy it.

func GetBhvrIDs

func GetBhvrIDs() []int

func GetBhvrIDsByBhvrTypeID

func GetBhvrIDsByBhvrTypeID(id int) []int

func GetBhvrIDsByObjInstID

func GetBhvrIDsByObjInstID(id int) []int

func GetBhvrTypes

func GetBhvrTypes() []string

func GetCanvasSize

func GetCanvasSize() (w, h int)

func GetInstIDByBhvrInstID

func GetInstIDByBhvrInstID(id int) int

func GetInstIDs

func GetInstIDs() []int

func GetInstIDsByBhvrTypeID

func GetInstIDsByBhvrTypeID(id int) []int

func GetInstIDsByObjTypeID

func GetInstIDsByObjTypeID(id int) []int

func GetInstTypes

func GetInstTypes() []string

func GetScreenSize

func GetScreenSize() (w, h int)

func ID

func ID(ins Instance) int

ID returns the instance's ID. It is not safe for use on search query. If it is never been set on game_data before, it will return 0.

func PrintDebug

func PrintDebug() string

func Run

func Run() error

func SetCanvasSize

func SetCanvasSize(w, h int)

func SetCustomLayoutFunction

func SetCustomLayoutFunction(fn func(outsideWidth, outsideHeight int) (screenWidth, screenHeight int))

SetCustomLayoutFunction set user's custom Layout function. Setting this not automatically use this function. You should set the layout type to LayoutType_Custom to use this.

func SetLayoutType

func SetLayoutType(layoutType LayoutType)

func Type

func Type(ins Instance) string

Type returns the instance's Type. It is a guarantee that it will not return empty string, but doesn't mean that this already set on game_data. If it is an instance of Object, it is better to use it once, and cache it on some variable, because it is VERY EXPENSIVE (using reflect). If it is a Behaviour or BehavioursData, you don't need to cache it, because it will autaomatically cached on BehavioursData.

func TypeID

func TypeID(ins Instance) int

TypeID returns the instance's TypeID. It is a guarantee that it will not return 0. It will automatically set the Type, TypeID, and BehavioursData to the game_data. If it is an instance of Object, it is better to use it once, and cache it on some variable, because it is VERY EXPENSIVE (using reflect). If it is a Behaviour or BehavioursData, you don't need to cache it, because it will automatically cached on BehavioursData.

Types

type Behaviour

type Behaviour interface {
	Instance
	Data() BehavioursData
	PreInit()
	PostInit()
	// PreUpdate()
	// PostUpdate()
	Draw(*ebiten.Image)
}

TODO: Consider different interface between Behaviour and Object

func GetBhvrByBhvrInstID

func GetBhvrByBhvrInstID(id int) Behaviour

func MustGetBehaviour

func MustGetBehaviour(instThis Object, bhvrThisTypeID int, bhvrTypeID int) Behaviour

Get Behaviour by type. Must return, panic if not found.

func MustGetBehaviourRel

func MustGetBehaviourRel(bhvrThis Behaviour, bhvrType int) Behaviour

Get relative's Behaviour by type. Must return, panic if not found.

type BehavioursData

type BehavioursData interface {
	Instance
	Behaviour() Behaviour
	// ByInstance(Object) interface{}
	DelInstance(Object)
	PreUpdate()
	PostUpdate()
}

func GetBhvrDataByBhvrTypeID

func GetBhvrDataByBhvrTypeID(id int) BehavioursData

func GetBhvrDatas

func GetBhvrDatas() []BehavioursData

type Instance

type Instance interface {
	// contains filtered or unexported methods
}

type Instancer

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

type LayoutType

type LayoutType int
const (
	// LayoutType_Canvas means that the size of game screen will follow the game's canvas. See the
	// implementation in game's Layout function.
	LayoutType_SnapCanvas LayoutType = iota

	// LayoutType_Outside means that the size of game screen will follow the game's device/window. See
	// the implementation in game's Layout function.
	LayoutType_SnapOutside

	// LayoutType_Custom means that the size of game screen will follow user's function.
	LayoutType_Custom
)

type Object

type Object interface {
	Instance
	Zidx() int
	SetZidx(int)

	IsUpdate() bool
	SetIsUpdate(bool)
	IsDraw() bool
	SetIsDraw(bool)

	Init()
	Update()
	Draw(*ebiten.Image)
	// contains filtered or unexported methods
}

TODO: Consider different interface between Behaviour and Object

func GetInstByObjInstID

func GetInstByObjInstID(id int) Object

func InitObject

func InitObject(inst Object) Object

Set an Instance to Game and initialize it.

func MustGetObjectParent

func MustGetObjectParent(bhvrThis Behaviour) Object

Get behaviour's parent. Must return, panic if not found.

type Objecter

type Objecter struct {
	Instancer
	// contains filtered or unexported fields
}

func (*Objecter) IsDraw

func (inst *Objecter) IsDraw() bool

func (*Objecter) IsUpdate

func (inst *Objecter) IsUpdate() bool

func (*Objecter) SetIsDraw

func (inst *Objecter) SetIsDraw(d bool)

func (*Objecter) SetIsUpdate

func (inst *Objecter) SetIsUpdate(d bool)

func (*Objecter) SetZidx

func (inst *Objecter) SetZidx(d int)

func (*Objecter) Zidx

func (inst *Objecter) Zidx() int

Jump to

Keyboard shortcuts

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