xxxxxxxxxx
39
/*
*** CATCH THE SHEEPS (GAME CONCEPT) ***
First part of the game, score and functionalities will be added on a different sketch.
Mouse Interaction with The Coding Train ˜ https://thecodingtrain.com/
Sketch made by Leonardo M. Louzas ( https://github.com/leonardomlouzas ) | 21/aug/24
*/
function setup() {
createCanvas(windowWidth, windowHeight);
sheep = new Sheep(windowWidth / 2, windowHeight / 2);
corral = new Corral(windowWidth / 2, windowHeight / 2);
}
function draw() {
background(100, 205, 100);
frameRate(60);
corral.show();
sheep.show();
// move the sheep every half frame
if (sheep.free && frameCount % 30 == 0) {
sheep.move(width, height);
}
}
function mouseDragged() {
// grab the sheep and move it
if (sheep.grabbed(mouseX, mouseY)) {
sheep.free = false;
}
}
// free the sheep after dragging it
function mouseReleased() {
sheep.free = true;
}