//ob_implicit_flush();
class dgt_game{
var $bmp0="
";var $bmp1="
";var $Table=array();
var $save_Table=array(); //保存最后一次状态
var $fk=array(); //模块形状
var $row=0;
var $col=0;
function J_1($row,$col){
$this->fk[$row+0][$col+0]=1;
$this->fk[$row+0][$col+1]=1;
$this->fk[$row+1][$col+1]=1;
$this->fk[$row+2][$col+1]=1;
}
function J_2($row,$col){
$this->fk[$row+0][$col+0]=1;
$this->fk[$row+0][$col+1]=1;
$this->fk[$row+0][$col+2]=1;
$this->fk[$row+1][$col+0]=1;
}
function J_3($row,$col){
$this->fk[$row+0][$col+0]=1;
$this->fk[$row+1][$col+0]=1;
$this->fk[$row+2][$col+0]=1;
$this->fk[$row+2][$col+1]=1;
}
function J_4($row,$col){
$this->fk[$row+0][$col+2]=1;
$this->fk[$row+1][$col+0]=1;
$this->fk[$row+1][$col+1]=1;
$this->fk[$row+1][$col+2]=1;
}
function input_fk($string){
switch($string){
case "J_1":$this->J_1($this->row,$this->col);break;
case "J_2":$this->J_2($this->row,$this->col);break;
case "J_3":$this->J_3($this->row,$this->col);break;
case "J_4":$this->J_4($this->row,$this->col);break;
}
}
function save_table(){
for($i=10;$i>=0;$i--){
for($j=0;$j<18;$j++){
if($this->Table[$i][$j]==1)
$this->save_Table[$i][$j]=$this->Table[$i][$j];
}
}
}
function save_table_show(){
for($i=10;$i>=0;$i--){
for($j=0;$j<18;$j++){
if($this->Table[$i][$j]==1)
echo $this->save_Table[$i][$j];
// $this->save_Table[$i][$j]=$this->Table[$i][$j];
}
}
}
function init(){
for($i=10;$i>=0;$i--){
for($j=0;$j<18;$j++){
$this->Table[$i][$j]=$this->save_Table[$i][$j];
$this->fk[$i][$j]=0;
}
}
echo "";
}
function show(){
for($i=10;$i>=0;$i--){
for($j=0;$j<18;$j++){
if(($this->fk[$i][$j]==1) or ($this->Table[$i][$j]==1)){
$this->Table[$i][$j]=1;
if($this->fk[$i+1][$j]==$this->Table[$i][$j])
$this->Table[$i+1][$j]=1;
}else
$this->Table[$i][$j]=0;
}
}
}
function ToDo(){
for($i=10;$i>=0;$i--){
echo "
for($j=0;$j<18;$j++){
if($this->Table[$i][$j]==0){
echo $this->bmp0;
}else{
echo $this->bmp1;
}
// $this->save_Table[$i][$j]=$this->Table[$i][$j];
}
echo "
";}
echo "
";// echo $this->Table[$i][$j];
}
}
for($i=0;$i<255;$i++){ echo $i;}$game=new dgt_game();/*for($i=10;$i>=0;$i--){ sleep(1); $game->init(); $game->row=3; $game->col=4; $j=mt_rand(1,4); $game->input_fk("J_".$j); $game->show(); $game->ToDo();}*/while(1){ for($i=10;$i>=0;$i--){ // usleep(200000); sleep(1); $game->init(); $game->row=$i; $game->col=10; $j=mt_rand(0,3); $game->input_fk("J_".($j+1)); $game->show(); $game->ToDo(); echo $i; } echo "
"; $game->save_table(); $game->save_table_show();}?>