Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. // Creating variables
  2. var socket = io();
  3. var myX=0 ,myY=0;
  4. socket.on("number", function(data){
  5. console.log(data);
  6. })
  7. socket.on("natisna", function(key){
  8. console.log(key);
  9. })
  10.  
  11. function update() {
  12. /*if(isKeyPressed[68]){
  13. myX++;
  14. }
  15. if(isKeyPressed[65]){
  16. myX--;
  17. }
  18. if(isKeyPressed[83]){
  19. myY++;
  20. }
  21. if(isKeyPressed[87]){
  22. myY--;
  23. }*/
  24. }
  25.  
  26. function draw() {
  27. context.fillRect(myX,myY,30,30)
  28. }
  29.  
  30. function keyup(key) {
  31. socket.emit("key", String.fromCharCode(key));
  32. console.log("Pressed", key);
  33. }
  34. function mouseup() {
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement