diff --git a/css/game.css b/css/game.css index fe46628..0a36444 100644 --- a/css/game.css +++ b/css/game.css @@ -51,14 +51,28 @@ left: 1050px; display: none; } - #dialogueBox img{ + #dialogueBox { position: absolute; width: 512px; height: 512px; top: 50px; left: 600px; + } + #dialogueBox img{ + position: absolute; + + width: 512px; + height: 670px; display: none; } + #dialogueText { + position: absolute; + top: 200px; + left: 100px; + width: 340px; + height: 128px; + font-size: 40px; + } #customer1 img{ /* 中年男 */ display: none; } diff --git a/game.html b/game.html index d45fe43..c73b52f 100644 --- a/game.html +++ b/game.html @@ -19,19 +19,23 @@ 秦始皇
- 死法1 + 死法1
- 死法2 + 死法2
- 死法3 + 死法3
对话框 +
+ +
+
中年男
@@ -78,7 +82,7 @@ - + diff --git a/js/game.js b/js/game.js index 02d0df6..1be9d73 100644 --- a/js/game.js +++ b/js/game.js @@ -1,20 +1,33 @@ // Function to show an element - function showElement(selector) { - const element = document.querySelector(selector); - if (element) { - element.style.display = 'block'; - } +function showElement(selector) { + const element = document.querySelector(selector); + if (element) { + element.style.display = 'block'; } +} + +// 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]); +} + +var questions = [ + "如何建立统一的度量衡体系以加强中央集权?", + "如何制定合理的税收政策来增强国库?", + "如何组织和动员资源建造长城以防御外敌?", + "如何执行禁止私人持有武器的政策?", + "如何推广统一的书写系统来加强文化统一?", + "如何合理征召士兵并保持军队的高效运作?", + "如何处理与儒家思想相关的政治异见?", + "如何加强皇帝的集权制度?", + "如何建立和维护一个有效的道路交通网络?", + "如何处理与周边国家的外交关系?" + ]; 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"); @@ -30,4 +43,8 @@ document.addEventListener("DOMContentLoaded", function() { // Show normal Qin Shi Huang showElement('#qinshihuang img'); + + // Show random question + var randomQuestion = questions[Math.floor(Math.random() * questions.length)]; + document.getElementById("dialogueText").innerHTML = randomQuestion; });