xxxxxxxxxx
45
var vel = 200;
var score = 0;
var gas = 100;
var mouse = false;
let size;
// Preload function to load assets and resources before the game starts.
function preload() {
renderPlayerIMG(); // player images.
streetRenderIMG(); // street images.
renderBotsIMG(); // bot images.
renderStatusIMG(); // status images.
loadSongs(); // game songs.
buttonIMG(); // button images.
screenIMG(); // screen images.
}
function setup() {
createCanvas(windowHeight, windowHeight); // Create a square canvas based on the window height.
size = windowHeight / 40; // Calculate a 'size' variable relative to the canvas height.
// Initialize game objects and elements.
p = new player(); // Create a player object.
s = new street(); // Create a street object.
pictureSetup(); // Set up webcam capture.
st = new status(); // Create a status object to display game status.
g = new Gas(); // Create a gas object.
// Play background music from the 'songs' array.
songs[2].loop();
}
function draw() {
Screen(); // Function to manage and render the game screens.
}
// Mouse pressed
function mousePressed() {
mouse = true; // Set 'mouse' to true when the mouse button is pressed.
}
// Mouse released
function mouseReleased() {
mouse = false; // Set 'mouse' to false when the mouse button is released.
}