MCPcopy Index your code
hub / github.com/EngoEngine/engo / Setup

Method Setup

demos/hide/hide.go:30–67  ·  view source on GitHub ↗
(u engo.Updater)

Source from the content-addressed store, hash-verified

28}
29
30func (*DefaultScene) Setup(u engo.Updater) {
31 w, _ := u.(*ecs.World)
32
33 common.SetBackground(color.White)
34
35 w.AddSystem(&common.RenderSystem{})
36 w.AddSystem(&HideSystem{})
37
38 // Retrieve a texture
39 texture, err := common.LoadedSprite("rock.png")
40 if err != nil {
41 log.Println(err)
42 }
43
44 // Create an entity
45 rock := Rock{BasicEntity: ecs.NewBasic()}
46
47 // Initialize the components, set scale to 8x
48 rock.RenderComponent = common.RenderComponent{
49 Drawable: texture,
50 Scale: engo.Point{8, 8},
51 }
52 rock.SpaceComponent = common.SpaceComponent{
53 Position: engo.Point{0, 0},
54 Width: texture.Width() * rock.RenderComponent.Scale.X,
55 Height: texture.Height() * rock.RenderComponent.Scale.Y,
56 }
57
58 // Add it to appropriate systems
59 for _, system := range w.Systems() {
60 switch sys := system.(type) {
61 case *common.RenderSystem:
62 sys.Add(&rock.BasicEntity, &rock.RenderComponent, &rock.SpaceComponent)
63 case *HideSystem:
64 sys.Add(&rock.BasicEntity, &rock.RenderComponent)
65 }
66 }
67}
68
69func (*DefaultScene) Type() string { return "GameWorld" }
70

Callers

nothing calls this directly

Calls 5

SetBackgroundFunction · 0.92
LoadedSpriteFunction · 0.92
WidthMethod · 0.65
HeightMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected