gml

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GpAxisFirst is to be used for looping over all axises
	GpAxisFirst = GpAxisLH

	GpAxisNone = 0
	GpAxisLH   = 1
	GpAxisLV   = 2
)

WARNING: Do not reorder or change for backwards compatibility. This allows these values to be used when storing gamepad settings to persistent storage.

View Source
const (
	DEBUG_COLLISION = false
)

Variables

This section is empty.

Functions

func AssetDirectory

func AssetDirectory() string

func CameraCreate

func CameraCreate(index int, windowX, windowY, windowWidth, windowHeight float64)

func CameraDestroy

func CameraDestroy(index int)

func CameraGetActive

func CameraGetActive() int

CameraGetActive will get the current camera that is actively being drawn on. Will panic not in Draw calls or in an invalid context

func CameraGetViewPos

func CameraGetViewPos(index int) geom.Vec

func CameraGetViewSize

func CameraGetViewSize(index int) geom.Vec

func CameraSetUpdateFunction

func CameraSetUpdateFunction(index int, updateFunc func())

func CameraSetViewPos

func CameraSetViewPos(index int, x, y float64)

func CameraSetViewSize

func CameraSetViewSize(index int, width, height float64)

func CameraSetViewTarget

func CameraSetViewTarget(index int, inst InstanceIndex)

func ClearKeyboardString

func ClearKeyboardString()

func ContextUpdatePop

func ContextUpdatePop(currentContext contextUpdateLoop)

func ContextUpdatePush

func ContextUpdatePush(context contextUpdateLoop)

PushUpdateContext allows you to override the state of the game with a special behaviour interface

func CustomAssetDirectory

func CustomAssetDirectory() string

func DebugFrameCount

func DebugFrameCount() int

DebugFrameCount is similar to DebugTickCount but doesn't increase if ebiten skips the draw

func DebugFrameUsage added in v0.4.0

func DebugFrameUsage() string

DebugFrameUsage returns a string like "1% (55ns)" to tell you how much of your frame budget has been utilized.

func DebugTickCount added in v0.4.0

func DebugTickCount() int

DebugTickCount is incremented by 1 per update() call

func DeltaTime

func DeltaTime() float64

DeltaTime gets the fixed delta time based on the designed TPS divided by max TPS.

func DesignedTPS

func DesignedTPS() int

DesignedTPS() returns the ticks-per-second that the game was designed to run at.

Default is 60

func DrawGetGUI

func DrawGetGUI() bool

DrawGetGUI returns whether Draw functions will draw relative to the screen or not

func DrawRectangle

func DrawRectangle(x, y, w, h float64, col color.Color)

func DrawRectangleAlpha

func DrawRectangleAlpha(x, y, w, h float64, col color.Color, alpha float64)

func DrawRectangleBorder

func DrawRectangleBorder(x, y, w, h float64, col color.Color, borderSize float64, borderColor color.Color)

func DrawSelf

func DrawSelf(state *sprite.SpriteState, x, y float64)

func DrawSetFont

func DrawSetFont(font FontIndex)

DrawSetFont will set the font index to be used for DrawText functions

func DrawSetGUI

func DrawSetGUI(guiMode bool)

DrawSetGUI allows you to set whether you want to draw relative to the screen (true) or to the world (false)

func DrawSprite

func DrawSprite(spriteIndex sprite.SpriteIndex, subimage float64, x, y float64)

func DrawSpriteAlpha

func DrawSpriteAlpha(spriteIndex sprite.SpriteIndex, subimage float64, x, y float64, alpha float64)

func DrawSpriteColor

func DrawSpriteColor(spriteIndex sprite.SpriteIndex, subimage float64, x, y float64, col color.Color)

DrawSpriteColor will draw a sprite with a color blend

func DrawSpriteCutMask

func DrawSpriteCutMask(spriteIndex sprite.SpriteIndex, subimage float64, x, y float64, options DrawSpriteMaskOptions)

DrawSpriteCutMask will draw the given sprite but allow you to pass multiple sprite images in to cut out transparency.

func DrawSpriteExt

func DrawSpriteExt(spriteIndex sprite.SpriteIndex, subimage float64, x, y float64, rotation float64, scale geom.Vec, alpha float64)

func DrawSpriteRotated

func DrawSpriteRotated(spriteIndex sprite.SpriteIndex, subimage float64, x, y float64, rotation float64)

func DrawSpriteScaled

func DrawSpriteScaled(spriteIndex sprite.SpriteIndex, subimage float64, x, y float64, scale geom.Vec)

func DrawText

func DrawText(x, y float64, message string, col color.Color)

DrawText is deprecated. Use DrawText. *note* might make more sense to rename DrawText to DrawText

and DrawTextAlpha to DrawTextAlpha

func DrawTextAlpha

func DrawTextAlpha(x, y float64, message string, col color.Color, alpha float64)

func GameEnd

func GameEnd()

GameEnd will close the game

func GamepadAxisValue

func GamepadAxisValue(id int, axis GamepadAxis) float64

func GamepadCheck

func GamepadCheck(id int, button GamepadButton) bool

func GamepadCheckPressed

func GamepadCheckPressed(id int, button GamepadButton) bool

func GamepadGetDescription added in v0.4.0

func GamepadGetDescription(id int) string

func InitCustomAsset

func InitCustomAsset(indexToPath []string)

InitCustomAsset is used by code generated by gmlgo so you can query a custom asset

func InitFontGeneratedData

func InitFontGeneratedData(indexToName []string, nameToIndex map[string]FontIndex)

InitFontGeneratedData is used by code generated by gmlgo so you can query a font by index or name

func InitObjectGeneratedData

func InitObjectGeneratedData(indexToName []string, nameToIndex map[string]ObjectIndex, objTypes []ObjectType)

InitObjectGeneratedData is required to be called so the engine can create game objects

func InitSpriteGeneratedData

func InitSpriteGeneratedData(indexToName []string, nameToIndex map[string]SpriteIndex, indexToPath []string)

InitSpriteGeneratedData is used by code generated by gmlgo so you can query a sprite by index or name

func InstanceDestroy

func InstanceDestroy(inst ObjectType)

InstanceDestroy will make an object call its Destroy then its Free method and then it will no longer exist.

func InstanceExists

func InstanceExists(inst ObjectType) bool

InstanceExists will return true if an object has not been destroyed and belongs to a room

func InstanceFree

func InstanceFree(inst ObjectType)

InstanceFree will make an object call its Free method and then it will no longer exist.

func InstanceIsPaused

func InstanceIsPaused() bool

InstanceIsPaused will return whether executing the Update() method of instances is disabled. Update() method of instances can be disabled by utilizing InstanceSetPauseCallback()

func InstanceSetPauseCallback

func InstanceSetPauseCallback(callback func() bool)

InstanceSetPauseCallback will call the provided function to check if instances should call their Update() method or not.

func IsBrowser

func IsBrowser() bool

IsBrowser will return true if the game is playing in a web browser

func IsCreatingRoomInstance

func IsCreatingRoomInstance() bool

IsCreatingRoomInstance is to be used in the Create() event of your objects, this will only return true if the object is being created from room data, not code.

func KeyboardCheck

func KeyboardCheck(key Key) bool

func KeyboardCheckPressed

func KeyboardCheckPressed(key Key) bool

func KeyboardString

func KeyboardString() string

KeyboardString returns the last letters typed by the user since ClearKeyboardString was called this is useful for input boxes and easily getting input from a user.

func MaxTPS

func MaxTPS() int

MaxTPS returns the current maximum TPS.

func MouseCheckButton

func MouseCheckButton(button int) bool

func MouseCheckPressed

func MouseCheckPressed(button int) bool

func MousePosition

func MousePosition() geom.Vec

MouseScreenPosition returns the camera viewport

func MouseScreenPosition

func MouseScreenPosition() geom.Vec

MouseScreenPosition returns the mouse position relative to the window

func PlaceFree

func PlaceFree(instType collisionObject, x, y float64) bool

func ProgramDirectory

func ProgramDirectory() string

func Run

func Run(controller gameController, gameSettings GameSettings)

Run

func SetDesignedTPS

func SetDesignedTPS(tps int)

SetDesignedTPS is the ticks-per-second the game was initially designed to run at. ie. 30tps, 60tps, etc

For example, if you're porting a Game Maker game that ran at 30 frames per second, you'd want this to be 30 so that translation of alarm logic works seamlessly.

func SetKeyboardString

func SetKeyboardString(text string)

func SetMaxTPS

func SetMaxTPS(tps int)

SetMaxTPS sets the maximum TPS (ticks per second), that represents how many updating function is called per second. The initial value is 60.

If tps is UncappedTPS, TPS is uncapped and the game is updated per frame. If tps is negative but not UncappedTPS, SetMaxTPS panics.

func StringHeight

func StringHeight(text string) float64

StringHeight will return height of the input string in pixels.

func StringWidth

func StringWidth(text string) float64

StringWidth will return the width of the input string in pixels.

func TestBootstrap

func TestBootstrap(controller gameController, gameSettings GameSettings, testSettings TestSettings)

TestBootstrap the game to give control over continuing / stopping execution per-frame this method is for additional control when testing

func WindowCursorVisible

func WindowCursorVisible() bool

func WindowGetFullscreen

func WindowGetFullscreen() bool

func WindowScale

func WindowScale() float64

func WindowSetCursorVisible

func WindowSetCursorVisible(visible bool)

func WindowSetFullscreen

func WindowSetFullscreen(value bool)

func WindowSetScale

func WindowSetScale(scale float64)

func WindowSetSize

func WindowSetSize(width, height float64)

func WindowSize

func WindowSize() geom.Vec

WindowSize will get the size of the current game window

Types

type Controller

type Controller struct {
}

func (*Controller) GamePostDraw

func (controller *Controller) GamePostDraw()

func (*Controller) GamePostUpdate

func (controller *Controller) GamePostUpdate()

func (*Controller) GamePreDraw

func (controller *Controller) GamePreDraw()

func (*Controller) GamePreUpdate

func (controller *Controller) GamePreUpdate()

type CustomAssetIndex

type CustomAssetIndex int32

func (CustomAssetIndex) Path

func (index CustomAssetIndex) Path() string

type DefaultContext

type DefaultContext struct{}

func (*DefaultContext) Close

func (context *DefaultContext) Close()

func (*DefaultContext) Draw

func (context *DefaultContext) Draw()

func (*DefaultContext) Open

func (context *DefaultContext) Open()

func (*DefaultContext) Update

func (context *DefaultContext) Update()

type DrawSpriteMaskOptions

type DrawSpriteMaskOptions struct {
	Masks []SpriteFrame
}

type FontIndex

type FontIndex int32

func DrawGetFont

func DrawGetFont() FontIndex

DrawGetFont will get the font index used for DrawText functions

type GameSettings

type GameSettings struct {
	WindowTitle  string
	WindowWidth  float64
	WindowHeight float64
	WindowScale  float64
}

type GamepadAxis

type GamepadAxis int32

func GamepadAxisCount added in v0.4.0

func GamepadAxisCount(id int) GamepadAxis

func (GamepadAxis) String added in v0.4.0

func (button GamepadAxis) String() string

type GamepadButton

type GamepadButton int32
const (
	GpButtonNone GamepadButton = 0
	// GpButtonFirst is to be used for looping over all buttons
	GpButtonFirst = GpButton0
)
const (
	GpButton0 GamepadButton = 1 + iota
	GpButton1
	GpButton2
	GpButton3
	GpButton4
	GpButton5
	GpButton6
	GpButton7
	GpButton8
	GpButton9
	GpButton10
	GpButton11
	GpButton12
	GpButton13
	GpButton14
	GpButton15
	GpButton16
	GpButton17
	GpButton18
	GpButton19
	GpButton20
	GpButton21
	GpButton22
	GpButton23
	GpButton24
	GpButton25
	GpButton26
	GpButton27
	GpButton28
	GpButton29
	GpButton30
	GpButton31
	GpSize
	GpShoulderLT // Special handling: Left shoulder trigger
	GpShoulderRT // Special handling: Right shoulder trigger
)

WARNING: Do not reorder or change for backwards compatibility. This allows these values to be used when storing gamepad settings to persistent storage.

const (
	GpFace1      GamepadButton = 1 + iota // Top button 1 (this maps to the "A" on an Xbox 360 controller and the cross on a PS controller)
	GpFace2                               // Top button 2 (this maps to the "B" on an Xbox 360 controller and the circle on a PS controller)
	GpFace3                               // Top button 3 (this maps to the "X" on an Xbox 360 controller and the square on a PS controller)
	GpFace4                               // Top button 4 (this maps to the "Y" on an Xbox 360 controller and the triangle on a PS controller)
	GpShoulderLB                          // Left shoulder button
	GpShoulderRB                          // Right shoulder button
	GpSelect
	GpStart
	GpStickLeft  // Left-stick, pressed as a button
	GpStickRight // Right-stick, pressed as a button
	GpPadUp
	GpPadRight
	GpPadDown
	GpPadLeft
)

WARNING: Do not reorder or change for backwards compatibility. This allows these values to be used when storing gamepad settings to persistent storage.

func GamepadButtonCount added in v0.4.0

func GamepadButtonCount(id int) GamepadButton

func (GamepadButton) String added in v0.4.0

func (button GamepadButton) String() string

type InstanceIndex

type InstanceIndex int32
const Noone InstanceIndex = 0

Noone is to be used when checking if there is no instance with InstanceIndex type

func CollisionRectList

func CollisionRectList(instType collisionObject, x, y float64) []InstanceIndex

func (InstanceIndex) Get

func (index InstanceIndex) Get() ObjectType

type Key

type Key int32
const (
	VkNoKey       Key = 0 + iota // keycode representing that no key is pressed
	VkAnykey                     // keycode representing that any key is pressed
	VkLeft                       // keycode for left arrow key
	VkRight                      // keycode for right arrow key
	VkUp                         // keycode for up arrow key
	VkDown                       // keycode for down arrow key
	VkEnter                      // enter key
	VkEscape                     // escape key
	VkSpace                      // space key
	VkShift                      // either of the shift keys
	VkControl                    // either of the control keys
	VkAlt                        // alt key
	VkBackspace                  // backspace key
	VkTab                        // tab key
	VkHome                       // home key
	VkEnd                        // end key
	VkDelete                     // delete key
	VkInsert                     // insert key
	VkPageUp                     // pageup key
	VkPageDown                   // pagedown key
	VkPause                      // pause/break key
	VkPrintScreen                // printscreen/sysrq key
	VkF1                         // keycode for the function keys F1 to F12
	VkF2
	VkF3
	VkF4
	VkF5
	VkF6
	VkF7
	VkF8
	VkF9
	VkF10
	VkF11
	VkF12
	Vk0
	Vk1
	Vk2
	Vk3
	Vk4
	Vk5
	Vk6
	Vk7
	Vk8
	Vk9
	VkNumpad0
	VkNumpad1
	VkNumpad2
	VkNumpad3
	VkNumpad4
	VkNumpad5
	VkNumpad6
	VkNumpad7
	VkNumpad8
	VkNumpad9
	VkNumpadEnter
	VkMultiply // multiply key on the numeric keypad
	VkDivide   // divide key on the numeric keypad
	VkAdd      // key on the numeric keypad
	VkSubtract // subtract key on the numeric keypad
	VkDecimal  // decimal dot keys on the numeric keypad
	VkA
	VkB
	VkC
	VkD
	VkE
	VkF
	VkG
	VkH
	VkI
	VkJ
	VkK
	VkL
	VkM
	VkN
	VkO
	VkP
	VkQ
	VkR
	VkS
	VkT
	VkU
	VkV
	VkW
	VkX
	VkY
	VkZ
	VkSize
)

WARNING: Do not reorder or change for backwards compatibility. This allows these values to be used when storing keyboard settings to persistent storage.

func (Key) String

func (key Key) String() string

type Object

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

func (*Object) BaseObject

func (inst *Object) BaseObject() *Object

func (*Object) Bbox

func (inst *Object) Bbox() geom.Rect

func (*Object) Create

func (inst *Object) Create()

func (*Object) Depth

func (inst *Object) Depth() int

Depth will get the draw order of the object

func (*Object) Destroy

func (inst *Object) Destroy()

func (*Object) Draw

func (inst *Object) Draw()

func (*Object) Free

func (inst *Object) Free()

func (*Object) ImageAngle

func (inst *Object) ImageAngle() float64

func (*Object) ImageAngleRadians

func (inst *Object) ImageAngleRadians() float64

func (*Object) InstanceIndex

func (inst *Object) InstanceIndex() InstanceIndex

func (*Object) ObjectIndex

func (inst *Object) ObjectIndex() ObjectIndex

func (*Object) ObjectName

func (inst *Object) ObjectName() string

func (*Object) RoomInstanceIndex

func (inst *Object) RoomInstanceIndex() RoomInstanceIndex

func (*Object) SetDepth

func (inst *Object) SetDepth(depth int)

SetDepth will change the draw order of the object

func (*Object) SetImageAngle

func (inst *Object) SetImageAngle(angleInDegrees float64)

func (*Object) SetImageAngleRadians

func (inst *Object) SetImageAngleRadians(angleInRadians float64)

func (*Object) SetSolid

func (inst *Object) SetSolid(isSolid bool)

func (*Object) SetSprite

func (inst *Object) SetSprite(spriteIndex sprite.SpriteIndex)

SetSprite will change the image used to draw the object

func (*Object) Solid

func (inst *Object) Solid() bool

func (Object) UnsafeSnapshotMarshalBinary

func (inst Object) UnsafeSnapshotMarshalBinary(buf *bytes.Buffer) error

func (*Object) UnsafeSnapshotUnmarshalBinary

func (inst *Object) UnsafeSnapshotUnmarshalBinary(buf *bytes.Buffer) error

func (*Object) Update

func (inst *Object) Update()

type ObjectIndex

type ObjectIndex int32

func ObjectGetIndex

func ObjectGetIndex(name string) (ObjectIndex, bool)

type ObjectSerialize

type ObjectSerialize struct{}

ObjectSerialize hints to the code generator to generate serialization functions

type ObjectType

type ObjectType interface {
	BaseObject() *Object
	ObjectIndex() ObjectIndex
	ObjectName() string
	Create()
	Destroy()
	Free()
	Update()
	Draw()
}

func InstanceRestore

func InstanceRestore(oldInstanceIndex InstanceIndex, objectIndex ObjectIndex) ObjectType

InstanceRestore re-creates an object using a previously used instance index and object index. This is used to bring old objects back with serialization.

func UnsafeObjectTypeList

func UnsafeObjectTypeList() []ObjectType

UnsafeObjectTypeList provides a copy of the list of object type definition data this is to be used by custom tools like a room editor or similar.

type Rect

type Rect = geom.Rect

type RoomInstanceIndex

type RoomInstanceIndex int32

func RoomInstanceNew

func RoomInstanceNew() RoomInstanceIndex

RoomInstanceNew create a new empty room instance programmatically

func (RoomInstanceIndex) Destroy

func (roomInstanceIndex RoomInstanceIndex) Destroy()

Destroy destroys a room instance

func (RoomInstanceIndex) InstanceChangeRoom added in v0.4.0

func (roomInstanceIndex RoomInstanceIndex) InstanceChangeRoom(baseObj *Object)

func (RoomInstanceIndex) InstanceCreate

func (roomInstanceIndex RoomInstanceIndex) InstanceCreate(x, y float64, objectIndex ObjectIndex) ObjectType

InstanceCreate will create a new instance in the room and call its Create() event.

func (RoomInstanceIndex) SetSize

func (roomInstanceIndex RoomInstanceIndex) SetSize(width, height float64)

func (RoomInstanceIndex) Size

func (roomInstanceIndex RoomInstanceIndex) Size() geom.Vec

Size returns the size of the given room instance

func (RoomInstanceIndex) WithAll

func (roomIndex RoomInstanceIndex) WithAll() []InstanceIndex

WithAll returns a list of instances in the same room as the provided object

type SpriteFrame

type SpriteFrame struct {
	SpriteIndex sprite.SpriteIndex
	ImageIndex  float64
}

type SpriteIndex

type SpriteIndex = sprite.SpriteIndex

func SpriteLoad

func SpriteLoad(index SpriteIndex) SpriteIndex

SpriteLoad will ensure the sprite is loaded

type SpriteState

type SpriteState = sprite.SpriteState

type TestSettings

type TestSettings struct {
	PreUpdate  func()
	PostUpdate func() bool
	// SpeedMultiplier is the number of times Update() methods are called
	// per frame when running tests in headed mode. If set to 0, it will default to 1.
	SpeedMultiplier int
}

type Vec

type Vec = geom.Vec

Directories

Path Synopsis
internal
dt
uid

Jump to

Keyboard shortcuts

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