Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import mojo
  2.  
  3. Class RocketGame Extends App
  4.  
  5.       Field mx:Float
  6.       Field my:Float
  7.       Field player:Rocket    
  8.       Method OnCreate ()
  9.  
  10.              
  11.              player = New Rocket
  12.  
  13.              
  14.              player.image = LoadImage ("player.png", 1, Image.MidHandle)
  15.  
  16.              
  17.              SetUpdateRate 60
  18.  
  19.       End
  20.  
  21.    
  22.  
  23.       Method OnUpdate ()
  24.  
  25.             mx = MouseX ()
  26.             my = MouseY ()
  27.  
  28.             player.MovePlayer mx, my               
  29.  
  30.       End
  31.  
  32.      
  33.       Method OnRender ()
  34.  
  35.              Cls 32, 64, 128
  36.  
  37.              DrawImage player.image, player.x, player.y, 0, 0.25, 0.25
  38.  
  39.       End
  40.  
  41. End
  42.  
  43. ' Player object definition...
  44.  
  45. Class Rocket
  46.  
  47.       Field image:Image
  48.         Field x:Float  
  49.       Field y:Float
  50.  
  51.       Field mousediv:Float = 12
  52.  
  53.      
  54.       Method MovePlayer (towardsx:Float, towardsy:Float)
  55.  
  56.             Local xdist:Float = towardsx - x           
  57.             Local ydist:Float = towardsy - y           
  58.  
  59.             Local xstep:Float = xdist / mousediv       
  60.             Local ystep:Float = ydist / mousediv       
  61.  
  62.             x = x + xstep
  63.             y = y + ystep
  64.  
  65.       End
  66.  
  67. End
  68.  
  69. ' Here we go!
  70.  
  71. Function Main ()
  72.     New RocketGame 
  73. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement