تم تصميم هذه اللعبة لنقطتين:
أولا ، عملية النصر أو الهزيمة
لأن المقص الحجري دوري
حجر القتل مقص
مقص وقتل القماش
قتل الحجر
حجر القتل مقص
. . .
اكتشف القواعد المستندة إلى الخصائص المذكورة أعلاه واكتب الخوارزمية.
دع الكمبيوتر بشكل عشوائي
هذا سهل نسبيا. لقد كتبت مقالا من قبل. إذا كنت لا تفهم ، فيمكنك الذهاب وإلقاء نظرة على أحذية الأطفال.
انتقاد الشاشة العشوائية
في الواقع ، ليس هذا التأثير هو مفتاح اللعبة ، لكنني أضفتها إليها من أجل أن تبدو أكثر تفاعلية وممتعة. يتم استخدام خوارزمية المعامل هنا ، ويمكن تحقيق التأثير عن طريق الحلق وفقًا للباقي.
واجهة لقطة الشاشة
أخيرًا ، تتم إضافة الرمز
<! doctype html> <html> <head> <meta charset = "utf -8"/> <title> لعبة مقص JS - مدونة Qiongtai </title> <style type = "text/css"> div {margin: 20px auto ؛ padding: 10px ؛ border: 2px solid ؛ #999 ؛ العرض: 200px ؛ الخلفية: #ffe ؛} div#cu {font-weight: bold ؛ font-size: 30px ؛ height: 40px ؛ color: red ؛} div#la {border: none ؛ background: none ؛ display: none ؛ null ، time = 20 ، you = 0 ، arr = new array ('Stone' ، 'Rag' ، 'Scissor') ؛ function p (n) {you = n ؛ document.getElementById ('you'). innerhtml = s (n) ؛ document.getElementById ('st'). معاق = true. setInterval ('t ()' ، 50) ؛} الوظيفة Agin () {document.getElementById ('st'). تعطيل = false ؛ document.getElementById ('mb'). upabled = false "none '؛ document.getElementById (' you '). innerhtml =' '؛ document.getElementById (' pc '). innerhtml =' '؛ document.getElementByid (' cu '). innerhtml =' '؛ document.getElementByid (' you ') math.floor (math.random () * 3 +1) ؛ document.getElementById ('pc'). innerhtml = s (pc) ؛ var str = '' ؛ if (pc == you) {str += 'trap' ؛} {var b = pc-you ؛ win '؛}} else {b = b*-1 ؛ if (b == 1) {str +=' you win '؛} آخر {str +=' computer win '؛}}}} document.getElementById (' la '). t () {if (time> 0) {document.getElementById ('pc'). innerhtml = arr [time ٪ 3] ؛ time-؛} آخر {clearinterval (se) ؛ se = null ؛ time = 20 ؛ bt () ؛ 'Scissor' ؛}} </script> </head> <body> <viv> <p> ماذا خرجت؟ <span id = "you"> يرجى تحديد </span> </p> <p> <button id = "st" onClick = "p (1) ؛"> stone </utton> </p> <p> <button id = "mb" onClick = "p (2) ؛ OnClick = "P (3) ؛"> مقص </button> </p> </viv> <viv> <p> كمبيوتر؟ </p> <span style = "" id = "pc"> </span> </viv> <div id = "cu"> </viv> <div id = "la"