ball.pde
来自「This is processing for java examples.」· PDE 代码 · 共 51 行
PDE
51 行
// Simple bouncing ball classclass Ball { float x; float y; float speed; float gravity; float w; float life = 255; Ball(float tempX, float tempY, float tempW) { x = tempX; y = tempY; w = tempW; speed = 0; gravity = 0.1; } void move() { // Add gravity to speed speed = speed + gravity; // Add speed to y location y = y + speed; // If square reaches the bottom // Reverse speed if (y > height) { // Dampening speed = speed * -0.8; y = height; } } boolean finished() { // Balls fade out life--; if (life < 0) { return true; } else { return false; } } void display() { // Display the circle fill(0,life); //stroke(0,life); ellipse(x,y,w,w); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?