hhl_project/js/game.js
2023-12-09 22:42:01 +08:00

34 lines
981 B
JavaScript

// Function to show an element
function showElement(selector) {
const element = document.querySelector(selector);
if (element) {
element.style.display = 'block';
}
}
document.addEventListener("DOMContentLoaded", function() {
// Function to randomly select a customer
function showRandomCustomer() {
const customers = ['#customer1 img', '#customer2 img', '#customer3 img'];
const randomIndex = Math.floor(Math.random() * customers.length);
showElement(customers[randomIndex]);
}
// Show dialogue box
showElement("#dialogueBox img");
// Show all dishes
showElement('#mapo-tofu img');
showElement('#roast-duck img');
showElement('#yangzhou-fried-rice img');
showElement('#braised-prawns img');
showElement('#kung-pao-chicken img');
// Show a random customer
showRandomCustomer();
// Show normal Qin Shi Huang
showElement('#qinshihuang img');
});