Logo

Home     Forum     Impressum / Kontakt     •     Java-Scripte                    

<CENTER>
<SCRIPT LANGUAGE="LiveScript">
        <!--
        step = 0;
        diff=3;
        // change board when button is clicked
        function clear_all(form) {
            step = 0;
            for (i=0;i<9; ++i) {
                position="a"+i;
                form[position].value="";
            }
        }
        // change board when button is clicked
        function clickit(field) {
        if (step == -1) {alert("Reset to play again"); return;}
        position=field.name.substring(1,2,1);
        position = 'a'+position;
        if (field.form[position].value !="") {alert("Can't go there");
return;}
        field.form[position].value="X";
        if (eval_pos(field.form)) {
            field.form.output.value="You Win!";
            step = -1;
            return;
        }
        position=get_move(field.form);
        field.form.output.value='I moved to ' +
position.substring(1,2,1);
        if (position=="") {
            field.form.output.value="No Winner.";
            step = -1;
            return;
        }
        field.form[position].value="O";
        if (eval_pos(field.form)) {
            field.form.output.value="You Lose!";
            step = -1;
        }
        }

        // see if there is a winner
        function eval_pos(form) {
           if ((form.a0.value!="" &&
            form.a0.value==form.a3.value && form.a0.value==form.a6.value)||
              (form.a0.value!=""
            && form.a0.value==form.a1.value && form.a0.value==form.a2.value) ||
              (form.a0.value!=""
            && form.a0.value==form.a4.value && form.a0.value==form.a8.value) ||
              (form.a1.value!=""
            && form.a1.value==form.a4.value && form.a1.value==form.a7.value) ||
              (form.a2.value!=""
            && form.a2.value==form.a5.value && form.a2.value==form.a8.value) ||
              (form.a2.value!=""
            && form.a2.value==form.a4.value && form.a2.value==form.a6.value) ||
              (form.a3.value!=""
            && form.a3.value==form.a4.value && form.a3.value==form.a5.value) ||
              (form.a6.value!=""
            && form.a6.value==form.a7.value && form.a6.value==form.a8.value))
            return true;
        else    
           return false;
        }

        function f(a) {
        if (a == "") return "."; else return a;
        }

        // get position for move.
        function comp_move(form,player,weight,depth) {
            var cost;
            var bestcost=-2;
            var position;
            var newplayer;
            if (player=="X") newplayer="O"; else newplayer="X";
            if (depth==diff) return 0;
            if (eval_pos(form)) return 1;
            for (var i=0; i<9; ++i) {
                position='a'+i;
                if (form[position].value != "")
                    continue;
                form[position].value=player;
                cost = comp_move(form,newplayer, -weight, depth+1);
                if (cost > bestcost) {
                    bestcost=cost;
                    if (cost==1) i=9;
                }
                form[position].value="";
            }
            if (bestcost==-2) bestcost=0;
            return(-bestcost);
        }

        // get position for move.
        function get_move(form) {
            var cost;
            var bestcost=-2;
            bestmove="";
            // don't think about first move.
            if (step++ == 0)
                if (form.a4.value=="")
                    return "a4";
                else
                if (form.a0.value=="")
                    return "a0";

            for (var i=0; i<9; ++i) {
                localposition='a'+i;
                if (form[localposition].value != "")
                    continue;
                form[localposition].value="O";
                cost=comp_move(form,"X", -1, 0);
                if (cost > bestcost) {
                    if (cost==1) i=9;
                    bestmove=localposition;
                    bestcost=cost;
                }
                form[localposition].value="";
            }
            return bestmove;
        }

        // complain if user attempts to change board
        function complain(field) {
            field.form.output.focus(); // put focus eleswhere
            alert("Don't change the game fields directly!");
        }
    //a href="http://www.ucsd.edu/
        // the end -->
      </SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--  to hide script contents from old browsers
// rev 0.04
var crlf = "\r\n";  
// should determine from browser type
    var x = 1;
    var y = 1;
    var dx = 1;
    var dy = 1;
    var s = "";
    var u = 0;
    var oops_flag = false;
    var score = 0;

function move1() {
    x += dx;
    if (x > 31) {
    x -= 2 * Math.abs(dx);
    if (dx > 0) dx = -dx; }
    if (x <  0) {
    x += 2 * Math.abs(dx);
    if (dx < 0) dx = -dx; }
    y += dy;
    if (y > 14) {
    y -= 2 * Math.abs(dy);
    if (dy > 0) dy = -dy;
    if (Math.abs(x - 2*u - 1) > 2) {
    oops_flag = true;
    }
    else {
    score += 1;          
    }    
    }
    if (y <  0) { y += 2 * Math.abs(dy);
if (dy < 0) dy = -dy; }
  }

function display1() {
    var s1 = ""
    var i,j;
    if (oops_flag) return "Oops!! You messed up on the easiest game ever made!! I feel sorry for you!! You need a lot of practice!! Come back often and play!!!!!!";
    for (j=0;j<15;j++) {
      for (i=0;i<32;i++) {
    if (j == y && i == x) s1 += "o";
        else s1 += ".";
      }
      s1 += crlf;
    }
    var s2 = ""
    for (i=0;i<16;i++) {
       if (u == i) s2 += "==";
       else s2 += "..";
    }
    return (s1+s2)
  }
  var timerID = null;
  var timerRunning = false;
  var myform;

function stopclock (){
        if(timerRunning) clearTimeout(timerID);
        timerRunning = false;
  }

function startclock (form) {
        myform = form;
    oops_flag = false;
    if (navigator.userAgent.indexOf("Mac") > 2) crlf = "\n";
    // Make sure the clock is stopped
        stopclock();
        dotime();
  }

function dotime () {
    move1();
        if (myform != null) {
      myform.text3.value = display1();      
      myform.score.value = " " + score;
    }
    if (!oops_flag) timerID = setTimeout("dotime()",200);
        timerRunning = true;
  }
// end hiding contents from old browsers  -->
</SCRIPT>
<FORM NAME="myForm" >
<TEXTAREA NAME="text3" ROWS=16 COLS=34 WRAP>
[game field]
</TEXTAREA>
Score: <INPUT TYPE="text" NAME="score" SIZE=10 VALUE=0>

<p>
<a href="#" onMouseOver="u =  0">\\\</a>
<a href="#" onMouseOver="u =  1">///</a>
<a href="#" onMouseOver="u =  2">\\\</a>
<a href="#" onMouseOver="u =  3">///</a>
<a href="#" onMouseOver="u =  4">\\\</a>
<a href="#" onMouseOver="u =  5">///</a>
<a href="#" onMouseOver="u =  6">\\\</a>
<a href="#" onMouseOver="u =  7">///</a>

<a href="#" onMouseOver="u =  8">\\\</a>
<a href="#" onMouseOver="u =  9">///</a>
<a href="#" onMouseOver="u = 10">\\\</a>
<a href="#" onMouseOver="u = 11">///</a>
<a href="#" onMouseOver="u = 12">\\\</a>
<a href="#" onMouseOver="u = 13">///</a>
<a href="#" onMouseOver="u = 14">\\\</a>
<a href="#" onMouseOver="u = 15">///</a>
 Hier mit der Maus steuern

<BR><BR><INPUT TYPE="button" NAME="Button1" VALUE="[ Start Game ]" onCLick="startclock(this.form)">
</FORM>
</CENTER>
Breakout

Breakout ist ein recht bekanntes Spiel, bei dem man einen kleinen Ball mit einem recht schmalen Balken im spielfeld halten muß.

nach diesem Prinzip funktioniert auch dieses Javascript Spiel.

Allerdings läuft das ganze in einem Textfeld, ohne Sound und Grafik
und es wird auf Dauer sehr langweilig