gameLoop

package module
v0.0.0-...-c298c6a Latest Latest
Warning

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

Go to latest
Published: May 19, 2017 License: MIT Imports: 2 Imported by: 3

README

Golang Game Loop

GoDoc

🎮 🔄 Golang Game Loop implementation

Install

go get github.com/kutase/go-gameloop

Example

package main

import (
	"github.com/kutase/go-gameloop"
	"log"
)

func main() {
	gl := gameLoop.New(10, func(delta float64) {
		log.Println("tick:", delta)
	})

	gl.Start()

	// Stop Game Loop:
	// gl.Stop()

	// Don't stop main goroutine
	for {}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GameLoop

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

func New

func New(tickRate time.Duration, onUpdate func(float64)) *GameLoop

Create new game loop

func (*GameLoop) GetTickRate

func (gl *GameLoop) GetTickRate() time.Duration

func (*GameLoop) Restart

func (gl *GameLoop) Restart()

Restart game loop

func (*GameLoop) SetOnUpdate

func (gl *GameLoop) SetOnUpdate(onUpdate func(float64))

Set onUpdate func

func (*GameLoop) SetTickRate

func (gl *GameLoop) SetTickRate(tickRate time.Duration)

Set tickRate and restart game loop

func (*GameLoop) Start

func (gl *GameLoop) Start()

Start game loop

func (*GameLoop) Stop

func (gl *GameLoop) Stop()

Stop game loop

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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