VB icon

PHP Mine

Submitted on: 1/1/2015 3:03:00 AM
By: PHP Code Exchange (from psc cd)  
Level: Intermediate
User Rating: By 5 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 6854
     PHP version of famous "Minesweeper" game by Microsoft by Mathias Daval
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 "Minesweeper" game by Microsoft by Mathias Daval
// By: PHP Code Exchange (from psc cd)

/*/////// PHPMINE v1.0 
// Copyright 2000, Kidou / PHPVault (http://www.phpvault.com) 
// Ce script est un freeware. Vous pouvez l'utiliser et le modifier librement, mais vous devez laisser le copyright. Merci de me faire savoir si vous trouvez ce script utile. (mathias@phpvault.com) 
// PHPMine est une version PHP du célèbre jeu "Démineur" de Mirosoft. 
// This script is a freeware. You can use it and modify it freely as long as you leave the copyright. Please tell me if you find this script useful (mathias@phpvault.com) 
// PHPMine is a PHP version of famous game "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=="") { 
if ($generer==1) { 
 if (($RowSize<=1) || ($ColSize<=1) || ($NumMine==0)) { 
 print "<p><br><font size=-1 color=red>Wrong number for Rows, Cols or Mines!</font>"; 
 if ($NumMine > $RowSize*$ColSize) { 
 print "<p><br><font size=-1 color=red>Too many mines!</font>"; 
 for ($Row=1;$Row<=$RowSize;$Row++) { 
 for ($Col=1;$Col<=$ColSize;$Col++) { 
 while ($index<$NumMine) { 
 if ($Mine[$Row][$Col]=="0") { 
} else { 
 for ($Row=1;$Row<=$RowSize;$Row++) { 
 for ($Col=1;$Col<=$ColSize;$Col++) { 
 if ($Decouv[$Row][$Col]=="1") {$reste=$reste-1;} 
 if ($$temp=="ok") { 
 if ($Mine[$Row][$Col]=="0") { 
 } else { 
 if ($perdu==1) { 
 print "<h2>You Lose!</h2>"; 
 for ($i=1;$i<=$RowSize;$i++) { 
 for ($j=1;$j<=$ColSize;$j++) { 
 if (($reste==$NumMine)&&($perdu!=1)) { 
 print "<h2>You Win!</h2>"; 
 print "<p><font size=-1><i>Your score: $time</i></font>"; 
 for ($i=1;$i<=$RowSize;$i++) { 
 for ($j=1;$j<=$ColSize;$j++) { 
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++) { 
 for ($i=-1; $i<=1; $i++) { 
 for ($j=-1; $j<=1; $j++) { 
 if ($Mine[$Row+$i][$Col+$j] == "1") { 
 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>"; 
<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> 
<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> 

Other 13 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

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

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)

To post feedback, first please login.