View file game/komp/kvadrat/game.html

File size: 19.37Kb
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Super Game =)</title>
<script language="JavaScript" type="text/javascript">

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

var curX, curY, curX2, curY2, boxX, boxY, moving=0, touch=0, tmp, tmp2;
var gametime=0, started=0, speed=40, next=0;
var starttime, endtime, finaltime=0;
var enemyxdir = new Array(1,1,1,1);
var enemyydir = new Array(1,1,1,1);
var x1, y1, x2, y2, x3, y3, x4, y4, gen;

if (isNS4 || isNS6){
document.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN|Event.MOUSEMOVE);
}
document.onmousedown = start;
document.onmousemove = checkLocation;
document.onmouseup = stop;

function startclock() {var today = new Date(); starttime = today.getTime();}
function endclock() {var today = new Date(); endtime = today.getTime();}
function calctime() {var time = (endtime - starttime - 0)/1000;	return time;}

function giveposX(divname) {
	if (isNS4) var posLeft = document.layers[divname].left;
	else if (isIE4 || isIE5) var posLeft = document.all(divname).style.pixelLeft;
	else if (isNS6) var posLeft = parseInt(document.getElementById(divname).style.left + "");
	return posLeft;
}

function giveposY(divname) {
	if (isNS4) var posTop = document.layers[divname].top;
	else if (isIE4 || isIE5) var posTop = document.all(divname).style.pixelTop;
	else if (isNS6) var posTop = parseInt(document.getElementById(divname).style.top + "");
	return posTop;
}

function setposX(divname, xpos) {
	if (isNS4) document.layers[divname].left = xpos;
	else if (isIE4 || isIE5) document.all(divname).style.pixelLeft = xpos;
	else if (isNS6) document.getElementById(divname).style.left = xpos;
}

function setposY(divname, ypos) {
	if (isNS4) document.layers[divname].top = ypos;
	else if (isIE4 || isIE5) document.all(divname).style.pixelTop = ypos;
	else if (isNS6) document.getElementById(divname).style.top = ypos;
}

function givesize(divname, dimension) {
	var divsize = 0;
		if (dimension == 'y') {
			if (isNS4) divsize = document.layers[divname].clip.height;
			else if (isIE4 || isIE5) divsize = document.all(divname).style.pixelHeight;
			else if (isNS6) divsize = parseInt(document.getElementById(divname).style.height + "");
		}
		else if (dimension == 'x') {
			if (isNS4) divsize = document.layers[divname].clip.width;
			else if (isIE4 || isIE5) divsize = document.all(divname).style.pixelWidth;
			else if (isNS6) divsize = parseInt(document.getElementById(divname).style.width + "");
		}

	return divsize;
}

function checktouching(num) {

	var enemy = "enemy" + num + ""
	var difX = giveposX('box') - giveposX(enemy) - 0;
	var difY = giveposY('box') - giveposY(enemy) - 0;


	if (difX > (-1 * givesize('box', 'x')) && difX < givesize(enemy, 'x') && difY > (-1 * givesize('box', 'y')) && difY < givesize(enemy, 'y')) {
		touch = 1;
	}
	else touch = 0;

}

function movenemy(num,step_x,step_y){

	var enemy = "enemy" + num + ""
	var enemyx = givesize(enemy, 'x');
	var enemyy = givesize(enemy, 'y');

	if (giveposX(enemy) >= (450 - enemyx) || giveposX(enemy) <= 0) {
		enemyxdir[num] = -1 * enemyxdir[num];
		}
	if (giveposY(enemy) >= (450 - enemyy) || giveposY(enemy) <= 0) {
		enemyydir[num] = -1 * enemyydir[num];
		}

	var newposx = giveposX(enemy) + (step_x*enemyxdir[num]) + 0;
	var newposy = giveposY(enemy) + (step_y*enemyydir[num]) + 0;

	setposX(enemy, newposx);
	setposY(enemy, newposy);

	checktouching(num + "");
	if (touch == 1) {
		stop(); reset();
		}
}

function rand(number) {
        return Math.ceil(Math.random()*number);
};

function rt() {
	return rand(30) - 13;
}

function rx() {
	tmp = rt();

	while (Math.abs(tmp) < 3) {
		tmp = rt();
	}

	return tmp;
}


function movenemies() {

	gametime = gametime + 1

	next = next + 1;

	if ((next == 10)&(speed>1)) {
		speed = speed - 1;
		next = 0;
	}

	if (speed < 1)
		speed = 1;

	if (gen != 1) {
		x1 = rx();
		y1 = rx();
		x2 = rx();
		y2 = rx();
		x3 = rx();
		y3 = rx();
		x4 = rx();
		y4 = rx();

		gen = 1;
	}


	movenemy(0,x1,y1);
	movenemy(1,x2,y2);
	movenemy(2,x3,y3);
	movenemy(3,x4,y4);

	setTimeout(movenemies,speed);
}

function start(e) {

	if (started == 0) {	movenemies(); 	startclock(); 	started = 1;	}

	curX = (isNS4 || isNS6) ? e.pageX : window.event.x ;
    curY = (isNS4 || isNS6) ? e.pageY : window.event.y ;

	curX2 = eval(curX - 40);
	curY2 = eval(curY - 40);

	boxX = eval(curX - 20);
	boxY = eval(curY - 20);

	var boxleft = giveposX('box');
	var boxtop = giveposY('box');

	if (curX > boxleft && curX2 < boxleft && curY > boxtop && curY2 < boxtop) {

		moving = 1;
		setposX('box', boxX);
		setposY('box', boxY);

		if (isNS4 || isNS6){
		document.captureEvents(Event.MOUSEMOVE);
		}
	}
}

function stop(e){
    moving=0;
	if (isNS4 || isNS6){
	document.releaseEvents(Event.MOUSEMOVE);
	}
}

function reset(e){
    endclock();
	moving=0;
	if (isNS4 || isNS6){
		document.releaseEvents(Event.MOUSEMOVE);
		}
	if (finaltime == 0) {
		finaltime = calctime();
		window.alert('You hold ' + finaltime + ' seconds...');

			document.location.reload();
		}
}

function checkLocation(e){

		curX = (isNS4 || isNS6) ? e.pageX : window.event.x ;
        curY = (isNS4 || isNS6) ? e.pageY : window.event.y ;

		boxX = eval(curX - 20);
		boxY = eval(curY - 20);

	checktouching('1');

	if (moving == 1 && touch == 0){

			setposX('box',boxX);
			setposY('box',boxY);

			if (curY > 69 && curX > 69 && curY < 381 && curX < 381) return false;
			else stop(); reset();
	}

	else if (touch == 1){
	stop(); reset();
	}

}

</script>
</head>
<body>
<div id="box" style="left:205px; width:40px; position:absolute; top:205px; height:40px; background-color:#900; layer-background-color:#900">
<table style="height:40; width:40;">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<div id="enemy0" style="left:270px; width:60px; position:absolute; top:60px; height:50px; background-color:#009; layer-background-color:#009;">
<table style="height:50; width:60;">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<div id="enemy1" style="left:300px; width:100px; position:absolute; top:330px; height:20px; background-color:#009; layer-background-color:#009">
<table style="height:20; width:100;">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<div id="enemy2" style="left:70px; width:30px; position:absolute; top:320px; height:60px; background-color:#009; layer-background-color:#009">
<table style="height:60; width:30;">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<div id="enemy3" style="left:70px; width:60px; position:absolute; top:70px; height:60px; background-color:#009; layer-background-color:#009">
<table style="height:60; width:60;">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr>
  <tr>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr>
  <tr>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr>
  <tr>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr>
  <tr>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr>
  <tr>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr>
  <tr>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr>
  <tr>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr>
  <tr>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td>
    <td width="50" bgcolor="#000" height="50">
      <table>
        <tbody>
        <tr>
          <td></td></tr></tbody></table></td></tr></tbody></table>


<div style="position:absolute; width:285px; height:293px; z-index:1; left:467px; top:32px" id="layer1">
<p>
&#1058;&#1082;&#1085;&#1080;&#1090;&#1077; &#1084;&#1099;&#1096;&#1082;&#1086;&#1081; &#1074; &#1082;&#1088;&#1072;&#1089;&#1085;&#1099;&#1081; &#1082;&#1074;&#1072;&#1076;&#1088;&#1072;&#1090; &#1080; &#1076;&#1074;&#1080;&#1075;&#1072;&#1081;&#1090;&#1077; &#1077;&#1075;&#1086;, &#1091;&#1076;&#1077;&#1088;&#1078;&#1080;&#1074;&#1072;&#1103; &#1083;&#1077;&#1074;&#1091;&#1102; &#1082;&#1085;&#1086;&#1087;&#1082;&#1091; &#1084;&#1099;&#1096;&#1080; &#1080; &#1080;&#1079;&#1073;&#1077;&#1075;&#1072;&#1103; &#1082;&#1086;&#1085;&#1090;&#1072;&#1082;&#1090;&#1072; &#1089; &#1089;&#1080;&#1085;&#1080;&#1084;&#1080; &#1082;&#1074;&#1072;&#1076;&#1088;&#1072;&#1090;&#1072;&#1084;&#1080;
</p>
<p>
&#1053;&#1077; &#1082;&#1072;&#1089;&#1072;&#1081;&#1090;&#1077;&#1089;&#1100; &#1095;&#1077;&#1088;&#1085;&#1099;&#1093; &#1082;&#1088;&#1072;&#1077;&#1074;
</p>
<p>
&#1045;&#1089;&#1083;&#1080; &#1087;&#1088;&#1086;&#1076;&#1077;&#1088;&#1078;&#1080;&#1090;&#1077;&#1089;&#1100; &#1073;&#1086;&#1083;&#1077;&#1077; 18 &#1089;&#1077;&#1082;&#1091;&#1085;&#1076; - &#1074;&#1099; &#1075;&#1077;&#1085;&#1080;&#1081;
</p>
<p>
&#1043;&#1086;&#1074;&#1086;&#1088;&#1103;&#1090;, &#1095;&#1090;&#1086; &#1072;&#1084;&#1077;&#1088;&#1080;&#1082;&#1072;&#1085;&#1089;&#1082;&#1080;&#1077; &#1074;&#1086;&#1077;&#1085;&#1085;&#1099;&#1077; &#1087;&#1080;&#1083;&#1086;&#1090;&#1099; &#1084;&#1086;&#1075;&#1091;&#1090; &#1101;&#1090;&#1086; &#1076;&#1077;&#1083;&#1072;&#1090;&#1100; &#1073;&#1086;&#1083;&#1100;&#1096;&#1077; 2 &#1084;&#1080;&#1085;&#1091;&#1090;
</p>
</div>
</body>
</html>