int ballX, ballY, ballVelocityX, ballVelocityY; int padX, padY, padVelocity, padWidth = 100, padHeight = 10; int score; boolean ballAlive; void setup() { size(480, 600); ballX=10; ballY=10; ballVelocityX=12; ballVelocityY=8; ballAlive=true; padX=100; padY=height-padHeight; padVelocity=10; score=0; } void draw() { //球の跳ね返し if (ballAlive) { //壁との衝突 if (ballX<0 || widthpadY-10) { ballVelocityY*=-1; score++; } //地面との接触 if (heightwidth) padX=width-padWidth; //球と棒の描画 background(0); fill(255); if (ballAlive) ellipse(ballX, ballY, 20, 20); rect(padX, padY, padWidth, padHeight); textSize(30); textAlign(LEFT); text("SCORE:" + score, 10, 30); //ゲームオーバー if (ballAlive==false) { textSize(30); textAlign(CENTER); text("CLICK HERE", width/2, height/2); } //リスタート if (ballAlive==false && mousePressed) { ballAlive=true; ballX=10; ballY=10; } }