Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Time Waister
var Score=0; var PaddleWidth=100; //speed of ball when first leaves paddle var initialspeedX= 5; var initialspeedY= -6; //current location of speed var ballspeedX=initialspeedX; var ballspeedY=initialspeedY; //location of ball var ballX=0; var ballY=0; var ballMoving=false; //ballmoving=true ball on paddle=false var draw=function(){background(0,108, 135); //paddle fill(240, 67, 67); rect(mouseX-PaddleWidth/2,350, PaddleWidth, 10); //ballmoving if (ballMoving){ ballX += ballspeedX; ballY+=ballspeedY;} else{ballX=mouseX; ballY=340; } //drawball fill(98, 255, 0); ellipse(ballX,ballY,20,20); //ball hot top wall if(ballY<=10){ ballspeedY=-ballspeedY; playSound(getSound("rpg/hit-thud")); } //leftwall if(ballX<=10){ ballspeedX=-ballspeedX; playSound(getSound("rpg/hit-thud")); } //rightwall if(ballX>=390){ballspeedX=-ballspeedX; playSound(getSound("rpg/hit-thud")); } //paddle if(ballY>=340&&ballY<346&&ballX>=mouseX-PaddleWidth/2&&ballX<=mouseX+PaddleWidth/2){ ballspeedY=-ballspeedY; playSound(getSound("rpg/hit-whack")); if(ballMoving){Score +=1;} } //ballfallenoutdabottom if (ballY >= 400){ballMoving=0;playSound(getSound("retro/boom1"));} text("SCORE: " + Score,11,39); textSize(41); }; //atoumatic function //when mouse is clicked var mouseClicked=function(){ if (!ballMoving){ //reset ball speed ballspeedX=initialspeedX; ballspeedY=initialspeedY; ballMoving=true; Score=0; } };
run
|
edit
|
history
|
help
0
JS Testing
color
9
random2
MyProfile_Medalla.java
JS is_sorted
codeing
G
Javascript Closure
Lovedek_ellovesi_tavolsag_kalkulator