Skip to content

Instantly share code, notes, and snippets.

@masaakif
Created January 19, 2009 08:13
Show Gist options
  • Save masaakif/48903 to your computer and use it in GitHub Desktop.
Save masaakif/48903 to your computer and use it in GitHub Desktop.
自由落下 1
import processing.core.*;
public class JiyuuRakka extends PApplet{
Ball b1;
public void setup(){
size(200, 200);
b1 = new Ball(random(width), random(0,20));
b1.setHeight(height);
}
public void draw(){
background(100);
b1.update();
ellipse(b1.x, b1.y, 10, 10);
}
}
public class Ball {
private
float _x, _y;
float _speedy;
float _size = 5;
int _height;
int _i;
float g = (float)0.009;
public
float x, y;
Ball(float x, float y){
_x = x;
_y = y;
_i = 0;
}
public void setHeight(int h) {
_height = h;
}
public void update(){
_i++;
_y = _y + g * _i * _i / 2;
_speedy = g * _i;
x = _x;
y = _y;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment