Skip to content

Commit

Permalink
v0.0.9: Fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkauzh committed Oct 8, 2023
1 parent 925d108 commit 9834371
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/backend/document/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func (c *context) FillRect(x, y, width, height float64) {
c.context.Call("fillRect", x, y, width, height)
}

func (c *context) ClearRect(x, y, width, height float64) {
c.context.Call("clearRect", x, y, width, height)
}

func (c *context) DrawImage(img js.Value, x, y, width, height float64) {
c.context.Call("drawImage", img, x, y, width, height)
}
17 changes: 12 additions & 5 deletions src/webzen/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ package webzen

import (
"syscall/js"
"time"
"time"

"github.com/dimkauzh/webzen/src/backend/document"
"github.com/dimkauzh/webzen/src/backend/window"
"github.com/dimkauzh/webzen/src/webzen/keys"
"github.com/dimkauzh/webzen/src/webzen/keys"
)

var fpsInterval = time.Millisecond * 16

func SetFps(fps int) {
fpsInterval = time.Second / time.Duration(fps)
fpsInterval = time.Second / time.Duration(fps)
}

func clearCanvas() {
canvas := document.GetElementById("canvas")
context := canvas.GetContext("2d")
context.ClearRect(0, 0, canvas.Get("width").Float(), canvas.Get("height").Float())
}

func Init() {
Expand All @@ -38,9 +44,10 @@ func Init() {
return nil
}))

keys.SetupEventListeners()
keys.SetupEventListeners()
}

func Update() {
time.Sleep(time.Millisecond * 16)
time.Sleep(time.Millisecond * 16)
clearCanvas()
}

0 comments on commit 9834371

Please sign in to comment.