我觉得用PHP+JS可以设计出挺牛逼的二维网页游戏,当然网络型的网页游戏后台数据的交互可以使用java来做数据处理。
php
$init = $_POST["init"];//game restart
$clickvalue = $_POST["clickvalue"];//minesweeping
$checkflag = 0;//Victory or defeat
$click_count = 0;//clicks count
if($init == null && $clickvalue == null){//initialization
$_POST = array();//set POST with a array
$_POST["rows"] = 9;//set rows
$_POST["cols"] = 9;//set cols
$_POST["num"] = 10;//set num
$_POST["timeshow"] = "00:00"; //set starttime
$init = true;//set initialization
}
$rows = $_POST["rows"];//get rows
$cols = $_POST["cols"];//get cols
$num = $_POST["num"];//get num
$starttime = $_POST["starttime"];//get starttime
if($init){// is initialization
$timeshow = "00:00";//set starttime
$data = array();//data initialization
for($i=0;$i= 0 && $j - 1 >= 0 && $data["data".($i - 1)."_".($j - 1)] == 100)$cnt++;//upper left
if($i - 1 >= 0 && $data["data".($i - 1)."_".$j] == 100)$cnt++;//left
if($i - 1 >= 0 && $j + 1 = 0 && $data["data".$i."_".($j - 1)] == 100)$cnt++;//upper
if($j + 1 = 0 && $data["data".($i + 1)."_".($j - 1)] == 100)$cnt++;//upper right
if($i + 1 9?$min:"0".$min).":".($sec>9?$sec:"0".$sec);
}else{
$timeshow = "00:00";//if game is stop , time stop
}
function openNode($i,$j){//set nodes to open,if it is can open
global $rows;//get the rows
global $cols;//get the cols
global $data;//get the data
if($i = $rows || $j = $cols || $data["open".$i."_".$j])return;//it is not a node,or it has been opened
$data["open".$i."_".$j] = 1;//open the node
if($data["data".$i."_".$j] > 0)return;//need to continue?
openNode($i - 1,$j - 1);
openNode($i - 1,$j);
openNode($i - 1,$j + 1);
openNode($i,$j - 1);
openNode($i,$j + 1);
openNode($i + 1,$j - 1);
openNode($i + 1,$j);
openNode($i + 1,$j + 1);
}
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号