Open chasestarr opened 9 years ago
int xEllipse=450;
float yEllipse=79;
float speed=0;
float gravity=0.98;
void setup(){
size(900,1100);
}
void draw(){
background(16,166,144);
fill(192,248,98);
ellipse(xEllipse,yEllipse,150,150);
yEllipse=yEllipse+speed;
speed=speed+gravity;
if(yEllipse>1025){
speed=speed*-0.9;
}
}
float ellipseX=200;
float ellipseY=200;
float speed=0;
float gravity=0.98;
float halfW=width/2;
float halfH=height/2;
float speedTwo=5;
void setup(){
size(1000,1000);
}
void draw(){
background(190,190,255);
fill(0,0,255);
ellipse(ellipseX,ellipseY,100,100);
ellipseY=ellipseY+speed;
speed=speed+gravity;
if(ellipseY>=949){
speed=speed*-0.7;
}
ellipseX=ellipseX+speedTwo;
if(ellipseX>=949){
speedTwo=speedTwo*-0.75;
}
if(ellipseX<=51){
speedTwo=speedTwo*-0.75;
}
}
float xEllipse=350;
float yEllipse=300;
float speed=0;
float gravity=0.98;
void setup(){
size(1000,1000);
}
void draw(){
background(5,5,5);
fill(255,0,0);
ellipse(xEllipse,yEllipse,125,125);
yEllipse=yEllipse+speed;
speed=speed+gravity;
if(yEllipse>950){
speed=speed*-.9;
}
}
Looking good so far everyone. Please remember to use the three tilde marks at the beginning and end of your code to format it correctly.
Below is an example of how it would look.
```javascript
function fancyAlert(arg) {
if(arg) {
$.facebox({div:'#foo'})
}
}```
Check out this page to see other ways to format your text.
float ellipseX=400; float ellipseY=100; float speed=5; float gravity=0.2; float speed2=5;
void setup(){ size(800,800); } void draw(){ background(255); fill(0,0,0); ellipse(ellipseX,ellipseY,50,50); ellipseY = ellipseY + speed; ellipseX = ellipseX +speed2; speed = speed + gravity; if(ellipseX>=775){ speed2=speed2-0.8; } if(ellipseY>=775){ speed=speed-0.8; } if(ellipseX>=775){ speed2=speed20.8; } if(ellipseX<=25){ speed2=speed2-0.8; } }
In this homework we will be practicing how to create a physics simulation of gravity
Draw an ellipse to the screen and update the position each frame. Also, update the speed based on gravity. Make an if-statement to cause the ball to bounce off of the floor.
Take a look at the image notes from this week here
Please paste your code as a comment on this post