xxxxxxxxxx
40
var x=0
var y=200
var w=40
var Mx=2
var My=2
var Time=0
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
y=y+My
x=x+Mx
circle (x,y,w)
wallCollide ()
}
function wallCollide (){
if (x<0) {
Mx=2
console.log('hit')
} else
if (x>width) {
console.log('hit')
Mx=-2
} else
if (y<0) {
console.log('hit')
My=2 } else
if (y>height) {
My=-2
console.log('hit')} else {hit = false}
}