复制php内容到剪贴板php代码:
1002,
'me_start'=>2001,'me_remon'=>2002,'me_author'=>2003,'me_quit'=>idclose,
'lb_1'=>3001,'lb_2'=>3002,'lb_u_t'=>3003,'lb_p_t'=>3004,
'pc_mon'=>3005,'u_mon'=>3006,
'lb_pc_1'=>3101,'lb_pc_2'=>3102,'lb_pc_3'=>3103,'lb_pc_4'=>3104,'lb_pc_5'=>3105,
'lb_u_1'=>3201,'lb_u_2'=>3202,'lb_u_3'=>3203,'lb_u_4'=>3204,'lb_u_5'=>3205,
'fr_pc_1'=>4001,'fr_pc_2'=>4002,'fr_pc_3'=>4003,'fr_pc_4'=>4004,'fr_pc_5'=>4005,
'fr_u_1'=>5001,'fr_u_2'=>5002,'fr_u_3'=>5003,'fr_u_4'=>5004,'fr_u_5'=>5005,
);
foreach ($contorl_id as $key=>$value){
if(!defined(strtoupper($key)))define(strtoupper($key),$value);
}
?>
21point.phpw文件
user_point,$this->pc_point)=explode('|',$f);
$this->window=$winmain;
$this->card=$card;
$this->prepare();
}
private function prepare(){
wb_set_image($this->window,'form/hyper.ico');
wb_create_control($this->window,menu,array(
'游戏(&g)' , null,
array(me_start , 开局\tcrtl+n,'','','ctrl+n'),
array(me_remon , 重计分),
array(me_author , 作者),
null ,
array(me_quit , 退出\tcrtl+q,'','','ctrl+q'),
null
));
wb_set_text(wb_get_control($this->window,u_mon),$this->user_point.'分');
wb_set_text(wb_get_control($this->window,pc_mon),$this->pc_point.'分');
$font=wb_create_font(arial, 13, null, fta_bold);
wb_set_font(wb_get_control($this->window,lb_1),$font);
wb_set_font(wb_get_control($this->window,lb_2),$font);
$font=wb_create_font(arial, 34, null, fta_bold);
for($i=1;$i wb_set_font(wb_get_control($this->window,(3100+$i)),$font);
wb_set_font(wb_get_control($this->window,(3200+$i)),$font);
}
}
private function start(){
$this->player='user';
$this->new_term=true;
$this->clear();
$this->play();
wb_set_enabled(wb_get_control($this->window,b_go),true);
wb_set_enabled(wb_get_control($this->window,b_change),true);
}
private function stop(){
wb_set_enabled(wb_get_control($this->window,b_go),false);
wb_set_enabled(wb_get_control($this->window,b_change),false);
}
private function change_player(){
$this->stop();
$this->player='pc';
$this->play();
}
private function total($num=0,$win){
static $u_tem,$p_tem;
if(empty($u_tem)||empty($p_tem)||$this->remon==true){
$u_tem=$this->user_point;
$p_tem=$this->pc_point;
$this->remon=false;
}
if(strtoupper($win)=='u'){
$u_tem+=$num;
$p_tem-=$num;
}else{
$u_tem-=$num;
$p_tem+=$num;
}
$this->user_point=$u_tem;
$this->pc_point=$p_tem;
wb_set_text(wb_get_control($this->window,u_mon),$this->user_point.'分');
wb_set_text(wb_get_control($this->window,pc_mon),$this->pc_point.'分');
$f=fopen('form/db.db','wb');
fwrite($f,$this->user_point.|.$this->pc_point);
fclose($f);
}
private function remon(){
$this->remon=true;
$this->user_point=10000;
$this->pc_point=10000;
wb_set_text(wb_get_control($this->window,u_mon),$this->user_point.'分');
wb_set_text(wb_get_control($this->window,pc_mon),$this->pc_point.'分');
$f=fopen('form/db.db','wb');
fwrite($f,$this->user_point.|.$this->pc_point);
fclose($f);
}
private function clear(){
wb_set_text(wb_get_control($this->window,lb_u_t),'');
wb_set_text(wb_get_control($this->window,lb_p_t),'');
for($i=1;$i wb_set_text(wb_get_control($this->window,(4000+$i)),'');
wb_set_text(wb_get_control($this->window,(5000+$i)),'');
wb_set_text(wb_get_control($this->window,(3100+$i)),'');
wb_set_text(wb_get_control($this->window,(3200+$i)),'');
}
}
private function play(){
static $card_tem=array(),$i=0,$j=0,$user_total=0,$pc_total=0;
if($this->new_term==true){
$card_tem=$this->card;
$this->new_term=false;
$user_total=0;
$pc_total=0;
$i=0;$j=0;
}
if($this->player=='user'){
$i++;
$card_key=array_rand($card_tem);
$card_value=$card_tem[$card_key];
$user_total+=$card_value;
wb_set_text(wb_get_control($this->window,lb_u_t),$user_total.'点');
wb_set_text(wb_get_control($this->window,(5000+$i)),$card_key);
wb_set_text(wb_get_control($this->window,(3200+$i)),$card_value);
if($i>=5 && $user_total $this->total(20,'u');
$sel=wb_message_box($this->window,恭喜你,5张全小,玩家获胜!\n您还想继续玩吗?,'胜利',wbc_yesno);
$sel==1?$this->start():$this->stop();
}elseif($user_total>21){
$this->total(20,'p');
$sel=wb_message_box($this->window,真不幸,超过21点,庄家获胜!\n您还想继续玩吗?,'失败',wbc_yesno);
$sel==1?$this->start():$this->stop();
}
}else{
$j++;
$card_key=array_rand($card_tem);
$card_value=$card_tem[$card_key];
$pc_total+=$card_value;
wb_set_text(wb_get_control($this->window,lb_p_t),$pc_total.'点');
wb_set_text(wb_get_control($this->window,(4000+$j)),$card_key);
wb_set_text(wb_get_control($this->window,(3100+$j)),$card_value);
if($j>=5 && $pc_total $this->total(20,'p');
$sel=wb_message_box($this->window,庄家5张全小,庄家获胜!\n您还想继续玩吗?,'失败',wbc_yesno);
$sel==1?$this->start():$this->stop();
}elseif($pc_total>21){
if( $pc_total-$card_value $this->total(20,'u');
$sel=wb_message_box($this->window,恭喜你,庄家点数超过21点,玩家获胜!\n您还想继续玩吗?,'胜利',wbc_yesno);
$sel==1?$this->start():$this->stop();
}else{
$pc_total=$pc_total-$card_value;
wb_set_text(wb_get_control($this->window,lb_p_t),$pc_total.'点');
wb_set_text(wb_get_control($this->window,(4000+$j)),'');
wb_set_text(wb_get_control($this->window,(3100+$j)),'');
if($pc_total>=$user_total){
$this->total(20,'p');
$msg=($pc_total==$user_total)?双方点数一样,庄家获胜!\n您还想继续玩吗?:庄家点数比你大,庄稼获胜!\n您还想继续玩吗?;
$sel=wb_message_box($this->window,$msg,'失败',wbc_yesno);
$sel==1?$this->start():$this->stop();
}else{
$this->total(20,'u');
$sel=wb_message_box($this->window,恭喜你,庄家点数比你小,玩家获胜!\n您还想继续玩吗?,'胜利',wbc_yesno);
$sel==1?$this->start():$this->stop();
}
}
}else{
usleep(800000);
$this->play();
}
}
unset($card_tem[$card_key]);
}
private function author(){
$inf=大家好,偶是machine_马,\n\n这是我人生中的第一个桌面应用程序,\n\n做得很烂,大家见笑了,哈哈哈^_^。\n\n\n\n\t\t作者:machine_马;
$author_window=wb_create_window($this->window,modaldialog,'作者简介',wbc_center, wbc_center, 360, 180, 0x00000000, 0);
wb_set_handler($author_window,'author_handler');
$image=wb_create_control($author_window,frame,'123',0,0,128,144,110,wbc_image);
wb_create_control($author_window,label,$inf,140,20,200,150,120,wbc_image);
wb_set_image($image, 'form/author.bmp', nocolor);
}
public function main(){
switch ($this->key_id){
case idclose:
wb_destroy_window($this->window); break;
case me_start:
$this->start(); break;
case me_author:
$this->author(); break;
case b_go:
$this->play(); break;
case b_change:
$this->change_player(); break;
case me_remon:
$this->remon(); break;
}
}
}
$wbd=new ponit($winmain,$card);
wb_set_handler($winmain,'go_to');
wb_main_loop();
function go_to($window,$id){
global $wbd;
$wbd->key_id=$id;
return $wbd->main();
}
function author_handler($this_window,$id){
switch($id){
case idclose:
wb_destroy_window($this_window);
}
}
?>
http://www.bkjia.com/phpjc/631916.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/631916.htmltecharticle复制php内容到剪贴板php代码: ?php $winmain=wb_create_window(null,appwindow,'21点游戏',wbc_center,wbc_center,800,495,0,0); wb_create_control($winmain,label,'庄家',20,1...