ligge

package module
v0.0.0-...-4cba025 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: BSD-3-Clause, MIT Imports: 8 Imported by: 0

README

Lietu's Go Game Engine

This engine gives you stuff. You can totally wotally write games on Go now. Yay!

It's got a license. Read it. It's in LICENSE.md.

Getting SDL stuff compiled

First time running anything the SDL libraries will have to be compiled, and they need to locate the SDL include and lib directories.

On *nix

If using *nix you'll probably want to install SDL development packages using whatever package manager you have, and then you'll need to set up the CGO_* environment variables to point to the SDL directories.

CGO_CFLAGS="-I/path/to/sdl/include"
CGO_LDFLAGS="-L/path/to/sdl/lib"

You can figure out what these are with e.g.:

find / -wholename "*/SDL2/SDL.h"
On Windows

You'll likely want to get msys2, install GCC and the SDL libraries on that.

Start up the MSYS2 Shell, and run:

pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_ttf

Then set the environment variables for Go to find the SDL stuff.

set CGO_CFLAGS=-Ic:/msys64/mingw64/include
set CGO_LDFLAGS=-Lc:/msys64/mingw64/lib

Financial support

This project has been made possible thanks to Cocreators and Lietu. You can help us continue our open source work by supporting us on Buy me a coffee.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AUDIO_ASSETS = "../assets/audio"
View Source
var AUDIO_CATEGORIES map[string]int = map[string]int{}
View Source
var IMAGE_ASSETS = "../assets/images"

Functions

func DrawText

func DrawText(fontName string, text string, x int32, y int32, color sdl.Color, renderer *sdl.Renderer)

func FloatToVolume

func FloatToVolume(f float32) int

func GetFont

func GetFont(name string) *ttf.Font

func GetImageTexture

func GetImageTexture(path string) *sdl.Texture

func InitializeClientComponents

func InitializeClientComponents()

func LoadFont

func LoadFont(name string, size int, path string) *ttf.Font

func PlayMusic

func PlayMusic(path string)

func RegisterAudioCategory

func RegisterAudioCategory(name string, volume int)

func RegisterFont

func RegisterFont(name string, size int, path string)

func RegisterGuiComponent

func RegisterGuiComponent(init func())

func RegisterScene

func RegisterScene(name string, scene Scene)

func RunClient

func RunClient(onGUIReady func())

func RunGUI

func RunGUI(onGUIReady func(), done chan bool, input *Input) bool

func UninitializeClientComponents

func UninitializeClientComponents()

func UnloadFonts

func UnloadFonts()

Types

type BaseScene

type BaseScene struct {
	Initialized   bool
	ComponentList []SceneComponent
}

func NewBaseScene

func NewBaseScene() *BaseScene

func (*BaseScene) AddComponent

func (b *BaseScene) AddComponent(component SceneComponent)

func (*BaseScene) InitComponents

func (b *BaseScene) InitComponents()

func (*BaseScene) KeyDown

func (b *BaseScene) KeyDown(code sdl.Keycode)

func (*BaseScene) KeyPress

func (b *BaseScene) KeyPress(code sdl.Keycode)

func (*BaseScene) KeyUp

func (b *BaseScene) KeyUp(code sdl.Keycode)

func (*BaseScene) RenderComponents

func (b *BaseScene) RenderComponents()

type BaseSceneComponent

type BaseSceneComponent struct {
}

func NewBaseSceneComponent

func NewBaseSceneComponent() BaseSceneComponent

func (*BaseSceneComponent) KeyDown

func (b *BaseSceneComponent) KeyDown(code sdl.Keycode)

func (*BaseSceneComponent) KeyPress

func (b *BaseSceneComponent) KeyPress(code sdl.Keycode)

func (*BaseSceneComponent) KeyUp

func (b *BaseSceneComponent) KeyUp(code sdl.Keycode)

type GUI

type GUI struct {
	Running  bool
	Events   chan sdl.Event
	Scene    Scene
	Window   *sdl.Window
	Renderer *sdl.Renderer
	Input    *Input
	Reload   bool
	Width    int32
	Height   int32
	// contains filtered or unexported fields
}
var Gui *GUI = nil

func NewGUI

func NewGUI(input *Input) *GUI

func (*GUI) Destroy

func (g *GUI) Destroy()

func (*GUI) DrawText

func (g *GUI) DrawText(fontName string, text string, x int32, y int32, color sdl.Color)

func (*GUI) GetSize

func (g *GUI) GetSize() (int32, int32)

func (*GUI) ProcessEvents

func (g *GUI) ProcessEvents()

func (*GUI) RenderScene

func (g *GUI) RenderScene()

func (*GUI) Run

func (g *GUI) Run(done chan bool)

func (*GUI) SetFrameStart

func (g *GUI) SetFrameStart()

func (*GUI) SetScene

func (g *GUI) SetScene(name string)

func (*GUI) Stop

func (g *GUI) Stop()

func (*GUI) WaitAndSync

func (g *GUI) WaitAndSync()

type Image

type Image struct {
	Width   int32
	Height  int32
	Texture *sdl.Texture
	Rect    *sdl.Rect
}

func GetImage

func GetImage(path string) *Image

func ImageFromPath

func ImageFromPath(path string) *Image

func ImageFromTexture

func ImageFromTexture(texture *sdl.Texture) *Image

func NewImage

func NewImage(w int32, h int32, texture *sdl.Texture) *Image

func (*Image) Render

func (i *Image) Render(x int32, y int32)

type Input

type Input struct {
	LastKeyPress sdl.Keycode
}

func NewInput

func NewInput() *Input

func (*Input) ProcessEvent

func (i *Input) ProcessEvent(event sdl.Event)

func (*Input) RecordKeyPress

func (i *Input) RecordKeyPress(event *sdl.KeyUpEvent)

func (*Input) Run

func (i *Input) Run()

type Scene

type Scene interface {
	Activate()
	Render()
	KeyDown(sdl.Keycode)
	KeyUp(sdl.Keycode)
	KeyPress(sdl.Keycode)
}

func GetScene

func GetScene(name string) Scene

type SceneComponent

type SceneComponent interface {
	Init()
	Render()
	KeyDown(code sdl.Keycode)
	KeyUp(code sdl.Keycode)
	KeyPress(code sdl.Keycode)
}

type Sound

type Sound struct {
	Category string
	Chunk    *mix.Chunk
}

func NewSound

func NewSound(category string, path string) *Sound

func (*Sound) Play

func (a *Sound) Play()

type Text

type Text struct {
	Image *Image
}

func CreateText

func CreateText(fontName string, text string, color sdl.Color) *Text

func NewText

func NewText(image *Image) *Text

func (*Text) Render

func (t *Text) Render(x int32, y int32)

Jump to

Keyboard shortcuts

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