SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Beginning the set-up
  2. var alwaysBackground = function() {
  3.     background(255, 255, 255);
  4.     stroke(0, 0, 255);
  5.     strokeWeight(5);
  6.     rect(0,0,399,399,75);
  7.     strokeWeight(2);
  8.     stroke(0, 0, 0);
  9.     rect(0,125,10,150);
  10.     rect(390,125,10,150);
  11.     fill(255, 255, 255);
  12.     strokeWeight(2);
  13.     var centerCircle = ellipse(200,200,100,100);
  14.     fill(255, 41, 41);
  15.     stroke(0, 0, 0);
  16.     var centerLine = rect(195,2,10,396);
  17.     fill(150, 150, 255);
  18.     var offsideLLine = rect(85,2,10,396);
  19.     fill(150, 150, 255);
  20.     var offsideRLine = rect(305,2,10,396);
  21.     fill(255, 255, 255);
  22.     var smallCircleInCenter = ellipse(200,200,10,10);
  23.     fill(224, 101, 101);
  24.     var goalLCrease = arc(10,200, 60,83,-88,88);
  25.     var goalRCrease = arc(390,200, 60,83,90,270);
  26.     //Until this line, I was setting the stage for the rest of the program//
  27. };
  28. var player1Score = 0;
  29. var player1XPos = 20;
  30. var player1YPos = 140;
  31. var player1Width = 50;
  32. var player1Height = 100;
  33. var player2Score = 0;
  34. var player2XPos = 335;
  35. var player2YPos = 140;
  36. var player2Width = 50;
  37. var player2Height = 100;
  38. var speed = 2.25;
  39. var puckX = 200;
  40. var puckY = 200;
  41. var puckXMove = random(-4,4);
  42. var puckYMove = random(-4,4);
  43. //I can use the following function to draw my players and make them move//
  44. var draw = function() {
  45.     alwaysBackground();
  46.     fill(0, 0, 0);
  47.     var puck = ellipse(puckX,puckY,20,20);
  48.     puckX = puckX + puckXMove;
  49.     puckY = puckY + puckYMove;
  50.     if (10 > puckX) {
  51.         if (puckX > 125 && puckX < 275) {
  52.         }
  53.         puckXMove = puckXMove * -1;
  54.     }
  55.     if (10 > puckY) {
  56.         puckYMove = puckYMove * -1;
  57.     }
  58.     if (puckX > 390) {
  59.         puckXMove = puckXMove * -1;
  60.     }
  61.     if (puckY > 390) {
  62.         puckYMove = puckYMove * -1;
  63.     }
  64.     var player1 = image(getImage("cute/CharacterBoy"),player1XPos,player1YPos,player1Width       ,player1Height);
  65.     fill(255, 255, 255);
  66.     if (keyIsPressed && keyCode === UP && player1YPos > -65 - player1YPos) {
  67.         player1YPos = player1YPos - 1 * speed;
  68.     }
  69.     else if (keyIsPressed && keyCode === DOWN && player1YPos < 625 - player1YPos) {
  70.        player1YPos = player1YPos + 1 * speed;
  71.     }
  72.     else if (keyIsPressed && keyCode === LEFT && player1XPos > -10 - player1XPos) {
  73.         player1XPos = player1XPos - 1 * speed;
  74.     }
  75.     else if (keyIsPressed && keyCode === RIGHT && player1XPos < 700 - player1XPos) {
  76.        player1XPos = player1XPos + 1 * speed;
  77.     }
  78.     var player2 = image(getImage("cute/CharacterPrincessGirl"),player2XPos,player2YPos           ,player2Width,player2Height);
  79.    
  80.     //player2XPos = puckX - 1;
  81.     player2YPos = puckY - 75;
  82.     if (puckX < 10 && puckY > 125 && puckY < 275) {
  83.         puckX = 200;
  84.         puckY = 200;
  85.     }
  86.     if (puckX > 390 && puckY > 125 && puckY < 275) {
  87.         puckX = 200;
  88.         puckY = 200;
  89.     }
  90.     if (puckX < player1XPos + player1Width && puckY > player1YPos && puckY < player1YPos + player1Height) {
  91.         puckXMove = puckXMove * -1;
  92.     }
  93.     if (puckX > player2XPos + player2Width && puckY < player2YPos && puckY < player2YPos + player2Height) {
  94.         puckXMove = puckXMove * -1;
  95.     }
  96. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top