Random position of class objects

ObstacleMovement obstacle1 = new ObstacleMovement(100, 200, 80, 100, 10, 3);
ObstacleMovement obstacle2 = new ObstacleMovement(100, 200, 30, 350, 10, 5);
ObstacleMovement obstacle3 = new ObstacleMovement(100, 200, 30, 600, 10, 5);
Car carmain = new Car();
//SlowObjects slowobject1 = new SlowObjects(100, 300, 30, 240, 10, 9);
StripeMovement stripe1 = new StripeMovement(1, 1, 1, 1);

float stripeYPos;
float b;
float obstacleYPos;
float obstacleXPos;
float obstaclePos;
float obstacle1Pos;

float obstacleXxPos;
float obstacleYyPos;

float size;
float speed;

int x = 0;
int y = 450;

void setup() {
size (720, 600);
obstacleYPos = -80;

obstacleXPos = 115;
obstaclePos = 350;
obstacle1Pos = 600;
obstacleXxPos = 240;
obstacleYyPos = -80;
}

void keyPressed() {
if ( key == ‘d’ ) {
x = x + 50;
}
if ( key == ‘a’)
x = x - 50;
}

void draw () {
background (#484646);
smooth();
strokeWeight(2);

line(240, 0, 240, 600);
line(480, 0, 480, 600);

stripe1.run();
obstacle1.run();
obstacle2.run();
obstacle3.run();
carmain.run();
//slowobject1.run1();

if (dist(obstacleXPos, obstacleYPos, mouseX, y) < 60) {
background (0);
noLoop();
textSize(80);
fill(#3279D8);
text(“You lose!”, 180, height/2);
}

if (dist(obstaclePos, obstacleYPos, mouseX, y) < 60) {
background (0);
noLoop();
textSize(80);
fill(#3279D8);
text(“You lose!”, 180, height/2);
}
if (dist(obstacle1Pos, obstacleYPos, mouseX, y) < 60) {
background (0);
noLoop();
textSize(80);
fill(#3279D8);
text(“You lose!”, 180, height/2);
}

}`

1 Like