xxxxxxxxxx
49
let startButton, quitButton;
function preload(){
backGround = loadImage("background.png");
}
function setup() {
createCanvas(400, 600);
// create start button
startButton = createButton("Start");
startButton.position(250, height-75);
startButton.size(100, 50);
startButton.mousePressed(startGame);
// create quit button
quitButton = createButton("Quit");
quitButton.position(50, height - 75);
quitButton.size(100, 50);
quitButton.mousePressed(quitGame);
}
function draw() {
background(backGround);
// add introduction text
textSize(12);
textFont('Courier New');
textStyle(BOLD);
textAlign(CENTER, CENTER);
fill(255);
text("It is the year 2050, and humanity has expanded its reach beyond the confines of planet Earth.The vast expanse of space is now home to numerous colonies and outposts,and the need for skilled pilots to navigate the dangers of the cosmos has never been greater.You are one such pilot, an ace space fighter with a reputation for taking on the toughest challenges and emerging victorious.But even you may not be ready for what lies ahead.A mysterious alien threat has emerged from the depths of space, and it is up to you to lead the fight against this new enemy.Armed with your trusty spacecraft and a powerful radar system,you must navigate through the treacherous asteroid fields and engage in intense dogfights with enemy ships.The fate of humanity rests on your shoulders, pilot.Will you rise to the challenge?", 50, 0, width - 90, height);
// add buttons
startButton.show();
quitButton.show();
}
function startGame() {
// remove buttons and start game
startButton.remove();
quitButton.remove();
// add game code here
}
function quitGame() {
// quit the game
window.close();
}