Guest User

Untitled

a guest
Oct 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. var x = 0,
  2. y = 0,
  3. dir = 1, // direction
  4. alt = 1 // altitude
  5.  
  6. function balloon(){
  7. // increment x axis
  8. x = x + (1 * dir);
  9.  
  10. // increment y axis
  11. y = y + (1 * alt);
  12.  
  13. $('.balloon').css({
  14. 'margin-top' : y + 'px',
  15. 'margin-left' : x + 'px'
  16. });
  17.  
  18. if(x == 10){
  19. dir = -1;
  20. } else if(x == 0){
  21. dir = 1;
  22. }
  23.  
  24. if(y == 15){
  25. alt = -1;
  26. } else if(y == 0){
  27. alt = 1;
  28. }
  29.  
  30. setTimeout(balloon, 250);
  31. }
  32.  
  33. balloon();
Add Comment
Please, Sign In to add comment