Skip to content

Latest commit

 

History

History
138 lines (97 loc) · 3.13 KB

README.md

File metadata and controls

138 lines (97 loc) · 3.13 KB

Go-ui

go-ui is a game builder lite using SDL2 veandco. It's not convention to compose a game, just proof of concept today.

The wrapper is implemented with goroutines.

I try to define a good architecture and simple of use. Inspired by Unity 3D (without interface home machine). I try to provide a good tool to creates models scenes / layout and objects.

I would be pleased to talk about that with you on mail: [email protected]

Requirements

See official github to SDL2 binding for Go by veandco.

Installation

To install Golang see getting started

To get SDL2 wrapper see veandco

go get -v github.com/veandco/go-sdl2/{sdl,mix,img,ttf}

To get go-ui:

go get -v github.com/ymohl-cl/go-ui

OSX

Install SDL2:

brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf

Example

You can view implementation example on this project gomoku game

Please, read godoc to know the specifications

package main

import (
	"github.com/ymohl-cl/go-ui/drivers"
	"github.com/ymohl-cl/go-ui/scripter"
	"github.com/ymohl-cl/gomoku/database"
	"github.com/ymohl-cl/gomoku/scenes/gomoku"
	"github.com/ymohl-cl/gomoku/scenes/loader"
	"github.com/ymohl-cl/gomoku/scenes/menu"
)

const (
	windowWidth = 800
	windowHeight = 600

	indexMenu = 1 << iota
	indexGomoku
)

func main() {
	var err error
	var d drivers.VSDL
	var data *database.Data

	// init drivers sdl from go-ui
	if d, err = drivers.Init(windowWidth, windowHeight, "Title of my windows"); err != nil {
		panic(err)
	}
	defer d.Destroy()

	// get your data app from your package, for the example, we used database package
	if data, err = database.Get(); err != nil {
		panic(err)
	}

	// get new scripter application from go-ui
	s := scripter.New()

	// get loader scene from my app
	var loaderScene *loader.Load
	if loaderScene, err = loader.New(nil, d.GetRenderer()); err != nil {
		panic(err)
	}
	// add scene on the scripter (go-ui)
	if err = s.AddLoader(loaderScene); err != nil {
		panic(err)
	}

	// get menu scene from my app
	var menuScene *menu.Menu
	if menuScene, err = menu.New(data, d.GetRenderer()); err != nil {
		panic(err)
	}
	// add scene on the scripter (go-ui)
	if err = s.AddScene(menuScene, indexMenu, true); err != nil {
		panic(err)
	}

	// get gomoku scene from my app
	var gameScene *gomoku.Gomoku
	if gameScene, err = gomoku.New(data, d.GetRenderer()); err != nil {
		panic(err)
	}
	// add scene on the scripter (go-ui)
	if err = s.AddScene(gameScene, indexGomoku, false); err != nil {
		panic(err)
	}

	// run application from go-ui
	s.Run(d)
}

FAQ

Why shaders aren't implemented ?

go-ui is a proof of concept for the moment. This lib provide that which are needest to make a simple project. If you need shaders, please contact us.

How do I contribute ?

Contact me by mail: [email protected]

Acknowledgment

Thanks at veandco for their work.

License

go-ui is BSD 3-clause licensed.

Version

V-0.1.1: implement library go-ui