Game lab–My students and I have been trying to make a sprite go in a square/rectangle. We have the code for 3 of the sides but have tried numerous times to get it to finish the last leg. No success. Any advice is greatly appreciated. Here is the code we have so far:

background(“green”);

var corgi_1 = createSprite(5, 200);

corgi_1.setAnimation(“corgi_1”);

corgi_1.height = 50;

corgi_1.width = 70;

function draw() {

if (corgi_1.x < 215) {

corgi_1.x = corgi_1.x + 5;

}

if (corgi_1.x >= 215) {

corgi_1.y = corgi_1.y + 5;

}

if (corgi_1.y >= 315) {

corgi_1.x = corgi_1.x + 78654;

}

if (corgi_1.y > 300) {

corgi_1.x = corgi_1.x - 10;

}

if ((corgi_1.x) <= 25) {

corgi_1.x = corgi_1.x + 5;

}

drawSprites();

}

Thank you,

Marla