Question: How do I make it that my object (robot) moves in random directions across the screen each time I run the program?
Code:
//head
var x = 200;
//body
var e = 400;
//arms
var x1= 280;
var y1 = 120;
//legs
var x2 = 230;
var y2 = 160;
var speedx = 5;
var speedy = 5;
function setup() {
createCanvas(500,400);
}
function draw() {
background(179,0,27);
rectMode( CENTER)
fill(68,100,173)
stroke(70,105,149)
//head
ellipse(x,100,50,50);
noFill(0)
fill(164,176,245)
noStroke(0)
stroke(125,70,0)
//body
rect(x,200,100,100)
if ( x > 200){
noFill(0)
fill(245,143,41)
noStroke(0)
stroke(245,143,41)
}
x = x + speedx
//right arm
rect(x1,210,40,120)
if ( x1 > 200){
noFill(0)
fill (125,70,0)
noStroke(0)
stroke(164,176,245)
}
x1 = x1 + speedx
// left arm
rect(y1,210,40,120)
y1= y1 + speedx
x2 = x2 + speedx
noFill(0)
fill(70,105,149)
noStroke(0)
stroke(68,100,173)
//right leg
rect(x2,350,40,140)
//left leg
rect(y2,350,40,140)
y2 = y2 + speedx
}