⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bounce.pde

📁 This is processing for java examples.
💻 PDE
字号:
/** * Bounce.  *  * When the shape hits the edge of the window, it reverses its direction.  */ int size = 60;       // Width of the shapefloat xpos, ypos;    // Starting position of shape    float xspeed = 2.8;  // Speed of the shapefloat yspeed = 2.2;  // Speed of the shapeint xdirection = 1;  // Left or Rightint ydirection = 1;  // Top to Bottomvoid setup() {  size(640, 200);  noStroke();  frameRate(30);  smooth();  // Set the starting position of the shape  xpos = width/2;  ypos = height/2;}void draw() {  background(102);    // Update the position of the shape  xpos = xpos + ( xspeed * xdirection );  ypos = ypos + ( yspeed * ydirection );    // 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) {    xdirection *= -1;  }  if (ypos > height-size || ypos < 0) {    ydirection *= -1;  }  // Draw the shape  ellipse(xpos+size/2, ypos+size/2, size, size);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -