Skip to content

Commit 38b5a13

Browse files
committed
fix ebiten example
1 parent 3915526 commit 38b5a13

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

examples/ebitengine/game.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type RenderSystem interface {
1919

2020
// Game is the main game type.
2121
type Game struct {
22-
World ecs.World // The ECS world as data store.
22+
World *ecs.World // The ECS world as data store.
2323
LogicSystems []LogicSystem // Systems for game logic.
2424
RenderSystems []RenderSystem // Systems for rendering.
2525
}
@@ -32,7 +32,7 @@ func NewGame() *Game {
3232
}
3333

3434
// Add "global" resources (like game settings, a grid, ...).
35-
ecs.AddResource(&g.World, &Settings{
35+
ecs.AddResource(g.World, &Settings{
3636
ScreenWidth: 640,
3737
ScreenHeight: 480,
3838
Scale: 64,
@@ -54,11 +54,11 @@ func NewGame() *Game {
5454

5555
// Initialize logic systems.
5656
for _, s := range g.LogicSystems {
57-
s.Initialize(&g.World)
57+
s.Initialize(g.World)
5858
}
5959
// Initialize render systems.
6060
for _, s := range g.RenderSystems {
61-
s.Initialize(&g.World)
61+
s.Initialize(g.World)
6262
}
6363

6464
return &g
@@ -68,7 +68,7 @@ func NewGame() *Game {
6868
func (g *Game) Update() error {
6969
// Update all logic systems.
7070
for _, s := range g.LogicSystems {
71-
s.Update(&g.World)
71+
s.Update(g.World)
7272
}
7373
return nil
7474
}
@@ -77,12 +77,12 @@ func (g *Game) Update() error {
7777
func (g *Game) Draw(screen *ebiten.Image) {
7878
// Update/draw all render systems.
7979
for _, s := range g.RenderSystems {
80-
s.Draw(&g.World, screen)
80+
s.Draw(g.World, screen)
8181
}
8282
}
8383

8484
// Layout the game's screen.
8585
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
86-
set := ecs.GetResource[Settings](&g.World)
86+
set := ecs.GetResource[Settings](g.World)
8787
return int(set.ScreenWidth), int(set.ScreenHeight)
8888
}

examples/ebitengine/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func main() {
2222
game := NewGame()
2323

2424
// Create a window.
25-
s := ecs.GetResource[Settings](&game.World)
25+
s := ecs.GetResource[Settings](game.World)
2626
ebiten.SetWindowSize(int(s.ScreenWidth), int(s.ScreenHeight))
2727
ebiten.SetWindowTitle("Stars!")
2828

0 commit comments

Comments
 (0)