Skip to content

Commit

Permalink
Reintroduce ball changing color
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyhenry committed Mar 6, 2024
1 parent 0e782c6 commit a0fe024
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions anthony_hernandez/end_of_video_code.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@
}
if(ballY < 0) {
ballSpeedY = -ballSpeedY;
console.log("test2")
}
if(ballY > canvas.height) {
ballSpeedY = -ballSpeedY;
console.log("TEst");
}
}

Expand Down Expand Up @@ -163,11 +165,23 @@
canvasContext.fillText(player2Score, canvas.width-100, 100);
}

function generateRandomColorValue()
{
return Math.floor(Math.random() * 256);
}

function colorCircle(centerX, centerY, radius, drawColor) {
canvasContext.fillStyle = drawColor;
canvasContext.beginPath();
canvasContext.arc(centerX, centerY, radius, 0,Math.PI*2,true);
let r = generateRandomColorValue();
let g = generateRandomColorValue();
let b = generateRandomColorValue();
let rgbColor = "rgb(" + r + "," + g + "," + b +")";
console.log(rgbColor);
canvasContext.fillStyle = rgbColor;
canvasContext.fill();
canvasContext.fillStyle = "white";
}

function colorRect(leftX,topY, width,height, drawColor) {
Expand Down

0 comments on commit a0fe024

Please sign in to comment.