انشء لي لعبة فيديو عبارة عن لعبة محاكي الحروب تختار فيها دولتك وتستطيع الهجوم على الدول…
- User
انشء لي لعبة فيديو عبارة عن لعبة محاكي الحروب تختار فيها دولتك وتستطيع الهجوم على الدول الاخرى بلغة هتمل واربط الاكواد كلها في هتمل في ملف واحد
- Assistant
انشء لي لعبة فيديو عبارة عن لعبة محاكي الحروب تختار فيها دولتك وتستطيع الهجوم على الدول الاخرى بلغة هتمل واربط الاكواد كلها في هتمل في ملف واحد
بالطبع! سأقوم بإنشاء لعبة فيديو بسيطة لمحاكاة الحروب باستخدام لغة HTML وJavaScript. هذه اللعبة ستتيح لك اختيار دولتك ثم اختيار دولة أخرى للهجوم عليها. سأضع كل الأكواد في ملف HTML واحد لتتمكن من تشغيلها بسهولة.
إليك الكود الكامل للعبة:
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<title>محاكي الحروب</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #2c3e50;
color: #ecf0f1;
text-align: center;
padding: 50px;
}
select, button {
padding: 10px 20px;
margin: 10px;
font-size: 16px;
}
#gameArea {
margin-top: 30px;
}
.message {
margin-top: 20px;
font-size: 18px;
color: #e74c3c;
}
</style>
</head>
<body>
<h1>محاكي الحروب</h1>
<div>
<label for="chooseCountry">اختر دولتك:</label>
<select id="chooseCountry">
<option value="" disabled selected>اختر الدولة</option>
<option value="مصر">مصر</option>
<option value="السعودية">السعودية</option>
<option value="الولايات المتحدة">الولايات المتحدة</option>
<option value="روسيا">روسيا</option>
<option value="فرنسا">فرنسا</option>
</select>
</div>
<div>
<label for="attackCountry">اختر الدولة التي تريد الهجوم عليها:</label>
<select id="attackCountry">
<option value="" disabled selected>اختر الهدف</option>
<option value="مصر">مصر</option>
<option value="السعودية">السعودية</option>
<option value="الولايات المتحدة">الولايات المتحدة</option>
<option value="روسيا">روسيا</option>
<option value="فرنسا">فرنسا</option>
</select>
</div>
<button id="attackBtn">هجوم!</button>
<div id="gameArea">
<p class="message" id="message"></p>
</div>
<script>
const chooseCountry = document.getElementById('chooseCountry');
const attackCountry = document.getElementById('attackCountry');
const attackBtn = document.getElementById('attackBtn');
const message = document.getElementById('message');
attackBtn.addEventListener('click', () => {
const playerCountry = chooseCountry.value;
const targetCountry = attackCountry.value;
if (!playerCountry) {
message.textContent = 'الرجاء اختيار دولتك أولاً.';
return;
}
if (!targetCountry) {
message.textContent = 'الرجاء اختيار الدولة المستهدفة.';
return;
}
if (playerCountry === targetCountry) {
message.textContent = 'لا يمكنك الهجوم على دولتك!';
return;
}
// تبسيط لعملية الهجوم
const success = Math.random() > 0.5;
if (success) {
message.textContent = `تهانينا! هاجمت ${targetCountry} بنجاح من قبل ${playerCountry}.`;
} else {
message.textContent = `فشل الهجوم على ${targetCountry}. حاول مرة أخرى!`;
}
});
</script>
</body>
</html>
هيكل الصفحة:
التنسيق (CSS):
الوظائف (JavaScript):
Math.random()، ويتم عرض النتيجة للمستخدم.نسخ الكود:
حفظ الملف:
.html، على سبيل المثال: war_simulator.html.فتح اللعبة:
هذه النسخة بسيطة جداً من محاكيات الحروب، ويمكنك تطويرها بإضافة ميزات إضافية مثل:
إذا كنت ترغب في تطوير لعبة أكثر تعقيداً، قد تحتاج إلى استخدام مكتبات أو أطر عمل مخصصة للألعاب مثل Phaser.js أو Unity.
أتمنى أن تستمتع باللعبة البسيطة هذه ويمكنك تطويرها حسب رغبتك!
Not yet included in a published release.