网页版 家庭骰子

   前天晚上,没有什么事可做,用js重新写好了我之前用c#些的一个小游戏!

 

  下面是源代码:

<html>
	<head>
		<title>My Game 【家庭骰子】 【作者:艾彦波】</title>
		<style type="text/css">
			#authorInfo p{
				margin-top:2px;
				color:bule;
				font-size:14
			}
			.mes p{
				margin-top:10px;
				color:red;
				font-size:12
			}
		</style>	
	</head>
	<body bgcolor="pink">
		<h3 style="color:red" align="center">网页版【家庭骰子】出来了!</h3>
		<div style="margin-top:40px">
			<table align="center">
				<tr align="center">
					<td rowspan="4">
						<select name="list" id="list" multiple size="10" style="width:150px"></select>	
					</td>
					<td>
						<input type="button" value="开始" οnclick="gameRun()">
					</td>	
				</tr>
				<tr align="center">
					<td>
						<input type="button" value="停止" οnclick="stopGame()">
					</td>	
				</tr>
				<tr>
					<td>
						恭喜!您的任务是:
					</td>	
				</tr>
				<tr align="center">
					<td>
						<span style="color:blue" name="showJob" id="showJob">游戏未开始</span>
					</td>	
				</tr>
				<tr>
					<td colspan="2">
						<input style="border:0px;background-color:pink" type="button" value="复位" οnclick="init()">
						<input style="border:0px;background-color:pink" type="button" value="读取xml" οnclick="readXml()">
					</td>
				</tr>
			</table>
		</div>
		<div id="authorInfo" style="margin-top:140px">
			<p align="center">作者:艾彦波
			<p align="center">javaeye博客:<a href=" http://aiyanbo.iteye.com" target="_blank">http://aiyanbo.iteye.com</a>
			<p align="center">E-mail:<a href="mailto:ayanbo@yeah.net">ayanbo@yeah.net</a>
			<p align="center">QQ:448267886
		</div>
		<div class="mes" style="margin-top:50px">
			<p align="center">注意:本游戏仅供娱乐,请勿用于正常生活秩序中!
			<p align="center">您好!MyGame将游戏的配置文件放在c:/Proparm Files/mygame 中如果您不再使用该游戏您可以删除此文件!(现在没有开放此功能,所以没有上述文件夹)
			<p align="center">CopyRight@aiyanbo 2010
		</div>
		
	</body>
	<script language="javascript">
		var arr=["洗衣服","洗碗","买菜","扫地","做饭","休息"];
		var list=document.getElementById("list");
		var timeout;
		var m;
		var cli=0;
		οnlοad=function(){
			window.open("http://aiyanbo.iteye.com");
			window.open("http://user.qzone.qq.com/448267886");
			init();
		}
		function init(){
			clearTimeout(timeout);
			list.length=0;
			document.getElementById("showJob").innerHTML="游戏未开始";
			for(var i=0;i<arr.length;i++){
				var o=new Option(arr[i],arr[i]);
				list.options.add(o);
			}
			cli=0;
		}
		function gameRun(){
			if(cli==1)
				return;
			cli=1;
			startGame();	
		}
		function startGame(){
			if(list.length==0){
				alert("您的任务已经用完了,请点击【确定】重新开始!");
				clearTimeout(timeout);
				init();
				return;
			}
			m=parseInt((Math.random()*10000)%list.length);
			list.selectedIndex=m;
			document.getElementById("showJob").innerHTML=list[m].value;
			timeout=setTimeout("startGame()",1);
		}
		function stopGame(){
			if(cli==0)
				return;
			if(!timeout)
				return;
			clearTimeout(timeout);
			list.remove(m);
			timeout=null;
			cli=0;
		}
		function readXml(){
			var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			var bool=xmlDoc.load("mygame.xml");
			alert(bool);
		}
	</script>
</html>

 

 

 

 

有些写得不好的地方,还望朋友帮我指正下!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值