📄 ball.pde
字号:
// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -