Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. def changeThings() = {
  2.  
  3. /*
  4. * pitää huolen siitä että ei kasaannu liikaa täpliä.
  5. * katso removeDot. dequeueAll poistaa kaikki, jotka palauttavat arvon true
  6. */
  7.  
  8. dots.dequeueAll(removeDot)
  9.  
  10. if (waitTime == waitHolder) {
  11. var deg = 0
  12. while (deg <= 360) { // muutettu while loopiksi optimisaation vuoksi. for loop toiminnallisesti sama
  13. dots.enqueue(new Dot(deg, circleRadius, circlePos.x.toInt, circlePos.y.toInt))
  14. deg += rotation // askeltaa rotationin verran
  15. }
  16.  
  17. circlePos = new Pos(circlePos.x + cos(math.random*2*Pi)*5 , circlePos.y + sin(math.random*2*Pi)*5)
  18.  
  19. waitTime = 0
  20. } else waitTime += 1
  21.  
  22. dots.foreach(_.move)
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement