(e controlEntity)
| 288 | } |
| 289 | |
| 290 | func 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 | |
| 336 | func (c *ControlSystem) Update(dt float32) { |
| 337 | for _, e := range c.entities { |
no test coverage detected