Startseite Spiele Die Türme von Hanoi
Die Türme von Hanoi
( 225 Bewertungen, 3.48 Punkte von 5 )
JavaScripts - Spiele
Ziel des Spiels ist es, den Stapel der Scheiben auf einen anderen Pfahl zu bringen. Dabei dürfen nur kleine Scheiben auf grösseren liegen, niemals darf eine grössere Scheibe auf einer kleineren liegen!

Um das Spiel runterzuladen, braucht ihr neben dem unten stehenden Code auch die entsprechenden Bilder. Die gibt es hier:
Download der Bilder

Die Bilder müssen im gleichen Verzeichnis liegen wie das Script.

Homepage erstellen


"); document.write("Disks: "); document.write(""); document.write(""); } function draw(x,y,name) { document.images["pos"+x+""+y].src = imgdir + name; } function animate(x,y,name) { theAnim.addFrame( "pos"+x+""+y, imgdir + name); } function clicked(i,j) { document.forms[0].message.focus(); // get rid of annoying outline in MSIE document.forms[0].message.blur(); if (game_is_over) restart(startpost = endpost); if (!isselection() && ispost(i,j)) { message("Wähle eine Scheibe."); return; } if (!ispost(i,j)) { toggle(j); return; }; if (ispost(i,j) && selectedc == j) { message("Lege die Scheibe auf einen Pfahl."); return; } if (!legalmove(j)) { message("Illegaler Zug, die grössten Scheiben müssen immer unten liegen."); return; } move(j); return; } function legalmove(j) { if (isempty(j)) return true; return (board[j][topmost(j)] < board[selectedc][selectedr]); } function isselection() { return selectedc != null; } function toggle( num ) { var toppos = topmost(num); if (selectedc == num && selectedr == toppos) { selectedc = null; selectedr = null; animate(num,toppos,"disk" + board[num][toppos] + ".gif"); message("Wähle eine Scheibe."); return; } if (isselection()) { animate(selectedc,selectedr,"disk" + board[selectedc][selectedr] + ".gif"); } selectedc = num; selectedr = toppos; animate(num,toppos,"disk" + board[num][toppos] + "h.gif"); message("Klicke auf einen Pfahl, auf den die Scheibe gelegt werden soll."); } function move( num ) { var toppos = (!isempty(num) ? topmost(num) : board[num].length); board[num][toppos-1] = board[selectedc][selectedr]; board[selectedc][selectedr] = 0; animate(selectedc,selectedr,"post.gif"); animate(num,toppos-1,"disk" + board[num][toppos-1] + ".gif"); selectedc = null; selectedr = null; message("Wähle eine Scheibe."); game_over(); } function hanoi(no_of_disks, start_post, goal_post) { if (no_of_disks > 0) { var free_post = all_posts - start_post - goal_post; hanoi (no_of_disks - 1, start_post, free_post); show_messages = true; toggle(start_post); move(goal_post); show_messages = false; hanoi (no_of_disks - 1 , free_post, goal_post); game_over(true); } } function game_over(forceMsg) { var filledpost = null; var val = 0; for (k = 0; k < board.length; k++) { val += ( isempty(k) ? 1 : 0 ); if (!isempty(k)) filledpost = k; } if (val == 2 && isempty(startpost)) { message("Du hast gewonnen!", forceMsg); game_is_over = true; endpost = filledpost; } return game_is_over; } // // Animation functions // function Animation() { this.imageNum = new Array(); // Array of indicies document.images to be changed this.imageSrc = new Array(); // Array of new srcs for imageNum array this.frameIndex = 0; // the frame to play next this.alreadyPlaying = false; // semaphore to ensure we play smoothly this.getFrameCount = getframecount; // the total numebr of frame so far this.moreFrames = moreframes; // tells us if there are more frames to play this.addFrame = addframe; // add a frame to the animation this.drawNextFrame = drawnextframe; // draws the next frame this.startAnimation = startanimation; // start the animation if necessary } function getframecount() { return this.imageNum.length; } function moreframes() { return this.frameIndex < this.getFrameCount(); } function startanimation() { if (!this.alreadyPlaying) { theAnim.alreadyPlaying = true; setTimeout('theAnim.drawNextFrame()',5); } } function addframe(num, src) { var theIndex = theAnim.imageNum.length; theAnim.imageSrc[theIndex] = src; theAnim.imageNum[theIndex] = num; theAnim.startAnimation(); } function drawnextframe() { if (theAnim.moreFrames()) { document.images[ theAnim.imageNum[theAnim.frameIndex] ].src = theAnim.imageSrc[theAnim.frameIndex]; theAnim.frameIndex++; setTimeout('theAnim.drawNextFrame()', 30); } else { theAnim.alreadyPlaying = false; } } drawboard(); var theAnim = new Animation(); message("Versuche den Stapel Scheiben auf einen anderen Pfahl zu legen."); document.disp.message.value = ""; // End -->
<!-- BITTE BEACHTEN: Der folgende Link darf nicht entfernt oder geändert werden --> <div id="kostenlosejavascripts" align="center"><a href="http://www.kostenlose-javascripts.de/dsl-anbieter-vergleich.html" title="Internetanbieter" target="_blank">Internetanbieter</a></div>

Du willst auch das Zitat des Tages auf deiner Homepage?

 

Kommentare  

 
#15 06.09.2009 03:35
jaa...
mit 7 disks geschafft
 
 
#14 24.07.2009 20:29
3,5 sind einfach, 6 und 7 schaff ich net^^ ist ein gutes spiel
 
 
#13 01.07.2009 12:58
cooles script! Dieses Spiel wollte ich schon lange für meine Hp.
 
 
#12 03.07.2008 16:44
chek ich nicht
 
 
#11 10.10.2007 11:37
mein gott ich pack das nie...
 
 
#10 21.01.2007 16:56
mann das schuff ich mit 2 jahren
 
 
#9 20.01.2007 19:05
Gutes Game aber habe keine geduld nix für mich
 
 
#8 26.06.2006 21:54
schönes spiel
 
 
#7 24.06.2006 09:49
hehe ich schaff alle 7 in 2,43 minuten
 
 
#6 14.05.2006 13:54
19min hab ich gebraucht..ein gedulds spiel!
 
 
#5 14.05.2006 00:10
Das geht... man darf nur nich aufgeben:-)
 
 
#4 13.04.2006 12:34
juhu, 7 disks geschafft, aber man bruacht echt geduld... puuh
 
 
#3 11.04.2006 22:31

voll easy
in 10mins geschafft
 
 
#2 08.04.2006 18:18
ich schaff des net xD
 
 
#1 19.03.2006 19:52
mit 7 disc ist es echt sehr schwierig..... aber ich habs geschafft
man muss schon viel geduld haben
 

Login