Documentation ¶
Index ¶
- Constants
- Variables
- func ClearScreen(c Color)
- func DrawArc(p Point, d int, start, sweep Angle, s Style)
- func DrawCircle(p Point, d int, s Style)
- func DrawEllipse(p Point, b Size, s Style)
- func DrawImage(i Image, p Point)
- func DrawLine(a, b Point, s LineStyle)
- func DrawPoint(p Point, c Color)
- func DrawRect(p Point, b Size, s Style)
- func DrawRoundedRect(p Point, b, c Size, s Style)
- func DrawSector(p Point, d int, start, sweep Angle, s Style)
- func DrawSubImage(i SubImage, p Point)
- func DrawText(t string, f Font, p Point, c Color)
- func DrawTriangle(a, b, c Point, s Style)
- func DumpDataFile(path string, raw []byte)
- func GetRandom() uint32
- func LogDebug(t string)
- func LogError(t string)
- func Quit()
- func RemoveDataFile(path string)
- func Restart()
- func SetColor(c Color, v RGB)
- func SetSeed(seed uint32)
- type Angle
- type Buttons
- type Color
- type DPad
- type File
- type Font
- type Image
- type LineStyle
- type Pad
- type Peer
- type Peers
- type Point
- type RGB
- type Size
- type Style
- type SubImage
Constants ¶
const ( // The screen width in pixels. Width = 240 // The screen height in pixels. Height = 160 )
const ( // The lowest possible value for [Pad.X]. PadMinX = -1000 // The lowest possible value for [Pad.Y]. PadMinY = -1000 // The highest possible value for [Pad.X]. PadMaxX = 1000 // The highest possible value for [Pad.Y]. PadMaxY = 1000 )
Variables ¶
var ( // Callback to be called once when the app starts. // // Called after memory is initialized and host functions are registered // but before any other callback. Boot func() // Callback to be called on every update. // // Don't use it to draw on the screen, use [Render] instead. Update func() // Callback to be called before rendering the frame. // // Don't use it to update the state, use [Update] instead. Render func() // Callback to be called before rendering a horizontal line on the screen. // // Accepts the index of the line about to be rendered // and returns the index of the line for which it should be called next time. // Use it to update color palette to support more than 4 colors per frame. RenderLine func(int) int // Callback to be called when a cheat code is sent from firefly CLI. // // Accepts the command index and value and returns a response to show in CLI. Cheat func(int, int) int )
Functions ¶
func DrawRoundedRect ¶
Draw a rectangle with rounded corners.
func DrawSubImage ¶
Draw a subregion of an image.
Most often used to draw a sprite from a sprite atlas.
func DrawText ¶
Render text using the given font.
Unlike in the other drawing functions, here Point points not to the top-left corner but to the baseline start position.
Types ¶
type Angle ¶
type Angle struct {
// contains filtered or unexported fields
}
An angle between two vectors.
Used by DrawArc and DrawSector. Constructed by [Dagrees] and Radians.
type Buttons ¶
type Buttons struct { // If "a" button is pressed. A bool // If "b" button is pressed. B bool // If "x" button is pressed. X bool // If "y" button is pressed. Y bool // If "menu" button is pressed. // // For singleplayer games, the button press is always intercepted by the runtime. Menu bool }
State of the buttons.
func ReadButtons ¶
Get the currently pressed buttons.
func (Buttons) JustPressed ¶
Given the old state, get buttons that were not pressed but are pressed now.
func (Buttons) JustReleased ¶
Given the old state, get buttons that were pressed but aren't pressed now.
type Color ¶
type Color uint8
A pointer to a color in the color palette.
const ( // No color (100% transparency). ColorNone Color = 0 // Black color: #1A1C2C. ColorBlack Color = 1 // Purple color: #5D275D. ColorPurple Color = 2 // Red color: #B13E53. ColorRed Color = 3 // Orange color: #EF7D57. ColorOrange Color = 4 // Yellow color: #FFCD75. ColorYellow Color = 5 // Light green color: #A7F070. ColorLightGreen Color = 6 // Green color: #38B764. ColorGreen Color = 7 // Dark green color: #257179. ColorDarkGreen Color = 8 // Dark blue color: #29366F. ColorDarkBlue Color = 9 // Blue color: #3B5DC9. ColorBlue Color = 10 // Light blue color: #41A6F6. ColorLightBlue Color = 11 // Cyan color: #73EFF7. ColorCyan Color = 12 // White color: #F4F4F4. ColorWhite Color = 13 // Light gray color: #94B0C2. ColorLightGray Color = 14 // Gray color: #566C86. ColorGray Color = 15 // Dark gray color: #333C57. ColorDarkGray Color = 16 )
type DPad ¶
func (DPad) JustPressed ¶
Given the old state, get directions that were not pressed but are pressed now.
func (DPad) JustReleased ¶
Given the old state, get directions that were pressed but aren't pressed now.
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
A loaded font file.
Can be loaded using LoadROMFile.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
A loaded image file.
Can be loaded using LoadROMFile.
type Pad ¶
A finger position on the touch pad.
Both X and Y are somewhere the range between -1000 and 1000 (both ends included). The 1000 X is on the right, the 1000 Y is on the top.
func (Pad) Azimuth ¶
The angle of the polar coordinate of the touch point.
type Peer ¶ added in v0.3.0
type Peer uint8
The peer ID.
const Combined Peer = 0xFF
Peer value that can be passed to ReadPad and ReadButtons to get the combined input of all peers.
Useful for single-player games that want in multi-player to handle inputs from all devices as one input.
type Peers ¶ added in v0.3.0
type Peers uint32
The map of peers online.
func GetPeers ¶ added in v0.3.0
func GetPeers() Peers
Get the list of peers that are currently online.
Includes the local device.
It can be used to detect if multiplayer is active: if there is more than 1 peer, you're playing with friends.
type Point ¶
A point on the screen.
Typically, the upper-left corner of a bounding box of a shape.
func (Point) ComponentMax ¶
Set both X and Y to their maximum in the two given points.
func (Point) ComponentMin ¶
Set both X and Y to their minimum in the two given points.
type Size ¶
type Size struct { // W is the width of the bounding box. W int // H is the height of the bounding box. H int }
Size of a bounding box for a shape.
The width and height must be positive.
func (Size) ComponentMax ¶
Set both W and H to their maximum in the two given sizes.
func (Size) ComponentMin ¶
Set both W and H to their minimum in the two given sizes.