mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Removing some examples
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* When the shape hits the edge of the window, it reverses its direction.
|
||||
*/
|
||||
|
||||
int size = 60; // Width of the shape
|
||||
int rad = 60; // Width of the shape
|
||||
float xpos, ypos; // Starting position of shape
|
||||
|
||||
float xspeed = 2.8; // Speed of the shape
|
||||
@@ -16,9 +16,10 @@ int ydirection = 1; // Top to Bottom
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(640, 200);
|
||||
size(640, 360);
|
||||
noStroke();
|
||||
frameRate(30);
|
||||
ellipseMode(RADIUS);
|
||||
smooth();
|
||||
// Set the starting position of the shape
|
||||
xpos = width/2;
|
||||
@@ -35,13 +36,13 @@ void draw()
|
||||
|
||||
// Test to see if the shape exceeds the boundaries of the screen
|
||||
// If it does, reverse its direction by multiplying by -1
|
||||
if (xpos > width-size || xpos < 0) {
|
||||
if (xpos > width-rad || xpos < rad) {
|
||||
xdirection *= -1;
|
||||
}
|
||||
if (ypos > height-size || ypos < 0) {
|
||||
if (ypos > height-rad || ypos < rad) {
|
||||
ydirection *= -1;
|
||||
}
|
||||
|
||||
// Draw the shape
|
||||
ellipse(xpos+size/2, ypos+size/2, size, size);
|
||||
ellipse(xpos, ypos, rad, rad);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ Ball[] balls = new Ball[numBalls];
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(640, 200);
|
||||
size(640, 360);
|
||||
noStroke();
|
||||
smooth();
|
||||
for (int i = 0; i < numBalls; i++) {
|
||||
balls[i] = new Ball(random(width), random(height), random(20, 40), i, balls);
|
||||
balls[i] = new Ball(random(width), random(height), random(30, 70), i, balls);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* Collision (Pong).
|
||||
*
|
||||
* Move the mouse up and down to move the paddle.
|
||||
*/
|
||||
|
||||
// Global variables for the ball
|
||||
float ball_x;
|
||||
float ball_y;
|
||||
float ball_dir = 1;
|
||||
float ball_size = 15; // Radius
|
||||
float dy = 0; // Direction
|
||||
|
||||
// Global variables for the paddle
|
||||
int paddle_width = 10;
|
||||
int paddle_height = 60;
|
||||
|
||||
int dist_wall = 15;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(640, 360);
|
||||
rectMode(RADIUS);
|
||||
ellipseMode(RADIUS);
|
||||
noStroke();
|
||||
smooth();
|
||||
ball_y = height/2;
|
||||
ball_x = 1;
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(51);
|
||||
|
||||
ball_x += ball_dir * 1.0;
|
||||
ball_y += dy;
|
||||
if(ball_x > width+ball_size) {
|
||||
ball_x = -width/2 - ball_size;
|
||||
ball_y = random(0, height);
|
||||
dy = 0;
|
||||
}
|
||||
|
||||
// Constrain paddle to screen
|
||||
float paddle_y = constrain(mouseY, paddle_height, height-paddle_height);
|
||||
|
||||
// Test to see if the ball is touching the paddle
|
||||
float py = width-dist_wall-paddle_width-ball_size;
|
||||
if(ball_x == py
|
||||
&& ball_y > paddle_y - paddle_height - ball_size
|
||||
&& ball_y < paddle_y + paddle_height + ball_size) {
|
||||
ball_dir *= -1;
|
||||
if(mouseY != pmouseY) {
|
||||
dy = (mouseY-pmouseY)/2.0;
|
||||
if(dy > 5) { dy = 5; }
|
||||
if(dy < -5) { dy = -5; }
|
||||
}
|
||||
}
|
||||
|
||||
// If ball hits paddle or back wall, reverse direction
|
||||
if(ball_x < ball_size && ball_dir == -1) {
|
||||
ball_dir *= -1;
|
||||
}
|
||||
|
||||
// If the ball is touching top or bottom edge, reverse direction
|
||||
if(ball_y > height-ball_size) {
|
||||
dy = dy * -1;
|
||||
}
|
||||
if(ball_y < ball_size) {
|
||||
dy = dy * -1;
|
||||
}
|
||||
|
||||
// Draw ball
|
||||
fill(255);
|
||||
ellipse(ball_x, ball_y, ball_size, ball_size);
|
||||
|
||||
// Draw the paddle
|
||||
fill(153);
|
||||
rect(width-dist_wall, paddle_y, paddle_width, paddle_height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,20 +7,19 @@
|
||||
* back at the bottom of the screen.
|
||||
*/
|
||||
|
||||
float a = 100;
|
||||
float a;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(640, 200);
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
stroke(255);
|
||||
a = height/2;
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
void draw() {
|
||||
background(51);
|
||||
line(0, a, width, a);
|
||||
a = a - 0.5;
|
||||
if (a < 0) {
|
||||
a = height;
|
||||
}
|
||||
line(0, a, width, a);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ float ellipseSpeed = 3.5;
|
||||
float velocityX, velocityY;
|
||||
|
||||
void setup(){
|
||||
size(640, 240);
|
||||
size(640, 360);
|
||||
frameRate(30);
|
||||
fill(128);
|
||||
smooth();
|
||||
|
||||
@@ -14,7 +14,7 @@ Ground[] ground = new Ground[segments];
|
||||
float[] peakHeights = new float[segments+1];
|
||||
|
||||
void setup(){
|
||||
size(640, 200);
|
||||
size(640, 360);
|
||||
smooth();
|
||||
orb = new Orb(50, 50, 3);
|
||||
velocity = new PVector(.5, 0);
|
||||
|
||||
Reference in New Issue
Block a user