diff --git a/cursor.png b/cursor.png new file mode 100644 index 0000000..fcb13c2 Binary files /dev/null and b/cursor.png differ diff --git a/run.go b/run.go index bcc6dec..0050430 100644 --- a/run.go +++ b/run.go @@ -1,6 +1,7 @@ package bloob import ( + _ "embed" "fmt" "github.com/veandco/go-sdl2/sdl" "time" @@ -21,8 +22,14 @@ type Settings struct { type Bloob struct { MousePos Vec2i + Cursor *Image } +var DefaultCursor *Image + +//go:embed "cursor.png" +var defaultCursorBytes []byte + func Run(game Runnable) { _ = sdl.Init(sdl.INIT_EVERYTHING) defer sdl.Quit() @@ -34,7 +41,13 @@ func Run(game Runnable) { Title: "Blooblib", } - bloob := Bloob{} + if DefaultCursor == nil { + DefaultCursor = LoadImageBytes(defaultCursorBytes) + } + + bloob := Bloob{ + Cursor: DefaultCursor, + } game.Init(&settings) @@ -51,6 +64,8 @@ func Run(game Runnable) { screen := NewImage(settings.WindowSize) screen.Alpha = false + sdl.ShowCursor(sdl.DISABLE) + _ = window.UpdateSurface() lastSecond := time.Now() @@ -85,6 +100,9 @@ func Run(game Runnable) { if delta2 >= frameDuration { game.Update(&bloob) game.Render(screen) + if bloob.Cursor != nil { + screen.Draw(bloob.Cursor, bloob.MousePos) + } windowImage.DrawUpscale(screen) framesSinceLastSecond += 1 lastFrame = lastFrame.Add(frameDuration)