-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
84 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Any helper functions go here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Any objects types go here | ||
|
||
class Ball { | ||
constructor(x, y, size = 30) { | ||
this.x = x; | ||
this.y = y; | ||
this.size = size; | ||
this.vx = 3; | ||
this.vy = 2; | ||
} | ||
|
||
update() { | ||
// Update position | ||
this.x += this.vx; | ||
this.y += this.vy; | ||
|
||
// Bounce off walls | ||
if (this.x + this.size / 2 > width || this.x - this.size / 2 < 0) | ||
this.vx *= -1; | ||
if (this.y + this.size / 2 > height || this.y - this.size / 2 < 0) | ||
this.vy *= -1; | ||
} | ||
|
||
draw() { | ||
fill(255); | ||
noStroke(); | ||
circle(this.x, this.y, this.size); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
let ball; | ||
|
||
function setup() { | ||
createCanvas(windowWidth, windowHeight); | ||
// Create ball in middle of screen | ||
ball = new Ball(width / 2, height / 2); | ||
} | ||
|
||
function windowResized() { | ||
resizeCanvas(windowWidth, windowHeight); | ||
} | ||
|
||
function draw() { | ||
background(0); | ||
ball.update(); | ||
ball.draw(); | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.