From e459b4c28cd3ac3da3721074a0f814520391e1c1 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Wed, 10 Apr 2019 02:21:20 +0800 Subject: [PATCH] Rate limit to 60FPS --- ui/director.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/director.go b/ui/director.go index 1408f974..8d5d0a55 100644 --- a/ui/director.go +++ b/ui/director.go @@ -23,6 +23,8 @@ type Director struct { roomID string } +const FPS = 60 + func NewDirector(roomID string, imageChannel chan *image.RGBA, inputChannel chan int) *Director { // func NewDirector(audio *Audio, imageChannel chan *image.RGBA, inputChannel chan int) *Director { director := Director{} @@ -61,7 +63,8 @@ func (d *Director) Start(paths []string) { } func (d *Director) Run() { - for { + c := time.Tick(time.Second / FPS) + for range c { // quit game // TODO: Check if noone using