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

Function getSpeed

demos/isoadventure/iso.go:290–334  ·  view source on GitHub ↗
(e controlEntity)

Source from the content-addressed store, hash-verified

288}
289
290func getSpeed(e controlEntity) (p engo.Point, changed bool) {
291 p.X = engo.Input.Axis(e.ControlComponent.SchemeHoriz).Value()
292 p.Y = engo.Input.Axis(e.ControlComponent.SchemeVert).Value()
293 origX, origY := p.X, p.Y
294
295 if engo.Input.Button(upButton).JustPressed() {
296 p.Y = -1
297 } else if engo.Input.Button(downButton).JustPressed() {
298 p.Y = 1
299 }
300 if engo.Input.Button(leftButton).JustPressed() {
301 p.X = -1
302 } else if engo.Input.Button(rightButton).JustPressed() {
303 p.X = 1
304 }
305
306 if engo.Input.Button(upButton).JustReleased() || engo.Input.Button(downButton).JustReleased() {
307 p.Y = 0
308 changed = true
309 if engo.Input.Button(upButton).Down() {
310 p.Y = -1
311 } else if engo.Input.Button(downButton).Down() {
312 p.Y = 1
313 } else if engo.Input.Button(leftButton).Down() {
314 p.X = -1
315 } else if engo.Input.Button(rightButton).Down() {
316 p.X = 1
317 }
318 }
319 if engo.Input.Button(leftButton).JustReleased() || engo.Input.Button(rightButton).JustReleased() {
320 p.X = 0
321 changed = true
322 if engo.Input.Button(leftButton).Down() {
323 p.X = -1
324 } else if engo.Input.Button(rightButton).Down() {
325 p.X = 1
326 } else if engo.Input.Button(upButton).Down() {
327 p.Y = -1
328 } else if engo.Input.Button(downButton).Down() {
329 p.Y = 1
330 }
331 }
332 changed = changed || p.X != origX || p.Y != origY
333 return
334}
335
336func (c *ControlSystem) Update(dt float32) {
337 for _, e := range c.entities {

Callers 1

UpdateMethod · 0.70

Calls 6

AxisMethod · 0.80
ButtonMethod · 0.80
ValueMethod · 0.65
JustPressedMethod · 0.45
JustReleasedMethod · 0.45
DownMethod · 0.45

Tested by

no test coverage detected