Chinaunix

标题: 自写的剪子包袱锤小游戏 [打印本页]

作者: zairwolf    时间: 2006-04-09 00:46
标题: 自写的剪子包袱锤小游戏
<div align=center><form action='?action=go' method=post>
选择你的类型:
<input type="radio" name="mychoise" value="1" checked>石头
<input type="radio" name="mychoise" value="2">剪子
<input type="radio" name="mychoise" value="3">布
<br/>
<br/>
<br/>
<input type="submit" value="出拳" />
</form>

<hr>

</div>
<?
//made by zairwolf
$arr=array(1=>'石头',2=>'剪子',3=>'布',);
if($action) {
$comschoice=rand(1,3);
if($comschoice-$mychoise==1 || $comschoice-$mychoise==-2) {
$res= "你赢了";
}elseif($comschoice==$mychoise) {
$res= "平局";
}else {
$res= "你输了";
}
echo "<table border=0 align=center cellpadding=4><tr align=left><td>你出的:</td><td>{$arr[$mychoise]} </td></tr><tr align=left><td>电脑出的</td><td name=computer id=computer>出拳中 </td></tr><tr align=left><td>结果</td><td name=res id=res>...</td></tr></table>";
ob_start();
ob_end_flush();
ob_implicit_flush();
for($i = 1; $i <= 300; $i++ ) print(" ");
sleep(1);
echo "<script>document.getElementById('computer').innerHTML=\"{$arr[$comschoice]}\";</script>";
echo "<script>document.getElementById('res').innerHTML='$res';</script>";
}
作者: Yarco    时间: 2006-04-09 10:06
提示: 作者被禁止或删除 内容自动屏蔽
作者: ydlhero    时间: 2006-04-09 10:14
lz 考虑用js写
作者: taohui    时间: 2006-04-09 22:42
可以放在教科书里




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2