Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions GravityBallCode/GravityBallCode.pde
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//declare variables
float x, y, velX, velY, diam;
float g;

void setup() {
//set size of canvas
size(800, 600);

//initialize variables
g = 0.3;
x = width/2;
y = height/2;
diam = 80;
Expand All @@ -23,6 +25,7 @@ void draw() {
//add velocity to position
x += velX;
y += velY;
velY = velY+g;

//bounce ball if it hits walls
if (x + diam/2 >= width) {
Expand Down