MCPcopy
hub / github.com/EngoEngine/engo / Update

Method Update

demos/pong/pong.go:344–368  ·  view source on GitHub ↗
(dt float32)

Source from the content-addressed store, hash-verified

342}
343
344func (c *ControlSystem) Update(dt float32) {
345 for _, e := range c.entities {
346 speed := engo.GameWidth() * dt
347
348 vert := engo.Input.Axis(e.ControlComponent.Scheme)
349 e.SpaceComponent.Position.Y += speed * vert.Value()
350
351 var moveThisOne bool
352 if engo.Input.Mouse.X > engo.WindowWidth()/2 && e.ControlComponent.Scheme == "arrows" {
353 moveThisOne = true
354 } else if engo.Input.Mouse.X < engo.WindowWidth()/2 && e.ControlComponent.Scheme == "wasd" {
355 moveThisOne = true
356 }
357
358 if moveThisOne {
359 e.SpaceComponent.Position.Y = c.mouseTrackerMouse.MouseY - e.SpaceComponent.Height/2
360 }
361
362 if (e.SpaceComponent.Height + e.SpaceComponent.Position.Y) > engo.GameHeight() {
363 e.SpaceComponent.Position.Y = engo.GameHeight() - e.SpaceComponent.Height
364 } else if e.SpaceComponent.Position.Y < 0 {
365 e.SpaceComponent.Position.Y = 0
366 }
367 }
368}
369
370type scoreEntity struct {
371 *ecs.BasicEntity

Callers

nothing calls this directly

Calls 5

GameWidthFunction · 0.92
WindowWidthFunction · 0.92
GameHeightFunction · 0.92
AxisMethod · 0.80
ValueMethod · 0.65

Tested by

no test coverage detected