top of page
Search

Assignment 10: Update

  • Writer: Steven Gonzalez
    Steven Gonzalez
  • Nov 5, 2019
  • 1 min read

for this project i wanted to make a block breaker that bounces a ball of a paddle has different blocks that drop abilities and difficulty levels. So far I have made the ball bounce of the paddle and am trying to make it break a block


var length;

var width;

var xPos;

var yPos;

var xSpeed;

var ySpeed;

var bSize;

var x1;

var y1;

function setup() {

createCanvas(800,500);

length=100;

width=10;

xPos=400;

yPos=40;

xSpeed=10;

ySpeed=10;

bSize=10;

x1=0;

y1=300;

}


function draw() {

background(50);

fill(255,0,0);

rect(mouseX,480,length,width);

fill(0,255,0);

rect(x1,y1,50,10);

xPos+=xSpeed;

yPos+=ySpeed;

ellipse(xPos,yPos,bSize,bSize);

if ((xPos > (800-bSize/2)) || (xPos < bSize/2)){

xSpeed = -xSpeed;

}

//Remove the next line so it the ball doesnt have a barrier underneath

if ((yPos>(500-bSize/2))||(yPos<bSize/2)){

ySpeed=-ySpeed;

}

if((yPos>(480-bSize/2))){

ySpeed=-ySpeed;

}

//The following code is so the ball breaks a block

if((yPos>(y1-bSize/2)||yPos<y1-width/bSize/2)&&((xPos>(x1-bSize/2))&&xPos<bSize/2)){

ySpeed=-ySpeed;

x1=-10;

}

}


 
 
 

Recent Posts

See All
Algorithms:Homework 13

how I found the algorithms that is unfair is by just searching in google companies using unfair algorithms. In this article it has five...

 
 
 
Assignment 11

for this I tried to go off what we did last class and delete a ball i tried using array.pop() and array.splice() but I couldn't get it to...

 
 
 

Comments


©2019 by Steven. Proudly created with Wix.com

bottom of page