Skip to content

Commit

Permalink
Last changes on 24 April 2011
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhkm authored Aug 11, 2018
1 parent 42718a8 commit ed18473
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions trapped/trapped.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
float x = 200;
float y = 10;

float speedX = 2.5;
float speedY = 1;
//float gravity = 0.1;

void setup() {
size(250,250);
}

void draw() {
background(255);
noStroke();
fill(0);
rectMode(CENTER);

rect(x,y,20,20);

x = speedX + x;
y = speedY + y;

if(y <= 10) {
speedX = speedX;
speedY = speedY * -1;
}
if(y >=240) {
speedX = speedX;
speedY = speedY * -1;
}
if(x <=10) {
speedX = speedX * -1;
speedY = speedY;
}
if(x >=240) {
speedX = speedX * -1;
speedY = speedY;
}
}

0 comments on commit ed18473

Please sign in to comment.