passing bloob to init and render too

This commit is contained in:
Squishy Bloob 2024-03-23 11:35:37 +00:00
parent 5fbb9b3545
commit cf6d0a9832
2 changed files with 5 additions and 8 deletions

2
go.sum
View File

@ -1,8 +1,6 @@
github.com/askeladdk/aseprite v0.0.4 h1:/k1VTiDkPORnrzonUUV5oXWwdHBoYjIIYJ1K/PupNMU=
github.com/askeladdk/aseprite v0.0.4/go.mod h1:lVW4EwZ7lgQjeHp7MhYj1NII5a/yLYyvAo7COPIn3WY=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/veandco/go-sdl2 v0.4.38 h1:lx8syOA2ccXlgViYkQe2Kn/4xt+p9mdd1Qc/yYMrmSo=
github.com/veandco/go-sdl2 v0.4.38/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
github.com/veandco/go-sdl2 v0.5.0-alpha.4.0.20240323054118-79669ab74d94 h1:7Ay2TWWqg2J4mqPj6vgbg9ib7OzO37szAnQ48MmdD/Y=
github.com/veandco/go-sdl2 v0.5.0-alpha.4.0.20240323054118-79669ab74d94/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 h1:6R2FC06FonbXQ8pK11/PDFY6N6LWlf9KlzibaCapmqc=

11
run.go
View File

@ -8,8 +8,8 @@ import (
)
type Runnable interface {
Init(settings *Settings)
Render(screen *Image)
Init(bloob *Bloob, settings *Settings)
Render(bloob *Bloob, screen *Image)
Update(bloob *Bloob)
}
@ -49,7 +49,7 @@ func Run(game Runnable) {
Cursor: DefaultCursor,
}
game.Init(&settings)
game.Init(&bloob, &settings)
window, _ := sdl.CreateWindow(
settings.Title,
@ -71,8 +71,7 @@ func Run(game Runnable) {
lastSecond := time.Now()
framesSinceLastSecond := 0
targetFPS := 60
frameDuration := time.Second / time.Duration(targetFPS)
frameDuration := time.Second / time.Duration(settings.TargetFps)
lastFrame := lastSecond
running := true
@ -99,7 +98,7 @@ func Run(game Runnable) {
delta2 := now.Sub(lastFrame)
if delta2 >= frameDuration {
game.Update(&bloob)
game.Render(screen)
game.Render(&bloob, screen)
if bloob.Cursor != nil {
screen.Draw(bloob.Cursor, bloob.MousePos)
}