Admin DueLLoYöneticisi
Mesaj Sayısı : 928 Doğum tarihi : 06/07/90 Yaşı : 34 Nerden : Antalya İş/Hobiler : Webtasarım - Öğrenci Lakap : Site sahibi Rep Puanı : 735008
| Konu: Kelime Yazma (tr) Cuma Ara. 04, 2009 8:19 pm | |
| - Kod:
-
<html> <head> <style> body { background: black; color: #55FF55; font-family: "lucida console", arial, sans-serif; font-weight: bold;} </style> <title>By qRs.28 Kelime Yazma Oyunu</title> </head> <body onload="onload();"> <input id="txt" type=text size=120 style="position: absolute; top: 400;left:10"> <div id="name" style="position: absolute; top: 370px; left: 270px"></div>
<div id="score" style="position: absolute; top: 370px; left: 20px">Skor: 0</div>
<div id="lives" style="position: absolute; top: 370px; left: 500px">Can: 10</div> <div id="hazir" style="position: absolute; top: 434px; left: 249px; width:234px">Hazirlayan: By qRs.28</div> <script> ie = 0; if (navigator.appVersion.indexOf("MSIE")!=-1){ ie = 1; }
dictionary = "silgi\nkalem\ncanta\nat\nbenzin\ngösteri\nayi\nfare\nkelimeler\net\ncikolata\nkedi\nciðlik\nkopek\ninsan\nkupa\nkarli\nyeni\nyemek\ntavuk\nyumurta\nturkiye\nordek\nkurt\nsincap\nel\nekran\nasker\nisik\ntestere\nkýrmýzý\nsari\npantolon\nsayfa\neski\navea\nöztürk\nmisafir\nyazma\nmasaüstü\ndolmuþ\notobüs\nmönitor\nyirmialtý\n"; var dict = dictionary.split("\n"); var score, max, initialSpeed, rednessBoundary, randomDelay, tooFar; var oneTickJump, speed, speedDecrement, lowerSpeedBoundary, scoreAddition; var slotSpacing, arrivalSpeed, ticksToNext, lives, cleared; function initVars() { score = 0; max = 16; divs = new Array(max); initialSpeed = 150; rednessBoundary = 450; randomDelay = 20; tooFar = 550; oneTickJump = 7; speed = initialSpeed; speedDecrement = 25; lowerSpeedBoundary = 100; scoreAddition = 3; slotSpacing = 20; arrivalSpeed = 50; ticksToNext = 1; lives = 10; cleared = 0; }
function arvonimi(score) { if (score >= 10000) return "Oha :D"; if (score >= 1000) return "!! Baþarýlý !!"; if (score >= 900) return "Güveniyorum sana!"; if (score >= 800) return "Eh idare eder"; if (score >= 700) return "Eh iþte"; if (score >= 600) return "Birdaha Dene"; if (score >= 500) return "fantastik"; if (score >= 400) return "güveniom sana"; if (score >= 300) return "orta"; if (score >= 200) return "orta hâli"; if (score >= 100) return "Hiç oynama daha iyi"; return "Tür!"; } function updateScore() { document.getElementById("score").innerHTML = "Skor: " + score; document.getElementById("name").innerHTML = arvonimi(score); }
function enter() { var txt; if (document.getElementById) { txt = document.getElementById("txt").value; } else { txt = document.all["txt"].value; }
if (lives == 0 && txt == "baslat") gameOverEnter(); matched = -1; for (i = 0; i < max; i++) { if (divs[i] != null) { if (divs[i].easyText.toLowerCase() == txt.toLowerCase()) { matched = i; } } }
if (matched != -1) { ticksToNext = 3; document.body.removeChild(divs[matched]); divs[matched] = null; score += scoreAddition + Math.floor(txt.length * 1.5); updateScore(); if (speed > lowerSpeedBoundary) { speed -= speedDecrement; } cleared++; if (cleared > 1) arrivalSpeed = 30; if (cleared > 5) arrivalSpeed = 20; if (cleared > 9) arrivalSpeed = 15; if (cleared > 12) arrivalSpeed = 12; if (cleared > 15) arrivalSpeed = 8; if (cleared > 25) arrivalSpeed = 7; if (cleared > 30) arrivalSpeed = 6; if (cleared > 35) arrivalSpeed = 5; if (cleared > 50) arrivalSpeed = 4; if (cleared > 60) arrivalSpeed = 3; if (cleared > 70) arrivalSpeed = 2; if (cleared > 80) arrivalSpeed = 1; }
document.getElementById("txt").value = ""; } function newText(str, slot) { // Create a new div and put it in the slot div = document.createElement("div"); div.innerHTML = str; div.easyText = str; div.style['position'] = "absolute"; div.easyLeft = 15; div.style['left'] = div.easyLeft + "px"; div.style['top'] = 20+slot*slotSpacing + "px"; divs[slot] = div; document.body.appendChild(div); }
// Enter pressed while game over function gameOverEnter() { document.body.removeChild(div); initVars(); setTimeout("tick()", initialSpeed); updateScore(); document.getElementById("txt").focus(); } function gameOver() { for (var i = 0; i < max; i++) { if (divs[i] != null) { document.body.removeChild(divs[i]); } }
div = document.createElement("div"); div.innerHTML = "<center>Oyun <a href=\"javascript:gameOverEnter()\">basla</a> <br>veya \"baslat\" yaz</center>"; div.style['position'] = "absolute"; div.style['left'] = "220px"; div.style['top'] = "170px"; document.body.appendChild(div);
return; var names = new Array(10); var scores = new Array(10); for (i = 0; i < 10; i++) { names[i] = "Kettunen"; scores[i] = (1000 - i * 100); }
var newNames = new Array(10); var newScores = new Array(10); mySlot = -1; for (i = 9; i >= 0; i--) { if (score > scores[i]) { newNames[i] = names[i-1]; newScores[i] = scores[i-1]; } else { if (mySlot == -1) mySlot = i + 1; newNames[i] = names[i]; newScores[i] = scores[i]; } } if (score > scores[0]) mySlot = 0; if (mySlot != -1) { newNames[mySlot] = '<input type=text id=name size=20 value="-- type here --">'; newScores[mySlot] = score; for (i = 9; i >= 0; i--) { names[i] = newNames[i]; scores[i] = newScores[i]; } } html = "Yuksek Skor<p>"; for (i = 0; i < 10; i++) { html += scores[i] + ' ' + names[i] + ' (' + arvonimi(scores[i]) + ')<br>'; } div = document.createElement("div"); div.innerHTML = html; div.style['position'] = "absolute"; div.style['left'] = "200px"; div.style['top'] = "50px"; document.body.appendChild(div); } function randomNewText() { allSlotsTaken = true; for (i = 0; i < max; i++) { if (divs[i] == null) allSlotsTaken = false; } if (allSlotsTaken == true) return; do { var slot = Math.floor(Math.random() * max); } while (divs[slot] != null); do { var i = Math.floor(Math.random() * dict.length); inPlay = false; for (j = 0; j < max; j++) { if (divs[j] != null && divs[j].easyText.toLowerCase() == dict[i].toLowerCase()) { inPlay = true; } } } while (inPlay == true); newText(dict[i], slot); }
function tick() { if (lives == 0) return; for (i = 0; i < max; i++) { if (divs[i] != null) { divs[i].easyLeft += oneTickJump; divs[i].style['left'] = divs[i].easyLeft + "px"; } }
for (i = 0; i < max; i++) { if (divs[i] != null) { if (divs[i].easyLeft >= rednessBoundary) { divs[i].style['color'] = "blue"; } } } for (i = 0; i < max; i++) { if (divs[i] != null) { if (divs[i].easyLeft >= tooFar) { document.body.removeChild(divs[i]); divs[i] = null; lives--; document.getElementById("lives").innerHTML = "Can: " + lives; if (lives == 0) { gameOver(); } } } } if (--ticksToNext == 0) { if (lives > 0) randomNewText(); ticksToNext = arrivalSpeed + Math.floor(Math.random() * randomDelay); } setTimeout("tick()", speed); }
function keyDown(DnEvents) { if (ie) { k=window.event.keyCode; } else { k=DnEvents.which; } if (k == 13 || k == 37 || k == 38 || k == 39) enter(); }
function onload() { initVars(); lives = 0; gameOver(); if (document.getElementById) { document.getElementById("txt").focus(); } else { document.all["txt"].focus(); } document.onkeydown = keyDown; setTimeout("tick()", initialSpeed); } </script> </body> </html>
Arkadaşlar Basit bir oyun.Oyun hızlandıkça hızlı yazma tecrübesi gerekir. istenilirse html haline getirilip kullanılabilir. | |
|