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

Function Run

engo.go:158–232  ·  view source on GitHub ↗

Run is called to create a window, initialize everything, and start the main loop. Once this function returns, the game window has been closed already. You can supply a lot of options within `RunOptions`, and your starting `Scene` should be defined in `defaultScene`.

(o RunOptions, defaultScene Scene)

Source from the content-addressed store, hash-verified

156// the game window has been closed already. You can supply a lot of options within `RunOptions`, and your starting
157// `Scene` should be defined in `defaultScene`.
158func Run(o RunOptions, defaultScene Scene) {
159 // Setting defaults
160 if o.FPSLimit == 0 {
161 o.FPSLimit = 60
162 }
163
164 if o.MSAA < 0 {
165 panic("MSAA has to be greater or equal to 0")
166 }
167
168 if o.MSAA == 0 {
169 o.MSAA = 1
170 }
171
172 if len(o.AssetsRoot) == 0 {
173 o.AssetsRoot = "assets"
174 }
175
176 if o.Update == nil {
177 o.Update = &ecs.World{}
178 }
179
180 if o.GlobalScale.X <= 0 || o.GlobalScale.Y <= 0 {
181 o.GlobalScale = Point{X: 1, Y: 1}
182 }
183
184 opts = o
185
186 // Create input
187 Input = NewInputManager()
188 if opts.StandardInputs {
189 log.Println("Using standard inputs")
190
191 Input.RegisterButton("jump", KeySpace)
192 Input.RegisterButton("action", KeyEnter)
193
194 Input.RegisterAxis(DefaultHorizontalAxis, AxisKeyPair{KeyA, KeyD}, AxisKeyPair{KeyArrowLeft, KeyArrowRight})
195 Input.RegisterAxis(DefaultVerticalAxis, AxisKeyPair{KeyW, KeyS}, AxisKeyPair{KeyArrowUp, KeyArrowDown})
196
197 Input.RegisterAxis(DefaultMouseXAxis, NewAxisMouse(AxisMouseHori))
198 Input.RegisterAxis(DefaultMouseYAxis, NewAxisMouse(AxisMouseVert))
199 }
200
201 Files.SetRoot(opts.AssetsRoot)
202 currentUpdater = opts.Update
203
204 // And run the game
205 if opts.HeadlessMode {
206 if opts.Width == 0 {
207 opts.Width = headlessWidth
208 }
209 if opts.Height == 0 {
210 opts.Height = headlessHeight
211 }
212 windowWidth = float32(opts.Width)
213 windowHeight = float32(opts.Height)
214 gameWidth = float32(opts.Width)
215 gameHeight = float32(opts.Height)

Callers 15

TestTMXFiletypeLoadFunction · 0.92
TestEveryInterfaceFunction · 0.92
TestShaderCompilationFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92

Calls 10

NewInputManagerFunction · 0.85
NewAxisMouseFunction · 0.85
runHeadlessFunction · 0.85
SetSceneFunction · 0.85
RegisterButtonMethod · 0.80
RegisterAxisMethod · 0.80
CreateWindowFunction · 0.70
DestroyWindowFunction · 0.70
runLoopFunction · 0.70
SetRootMethod · 0.65

Tested by 15

TestTMXFiletypeLoadFunction · 0.74
TestEveryInterfaceFunction · 0.74
TestShaderCompilationFunction · 0.74
TestSetScaleOnResizeFunction · 0.68
TestHeadlessFunction · 0.68
TestScaleOnResizeFunction · 0.68
TestGameWidthHeightFunction · 0.68