Felanpro

Cat & Mouse. (2 player game)

Feb 17th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="http://koda.nu/simple.js">
  2.  
  3.   var cat = {x: 100, y: 100, speed :10};
  4.  
  5.   function update() {
  6.    clearScreen();
  7.    hideMouse();
  8.    
  9.    if(keyboard.a) {cat.x -= cat.speed;}
  10.     if(keyboard.d) {cat.x += cat.speed;}
  11.     if(keyboard.w) {cat.y -= cat.speed;}
  12.     if(keyboard.s) {cat.y += cat.speed;}
  13.    
  14.     circle(cat.x, cat.y, 20, "black");
  15.     circle(mouse.x, mouse.y, 20, "grey");
  16.    
  17.     if(distance(cat.x, cat.y, mouse.x, mouse.y) < 40)
  18.     {
  19.     stopUpdate();
  20.     showMouse();
  21.     text(mouse.x, mouse.y, 50, "The cat wins!", "green");
  22.     }
  23.   }
  24.  
  25. </script>
Advertisement
Add Comment
Please, Sign In to add comment