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;
}
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme