gameloop

package module
v0.0.0-...-114b07b Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: Apache-2.0 Imports: 2 Imported by: 6

README

gameloop: Simple Game Loop in Golang

This is a very, very basic game loop... nothing fancy about it.

This implementation is a bare bones variant inspired by kutase's excellent go-gameloop.

If you want to use a more advanced game loop, please consider using kutase's package :)

Example

package main

import (
	"github.com/Flokey82/gameloop"
	"log"
	"time"
)

func main() {
	gameloop.New(time.Second, func(delta float64) {
		log.Println("loop!")
	})
}

Documentation

Overview

Package gameloop implements a very simple game loop. This code is based on: github.com/kutase/go-gameloop

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GameLoop

type GameLoop struct {
	Quit chan bool // channel used for exiting the loop
	// contains filtered or unexported fields
}

GameLoop implements a simple game loop.

func New

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

Create new game loop

func (*GameLoop) Restart

func (g *GameLoop) Restart()

Restart game loop.

func (*GameLoop) Start

func (g *GameLoop) Start()

Start game loop.

func (*GameLoop) Stop

func (g *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