| 101 | func (w *WhoopSystem) Remove(basic ecs.BasicEntity) {} |
| 102 | |
| 103 | func (w *WhoopSystem) Update(dt float32) { |
| 104 | if btn := engo.Input.Button("pause"); btn.JustPressed() { |
| 105 | if w.paused { |
| 106 | w.aSys.Restart() |
| 107 | w.paused = false |
| 108 | } else { |
| 109 | w.aSys.Pause() |
| 110 | w.paused = true |
| 111 | } |
| 112 | } |
| 113 | if w.paused { |
| 114 | return |
| 115 | } |
| 116 | if btn := engo.Input.Button("whoop"); btn.JustPressed() { |
| 117 | if !w.player.IsPlaying() { |
| 118 | w.player.Rewind() |
| 119 | w.player.Play() |
| 120 | } |
| 121 | } |
| 122 | d := float64(dt * 0.1) |
| 123 | volume := w.player.GetVolume() |
| 124 | if w.goingUp { |
| 125 | volume += d |
| 126 | } else { |
| 127 | volume -= d |
| 128 | } |
| 129 | |
| 130 | if volume < 0 { |
| 131 | w.player.SetVolume(0.0) |
| 132 | w.goingUp = true |
| 133 | } else if volume > 1 { |
| 134 | w.player.SetVolume(1.0) |
| 135 | w.goingUp = false |
| 136 | } else { |
| 137 | w.player.SetVolume(volume) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | func main() { |
| 142 | opts := engo.RunOptions{ |