Desktop applications written in php

Source: Internet
Author: User


Copy the PHP content to the clipboard. PHP code:

<? Php
$ Winmain = wb_create_window (null, AppWindow, 'Point 21 game', WBC_CENTER, WBC_CENTER, 800,495 );
Wb_create_control ($ winmain, Label, 'banker ', 20, 15, 40, 30, LB_1, 0, 0 );
Wb_create_control ($ winmain, Label, 'gamer ', 20,200, LB_2, 0 );
Wb_create_control ($ winmain, Frame, '', 120,150, FR_PC_1, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 120,150, FR_PC_2, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 36120,150, FR_PC_3, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 120,150, 40, FR_PC_4, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 640,40, 120,150, FR_PC_5, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 645,230,120,150, FR_U_5, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 500,230,120,150, FR_U_4, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 360,230,120,150, FR_U_3, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 220,230,120,150, FR_U_2, 0, 0 );
Wb_create_control ($ winmain, Frame, '', 80,230,120,150, FR_U_1, 0, 0 );
Wb_create_control ($ winmain, Label, '', 35,305, LB_U_T, 0 );
Wb_create_control ($ winmain, Label, '', 35,110, LB_P_T, 0 );
Wb_create_control ($ winmain, PushButton, 'licensing ', 320,400, B _GO, 0 x, 0 );
Wb_create_control ($ winmain, PushButton, 'stop', 435,400, B _CHANGE, 0 x, 0 );
Wb_create_control ($ winmain, Label, '', 110,95, 60,60, LB_PC_1, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 95, 60, 60, LB_PC_2, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 390,95, 60,60, LB_PC_3, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 530,95, 60,60, LB_PC_4, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 670,95, 60, 60, LB_PC_5, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 110,285, 60, 60, LB_U_1, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 250,285, 60, 60, LB_U_2, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 390,285, 60, 60, LB_U_3, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 530,285, 60, 60, LB_U_4, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 670,285, 60, 60, LB_U_5, 0x00000800,0, 0 );
Wb_create_control ($ winmain, Label, '', 90, 20, PC_MON, 0 );
Wb_create_control ($ winmain, Label, '', 70,205, 90,20, U_MON, 0 );

Point_shortde.php File


<? Php
For ($ I = 1; $ I <= 13; $ I ++ ){
Switch ($ I ){
Case 1j = 1; $ key = 'a'; break;
Case 11j = 10; $ key = 'J'; break;
Case 12j = 10; $ key = 'q'; break;
Case 13j = 10; $ key = 'K'; break;
Default:
$ Key = $ j = $ I;
}
$ Card [" \ n peach \ n $ key"] = $ j;
$ Card ["Red \ n peach \ n $ key"] = $ j;
$ Card ["Mei \ n flowers \ n $ key"] = $ j;
$ Card ["square \ n slices \ n $ key"] = $ j;
}
$ Contorl_id = array (
'B _ go' => 1001,' B _ change' => 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 File


<? Php
Set_time_limit (0 );
Include_once ('include/winbinder. php ');
Include_once ('form/point_include.php ');
Include_once ('form/21point. form. php ');

Class Ponit {
Public $ key_id;
Private $ user_point = 10000;
Private $ pc_point = 10000;
Private $ card;
Private $ player = 'user ';
Private $ new_term = false;
Private $ remon = false;
Public function _ construct ($ winmain, $ card ){
$ F = file_get_contents ('form/db. db ');
List ($ this-> 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 (
'Game (& G) ', null,
Array (ME_START, "\ tCrtl + N", '','', 'ctrl + N '),
Array (ME_REMON, "scoring "),
Array (ME_AUTHOR, "author "),
Null,
Array (ME_QUIT, "Exit \ tCrtl + Q", '','', 'ctrl + Q '),
Null
));
Wb_set_text (wb_get_control ($ this-> window, U_MON), $ this-> user_point. 'quantity ');
Wb_set_text (wb_get_control ($ this-> window, PC_MON), $ this-> pc_point. 'quantity ');
$ 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 <= 5; $ 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. 'quantity ');
Wb_set_text (wb_get_control ($ this-> window, PC_MON), $ this-> pc_point. 'quantity ');
$ 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. 'quantity ');
Wb_set_text (wb_get_control ($ this-> window, PC_MON), $ this-> pc_point. 'quantity ');
$ 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 <= 5; $ 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. 'point ');
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 <= 21 ){
$ This-> total (20, 'U ');
$ Sel = wb_message_box ($ this-> window, "congratulations, five small players, winning! \ N do you want to continue? ", 'Shengli ', WBC_YESNO );
$ Sel = 1? $ This-> start (): $ this-> stop ();
} Elseif ($ user_total> 21 ){
$ This-> total (20, 'P ');
$ Sel = wb_message_box ($ this-> window, "Unfortunately, the banker wins! \ N do you want to continue? ", 'Failed', 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. 'point ');
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 <= 21 ){
$ This-> total (20, 'P ');
$ Sel = wb_message_box ($ this-> window, "the banker has five pictures, and the banker wins! \ N do you want to continue? ", 'Failed', WBC_YESNO );
$ Sel = 1? $ This-> start (): $ this-> stop ();
} Elseif ($ pc_total> 21 ){
If ($ pc_total-$ card_value <$ user_total ){
$ This-> total (20, 'U ');
$ Sel = wb_message_box ($ this-> window, "congratulations, the number of banker points exceeds 21 and the player wins! \ N do you want to continue? ", 'Shengli ', 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. 'point ');
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 )? "The Banker wins the same number of points on both sides! \ N do you want to continue? ":" The Banker points are bigger than you, and the crops win! \ N do you want to continue? ";
$ Sel = wb_message_box ($ this-> window, $ msg, 'failed', WBC_YESNO );
$ Sel = 1? $ This-> start (): $ this-> stop ();
} Else {
$ This-> total (20, 'U ');
$ Sel = wb_message_box ($ this-> window, "congratulations, the banker points are smaller than you, and the player wins! \ N do you want to continue? ", 'Shengli ', WBC_YESNO );
$ Sel = 1? $ This-> start (): $ this-> stop ();
}
}
} Else {
Usleep (800000 );
$ This-> play ();
}
}
Unset ($ card_tem [$ card_key]);
}

Private function author (){
$ Inf = "Hello everyone, I'm a machine _ horse, \ n. This is the first desktop application in my life. \ n is a bad job. Everyone laughed, hahaha ^_^. \ N \ t Author: machine _ horse ";
$ Author_window = wb_create_window ($ this-> window, ModalDialog, 'author profile ', WBC_CENTER, WBC_CENTER, 360,180, 0x00000000, 0 );
Wb_set_handler ($ author_window, 'author _ handler ');
$ Image = wb_create_control ($ author_window, Frame, '000000', 123, 128,144,110, WBC_IMAGE );
Wb_create_control ($ author_window, Label, $ inf, 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 _ ');
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 );
}
}
?>

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.