Add Initial commit

This commit is contained in:
Lev
2021-04-17 19:57:02 -05:00
parent fda9a75922
commit cacc558bb8
5 changed files with 16008 additions and 0 deletions

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>randomDot</title>
<script src="libraries/p5.min.js" type="text/javascript"></script>
<script src="libraries/p5.dom.js" type="text/javascript"></script>
<script src="libraries/p5.sound.js" type="text/javascript"></script>
<script src="sketch.js" type="text/javascript"></script>
<style> body {padding: 0; margin: 0;} canvas {vertical-align: top;} </style>
</head>
<body>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
let ball;
function setup() {
createCanvas(900, 600);
background(0);
ball = new Ball(width, height);
}
function draw()
{
background('red');
ball.run();
}
class Ball
{
constructor(w, h)
{
this.speedX = random(-5, 5);
this.speedY = random(-5, 5);
this.locX = random(w);
this.locY = random(h);
this.maxW = w;
this.maxH = h;
}
run()
{
this.bounce();
this.draw();
this.move();
}
draw()
{
fill(125);
ellipse(this.locX, this.locY, 40, 40);
}
move()
{
this.locX += this.speedX;
this.locY += this.speedY;
}
bounce()
{
if(this.locX < 0 || this.locX > this.maxW) this.speedX *= -1;
if(this.locY < 0 || this.locY > this.maxH) this.speedY *= -1;
}
}