Guest User

Untitled

a guest
May 15th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stop();
  2. var points = 0
  3. var speed = 10
  4. var gameOver = true
  5.  
  6. dir = "Right"
  7.  
  8. updatePlayer = function()
  9. {
  10.     player._x = _xmouse
  11.     player._y = _ymouse
  12.    
  13.     if(_xmouse > 650){
  14.         player._x = 650
  15.     }
  16.    
  17.     if(_xmouse < 0){
  18.         player._x = 0
  19.     }
  20.    
  21.     if(_ymouse > 450){
  22.         player._y = 450
  23.     }
  24.    
  25.     if(_ymouse < 0){
  26.         player._y = 0
  27.     }
  28. }
  29.  
  30. checkCollisions = function()
  31. {
  32.     if(shroomy.hitF(player))
  33.     {
  34.         cd._visible = true
  35.         nextFrame()
  36.         gameOver = true
  37.     }else{
  38.         points++
  39.     }
  40. }
  41.  
  42. updateShroomy = function()
  43. {
  44.     dx = shroomy._x - _xmouse
  45.     dy = shroomy._y - _ymouse
  46.     theta = Math.atan2(dy,dx)
  47.    
  48.     shroomy._x -=  Math.cos(theta) * speed
  49.     shroomy._y -= Math.sin(theta) * speed
  50.     speed += 0.05
  51.    
  52.    
  53.     if((dx<10)&&(dir != "Left")){
  54.         dir = "Left"
  55.         shroomy._xscale *= -1
  56.     }
  57.    
  58.     if((dx>10)&&(dir != "Right")){
  59.         dir = "Right"
  60.         shroomy._xscale *= -1
  61.     }
  62. }
  63.  
  64. onEnterFrame = function()
  65. {
  66.     if(cd._visible == true){
  67.         if(player.hitTest(_xmouse, _ymouse)){
  68.             Mouse.hide();
  69.             cd.play();
  70.         }
  71.     }
  72.     if(gameOver == false){
  73.         updatePlayer();
  74.         updateShroomy();
  75.         checkCollisions();
  76.     }
  77. }
Add Comment
Please, Sign In to add comment