1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Processing - 07 - バウンドボールの描画

Posted at
スクリーンショット 2018-02-05 22.26.09.png
float ellipseX;  //円の中心位置
float ellipseY;  //円の中心位置
float speedX;    //円の速度
float speedY;    //円の速度

void setup(){
  size(1024, 768);    
  frameRate(60);      
  stroke(194,24,91);  
  fill(233,30,99,127);
  ellipseX = 40;      //円の中心位置(初期)
  ellipseY = 40;      //円の中心位置(初期)
  speedX = 2;         //円の速度      
  speedY = 5;         //円の速度
}


void draw(){
  background(15);                      
  ellipse(ellipseX, ellipseY, 20, 20);
  ellipseX = ellipseX + speedX;      //円の中心位置(X座標)を更新
  ellipseY = ellipseY + speedY;      //円の中心位置(X座標)を更新
  
  if(ellipseX < 0 || ellipseX > width){
    speedX = speedX  * -1;
  }
  if(ellipseY < 0 || ellipseY > height){
    speedY = speedY * -1;
  }
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?