PHP,version,famous,Minesweeper,game,Microsoft
Quick Search for:  in language:    
PHP,version,famous,Minesweeper,game,Microsoft
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
PHP Stats

 Code: 73,711 lines
 Jobs: 9 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for PHP.
PWGen
By Flinn Mueller on 10/19


URHere
By Flinn Mueller on 10/19


MySQL Database Wrapper
By Merlin Corey on 10/16


Click here to see a screenshot of this code!PHP Calender System
By Charles Chadwick on 10/14

(Screen Shot)

Click here to see a screenshot of this code!A1 counter
By Michael Goh on 10/10

(Screen Shot)

Backup MySql
By Keyur Itchhaporia on 10/9


An Important Note About .inc Files
By Charles Chadwick on 10/9


^ A time Saver Script
By Darryl Porter on 10/9


A 1337 Phrase Maker
By Jason DeLuca on 10/8


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

PHP Mine

Print
Email
 
VB icon
Submitted on: 10/29/2000 8:14:33 PM
By: PHP Code Exchange  
Level: Intermediate
User Rating: By 2 Users
Compatibility:PHP 3.0, PHP 4.0

Users have accessed this code 5324 times.
 
 
     PHP version of famous "Minesweeper" game by Microsoft by Mathias Daval
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    //**************************************
    //     
    // Name: PHP Mine
    // Description:PHP version of famous "Mi
    //     nesweeper" game by Microsoft by Mathias 
    //     Daval
    // By: PHP Code Exchange
    //**************************************
    //     
    
    <? 
    /*/////// PHPMINE v1.0 
    ///////// 
    // Copyright 2000, Kidou / PHPVault (htt
    //     p://www.phpvault.com) 
    ////////////////////////////////////////
    ////////////////////////////////// 
    // Ce script est un freeware. Vous pouve
    //     z l'utiliser et le modifier librement, m
    //     ais vous devez laisser le copyright. Mer
    //     ci de me faire savoir si vous trouvez ce
    //     script utile. (mathias@phpvault.com) 
    // PHPMine est une version PHP du célèbr
    //     e jeu "Démineur" de Mirosoft. 
    ////////////////////////////////////////
    ///////////////////////////////// 
    // This script is a freeware. You can us
    //     e it and modify it freely as long as you
    //     leave the copyright. Please tell me if y
    //     ou find this script useful (mathias@phpv
    //     ault.com) 
    // PHPMine is a PHP version of famous ga
    //     me "Minesweeper" by Microsoft. 
    ////////////////////////////////////////
    /////////////////////////////////*/ 
    print "<html>"; 
    print "<head>"; 
    print "<title>PHPVault's PHPMine v1.0</title>"; 
    print "</head>"; 
    print "<body><center>"; 
    print "<font size=4 face=Verdana><b>PHPMine v1.0</b>"; 
    if ($submit=="") { 
    $NumMine=4; 
    $RowSize=5; 
    $ColSize=5; 
    $generer=1; 
    } 
    if ($generer==1) { 
    srand((double)microtime()*100000000); 
    $time_start=time(); 
    if (($RowSize<=1) || ($ColSize<=1) || ($NumMine==0)) { 
    print "<p><br><font size=-1 color=red>Wrong number for Rows, Cols or Mines!</font>"; 
    exit; 
    } 
    if ($NumMine > $RowSize*$ColSize) { 
    print "<p><br><font size=-1 color=red>Too many mines!</font>"; 
    exit; 
    } 
    for ($Row=1;$Row<=$RowSize;$Row++) { 
    for ($Col=1;$Col<=$ColSize;$Col++) { 
    $Mine[$Row][$Col]="0"; 
    $Decouv[$Row][$Col]="0"; 
    } 
    } 
    $index=0; 
    while ($index<$NumMine) { 
    $Row=rand(1,$RowSize); 
    $Col=rand(1,$ColSize); 
    if ($Mine[$Row][$Col]=="0") { 
    $Mine[$Row][$Col]="1"; 
    $index++; 
    } 
    } 
    } else { 
    $perdu=0; 
    $reste=$RowSize*$ColSize; 
    for ($Row=1;$Row<=$RowSize;$Row++) { 
    for ($Col=1;$Col<=$ColSize;$Col++) { 
    $temp="Mine".($Row*($ColSize+1)+$Col); 
    $Mine[$Row][$Col]=$$temp; 
    $temp="Decouv".($Row*($ColSize+1)+$Col); 
    $Decouv[$Row][$Col]=$$temp; 
    if ($Decouv[$Row][$Col]=="1") {$reste=$reste-1;} 
    $temp="submit".($Row*($ColSize+1)+$Col); 
    if ($$temp=="ok") { 
    $reste=$reste-1; 
    if ($Mine[$Row][$Col]=="0") { 
    $Decouv[$Row][$Col]="1"; 
    } else { 
    $perdu=1; 
    } 
    } 
    } 
    } 
    if ($perdu==1) { 
    print "<h2>You Lose!</h2>"; 
    for ($i=1;$i<=$RowSize;$i++) { 
    for ($j=1;$j<=$ColSize;$j++) { 
    $Decouv[$i][$j]="1"; 
    } 
    } 
    } 
    if (($reste==$NumMine)&&($perdu!=1)) { 
    print "<h2>You Win!</h2>"; 
    $time_stop=time(); 
    $time=$time_stop-$time_start; 
    print "<p><font size=-1><i>Your score: $time</i></font>"; 
    for ($i=1;$i<=$RowSize;$i++) { 
    for ($j=1;$j<=$ColSize;$j++) { 
    $Decouv[$i][$j]="1"; 
    } 
    } 
    } 
    } 
    print "<form method=get action=\"$PHP_SELF\">"; 
    print "<input type=hidden name=time_start value=$time_start>"; 
    print "<input type=hidden name=NumMine value=$NumMine>"; 
    print "<input type=hidden name=RowSize value=$RowSize>"; 
    print "<input type=hidden name=ColSize value=$ColSize>"; 
    print "<input type=hidden name=generer value=0>"; 
    print "<p><table border=1 cellpadding=8>"; 
    for ($Row=1; $Row<=$RowSize; $Row++) { 
    print "<tr>"; 
    for ($Col=1; $Col<=$ColSize; $Col++) { 
    $nb=0; 
    for ($i=-1; $i<=1; $i++) { 
    for ($j=-1; $j<=1; $j++) { 
    if ($Mine[$Row+$i][$Col+$j] == "1") { 
    $nb++; 
    } 
    } 
    } 
    print "<td width=15 height=15 align=center valign=middle>"; 
    if ($Decouv[$Row][$Col]=="1") { 
    if ($nb==0) { 
    print " "; 
    } else { 
    if ($Mine[$Row][$Col]=="1") { 
    print "*"; 
    } else { 
    print "$nb"; 
    } 
    } 
    } else { 
    print "<input type=hidden name=submit value=ok>"; 
    print "<input type=submit name=submit".($Row*($ColSize+1)+$Col)." value=ok>"; 
    } 
    print "<input type=hidden name=Mine".($Row*($ColSize+1)+$Col)." value=".$Mine[$Row][$Col].">"; 
    print "<input type=hidden name=Decouv".($Row*($ColSize+1)+$Col)." value=".$Decouv[$Row][$Col].">"; 
    print "</td>"; 
    } 
    print "</tr>"; 
    } 
    print "</table>"; 
    print "</form>"; 
    ?> 
    <hr> 
    <form method=post> 
    Rows :  <input type=text name=RowSize value=5 size=2> 
    <br>Cols :  <input type=text name=ColSize value=5 size=2> 
    <br>Mines :  <input type=text name=NumMine value=4 size=2> 
    <p><input type=submit name=submit value=Generate> 
    <input type=hidden name=generer value=1> 
    </form> 
    <p> 
    <center><font size=-2>(c) 2000, <a href="http://www.phpvault.com">PHPVault</a> - All rights reserved<br>Script by <a href="mailto:perso@kidou.net">Kidou</a> 
    </font> 
    </center> 
    </body> 
    </html>


Other 198 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
12/21/2001 12:36:50 AM:Akshay
The code is really nice i wanna use 
this but i wud like to add in a image 
instead of ok buttons so wot 
modifications i have to make for this i 
have tried it but cudnt get it so in 
case if u write to me it wud be really 
helpful for me my email id is 
akki_n@rediffmail.com, 
akshay_narkar@yahoo.com.
Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | PHP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.