Accueil > > > DÉMINEUR EN JAVASCRIPT
DÉMINEUR EN JAVASCRIPT
Information sur la source
Description
Tout est dans le titre !!!
Source
- < ============= game.html ==============>
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <HTML><HEAD>
- <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
- <META content="MSHTML 6.00.2800.1515" name=GENERATOR><title>Démineur</title></HEAD>
- <BODY text=#000000>
- <BR>
- <BLOCKQUOTE>
- <H1>Démineur en JavaScript !</H1>
- <H1>Bonne partie !</H1>
- <P></P></BLOCKQUOTE></BODY></HTML>
-
-
- <============== side.html ================>
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <HTML><HEAD>
- <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
- <SCRIPT language=JavaScript>
-
- <!--
- /*
- Script written in November 1996 by VBP
- Contact: vbp@via.ecp.fr or http://www.via.ecp.fr/~vbp/
- */
-
- mark = false
-
- function LoadGame(nbCols, nbRows, nbMines) {
- cols = nbCols
- rows = nbRows
- mines = nbMines
- document.init_form.columns.value = cols
- document.init_form.rows.value = rows
- document.init_form.mines.value = mines
- unmarked_mines = mines
- left = cols*rows - mines
- stat = document.init_form.status
- stat.value = 'Lancement...'
- doc = parent.game.document
- doc.close()
- doc.open('text/html')
- doc.bgColor = "#FDEAB9"
- doc.write('<H1>Lancement, veuillez patienter...</H1>')
- doc.close()
- field = new MineField()
- for (var k = 0; k < mines; k++) AddMine()
- doc.open('text/html')
- doc.bgColor = "#FFFFFF"
- doc.write(Table())
- doc.close()
- RefreshStatus()
- first = true
- mark = false
- HandsOff()
- }
-
- function Personalized(form) {
- nbCols = form.columns.value
- nbRows = form.rows.value
- nbMines = form.mines.value
- if ( nbMines > nbCols*nbRows/2) {
- alert('Trop de mines')
- }
- else LoadGame(nbCols, nbRows, nbMines)
- }
-
- function format(n) {
- if ( n < 10 )
- var strg = '0'
- else
- var strg = ''
- return strg + n
- }
-
- function Table() {
- var strg = '<CENTER>\n\n<P><FORM NAME="mineField">\n\n</P>\n\n<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">\n'
- for (var i = 0; i < rows ; i++) {
- strg += '<TR>\n'
- for (var j = 0; j < cols; j++)
- strg += '<TD><INPUT TYPE="button" VALUE=" " NAME="' + format(i) + format(j) + '" onClick="parent.init.Check(this)"></TD>\n'
- strg += '</TR>\n'
- }
- strg += '</TABLE>\n\n</FORM>\n'
- return strg
- }
-
- function HandsOff() {
- document.init_form.columns.focus()
- }
-
- function ChangeMark(box) {
- mark = !mark
- box.focus()
- }
-
- function MineField() {
- for (var i = 0; i < rows; i++) {
- this[i] = new Array(cols)
- for (var j = 0; j < cols; j++) this[i][j] = false
- }
- return this
- }
-
- function AddMine() {
- var i_r = Math.floor(Math.random()*rows)
- var j_r = Math.floor(Math.random()*cols)
- while ( field[i_r][j_r] ) {
- i_r = Math.floor(Math.random()*rows)
- j_r = Math.floor(Math.random()*cols)
- }
- field[i_r][j_r] = true
- }
-
- function RefreshStatus() {
- if ( unmarked_mines == 1 || unmarked_mines == 0)
- stat.value = unmarked_mines + ' Mines Restantes'
- else
- stat.value = unmarked_mines + ' Mines Restantes'
- }
-
- function Check(button) {
- if ( mark ) {
- if ( button.value == ' ' ) {
- button.value = 'M'
- unmarked_mines--
- RefreshStatus()
- }
- else if ( button.value == 'M' ) {
- button.value = ' '
- unmarked_mines++
- RefreshStatus()
- }
- }
- else if ( button.value == ' ' ) {
- var ci = eval(button.name.substring(0, 2))
- var cj = eval(button.name.substring(2, 4))
- if ( first ) {
- if ( field[ci][cj] ) {
- AddMine()
- field[ci][cj] = false
- }
- first = false
- }
- if ( field[ci][cj] ) {
- stat.value = 'Tu as perdu! :-('
- ShowMines(ci, cj)
- alert('BOOM! TU AS PERDU!')
- }
- else {
- button.value = Count(ci, cj)
- if ( button.value == 0 ) with (Math) {
- for (var i = max(0, ci-1); i < min(rows, ci+2); i++)
- for (var j = max(0, cj-1); j < min(cols, cj+2); j++)
- Check(parent.game.document.mineField.elements[i*cols+j])
- }
- left--
- if ( left == 0 ) {
- stat.value = 'TU AS GAGNÉ! :-)'
- ShowMines(-1, -1)
- alert('BRAVO! TU AS GAGNÉ!')
- }
- }
- }
- mark = false
- HandsOff()
- }
-
- function Count(ci, cj) {
- var k = 0
- with (Math) {
- for (var i = max(0, ci-1); i < min(rows, ci+2); i++)
- for (var j = max(0, cj-1); j < min(cols, cj+2); j++)
- if ( field[i][j] ) k++
- }
- return k
- }
-
- function ShowMines(ci, cj) {
- for (var i = 0; i < rows; i++)
- for (var j = 0; j < cols; j++)
- if ( field[i][j] )
- parent.game.document.mineField.elements[i*cols+j].value = 'M'
- else if ( parent.game.document.mineField.elements[i*cols+j].value == ' ' )
- parent.game.document.mineField.elements[i*cols+j].value = ' '
- else if ( parent.game.document.mineField.elements[i*cols+j].value == 'M' )
- parent.game.document.mineField.elements[i*cols+j].value = 'E'
- if ( ci != -1 )
- parent.game.document.mineField.elements[ci*cols+cj].value = 'K'
- }
-
- // -->
-
- </SCRIPT>
-
- <META content="MSHTML 6.00.2800.1515" name=GENERATOR><title>Démineur</title></HEAD>
- <BODY>
- <FORM name=init_form>
- <CENTER>
- <INPUT onfocus=ChangeMark(document.init_form.columns) size=15
- value=Bienvenue ! name=status>
- <BR>
- <STRONG><FONT
- size=+2>Choisissez:</FONT></STRONG>
- <HR>
- <INPUT onfocus=HandsOff() onclick="LoadGame(8, 4, 4)" type=button value=Débutant>
- <HR>
- <INPUT onfocus=HandsOff() onclick="LoadGame(14, 8, 20)" type=button value=Moyen>
- <HR>
- <INPUT onfocus=HandsOff() onclick="LoadGame(20, 12, 50)" type=button value=Expert>
- <HR>
-
- <TABLE border=0>
- <TBODY>
- <TR>
- <TH colSpan=2><INPUT onfocus=HandsOff() onclick=Personalized(this.form) type=button value=Personalisé></TH>
- <TR>
- <TD>Colones :</TD>
- <TD><INPUT maxLength=2 size=2 name=columns></TD></TR>
- <TR>
- <TD>Rangée :</TD>
- <TD><INPUT onfocus=ChangeMark(this) maxLength=2 size=2 name=rows></TD></TR>
- <TR>
- <TD>Mines :</TD>
- <TD><INPUT onfocus=ChangeMark(this) maxLength=2 size=2
- name=mines></TD></TR></TBODY></TABLE>
- </CENTER></FORM></BODY></HTML>
-
-
- <============= demineur.html ============>
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
-
- <HTML><HEAD><TITLE>Démineur</TITLE>
- <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
- <META content="MSHTML 6.00.2800.1515" name=GENERATOR></HEAD><FRAMESET
- cols=140,*><FRAME name=init marginWidth=0 marginHeight=0
- src="side.html" noresize><FRAME name=game
- marginWidth=0 marginHeight=0
- src="game.html" noresize></FRAMESET><noframes></noframes></HTML>
< ============= game.html ==============>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1515" name=GENERATOR><title>Démineur</title></HEAD>
<BODY text=#000000>
<BR>
<BLOCKQUOTE>
<H1>Démineur en JavaScript !</H1>
<H1>Bonne partie !</H1>
<P></P></BLOCKQUOTE></BODY></HTML>
<============== side.html ================>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<SCRIPT language=JavaScript>
<!--
/*
Script written in November 1996 by VBP
Contact: vbp@via.ecp.fr or http://www.via.ecp.fr/~vbp/
*/
mark = false
function LoadGame(nbCols, nbRows, nbMines) {
cols = nbCols
rows = nbRows
mines = nbMines
document.init_form.columns.value = cols
document.init_form.rows.value = rows
document.init_form.mines.value = mines
unmarked_mines = mines
left = cols*rows - mines
stat = document.init_form.status
stat.value = 'Lancement...'
doc = parent.game.document
doc.close()
doc.open('text/html')
doc.bgColor = "#FDEAB9"
doc.write('<H1>Lancement, veuillez patienter...</H1>')
doc.close()
field = new MineField()
for (var k = 0; k < mines; k++) AddMine()
doc.open('text/html')
doc.bgColor = "#FFFFFF"
doc.write(Table())
doc.close()
RefreshStatus()
first = true
mark = false
HandsOff()
}
function Personalized(form) {
nbCols = form.columns.value
nbRows = form.rows.value
nbMines = form.mines.value
if ( nbMines > nbCols*nbRows/2) {
alert('Trop de mines')
}
else LoadGame(nbCols, nbRows, nbMines)
}
function format(n) {
if ( n < 10 )
var strg = '0'
else
var strg = ''
return strg + n
}
function Table() {
var strg = '<CENTER>\n\n<P><FORM NAME="mineField">\n\n</P>\n\n<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">\n'
for (var i = 0; i < rows ; i++) {
strg += '<TR>\n'
for (var j = 0; j < cols; j++)
strg += '<TD><INPUT TYPE="button" VALUE=" " NAME="' + format(i) + format(j) + '" onClick="parent.init.Check(this)"></TD>\n'
strg += '</TR>\n'
}
strg += '</TABLE>\n\n</FORM>\n'
return strg
}
function HandsOff() {
document.init_form.columns.focus()
}
function ChangeMark(box) {
mark = !mark
box.focus()
}
function MineField() {
for (var i = 0; i < rows; i++) {
this[i] = new Array(cols)
for (var j = 0; j < cols; j++) this[i][j] = false
}
return this
}
function AddMine() {
var i_r = Math.floor(Math.random()*rows)
var j_r = Math.floor(Math.random()*cols)
while ( field[i_r][j_r] ) {
i_r = Math.floor(Math.random()*rows)
j_r = Math.floor(Math.random()*cols)
}
field[i_r][j_r] = true
}
function RefreshStatus() {
if ( unmarked_mines == 1 || unmarked_mines == 0)
stat.value = unmarked_mines + ' Mines Restantes'
else
stat.value = unmarked_mines + ' Mines Restantes'
}
function Check(button) {
if ( mark ) {
if ( button.value == ' ' ) {
button.value = 'M'
unmarked_mines--
RefreshStatus()
}
else if ( button.value == 'M' ) {
button.value = ' '
unmarked_mines++
RefreshStatus()
}
}
else if ( button.value == ' ' ) {
var ci = eval(button.name.substring(0, 2))
var cj = eval(button.name.substring(2, 4))
if ( first ) {
if ( field[ci][cj] ) {
AddMine()
field[ci][cj] = false
}
first = false
}
if ( field[ci][cj] ) {
stat.value = 'Tu as perdu! :-('
ShowMines(ci, cj)
alert('BOOM! TU AS PERDU!')
}
else {
button.value = Count(ci, cj)
if ( button.value == 0 ) with (Math) {
for (var i = max(0, ci-1); i < min(rows, ci+2); i++)
for (var j = max(0, cj-1); j < min(cols, cj+2); j++)
Check(parent.game.document.mineField.elements[i*cols+j])
}
left--
if ( left == 0 ) {
stat.value = 'TU AS GAGNÉ! :-)'
ShowMines(-1, -1)
alert('BRAVO! TU AS GAGNÉ!')
}
}
}
mark = false
HandsOff()
}
function Count(ci, cj) {
var k = 0
with (Math) {
for (var i = max(0, ci-1); i < min(rows, ci+2); i++)
for (var j = max(0, cj-1); j < min(cols, cj+2); j++)
if ( field[i][j] ) k++
}
return k
}
function ShowMines(ci, cj) {
for (var i = 0; i < rows; i++)
for (var j = 0; j < cols; j++)
if ( field[i][j] )
parent.game.document.mineField.elements[i*cols+j].value = 'M'
else if ( parent.game.document.mineField.elements[i*cols+j].value == ' ' )
parent.game.document.mineField.elements[i*cols+j].value = ' '
else if ( parent.game.document.mineField.elements[i*cols+j].value == 'M' )
parent.game.document.mineField.elements[i*cols+j].value = 'E'
if ( ci != -1 )
parent.game.document.mineField.elements[ci*cols+cj].value = 'K'
}
// -->
</SCRIPT>
<META content="MSHTML 6.00.2800.1515" name=GENERATOR><title>Démineur</title></HEAD>
<BODY>
<FORM name=init_form>
<CENTER>
<INPUT onfocus=ChangeMark(document.init_form.columns) size=15
value=Bienvenue ! name=status>
<BR>
<STRONG><FONT
size=+2>Choisissez:</FONT></STRONG>
<HR>
<INPUT onfocus=HandsOff() onclick="LoadGame(8, 4, 4)" type=button value=Débutant>
<HR>
<INPUT onfocus=HandsOff() onclick="LoadGame(14, 8, 20)" type=button value=Moyen>
<HR>
<INPUT onfocus=HandsOff() onclick="LoadGame(20, 12, 50)" type=button value=Expert>
<HR>
<TABLE border=0>
<TBODY>
<TR>
<TH colSpan=2><INPUT onfocus=HandsOff() onclick=Personalized(this.form) type=button value=Personalisé></TH>
<TR>
<TD>Colones :</TD>
<TD><INPUT maxLength=2 size=2 name=columns></TD></TR>
<TR>
<TD>Rangée :</TD>
<TD><INPUT onfocus=ChangeMark(this) maxLength=2 size=2 name=rows></TD></TR>
<TR>
<TD>Mines :</TD>
<TD><INPUT onfocus=ChangeMark(this) maxLength=2 size=2
name=mines></TD></TR></TBODY></TABLE>
</CENTER></FORM></BODY></HTML>
<============= demineur.html ============>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<HTML><HEAD><TITLE>Démineur</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1515" name=GENERATOR></HEAD><FRAMESET
cols=140,*><FRAME name=init marginWidth=0 marginHeight=0
src="side.html" noresize><FRAME name=game
marginWidth=0 marginHeight=0
src="game.html" noresize></FRAMESET><noframes></noframes></HTML>
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
jeu de nim [ par matcheu ]
salu est ce que quelqun sait programmé le jeu de nim en perl
Boutons radios? [ par dufour137 ]
bonjour tout le monde, j'aimerais svoir comment faire pour tester une valeure dans une page htm sur un bouton radio pour ouvrir une page internet selo
PRoblème en javascript, jeu de pendu [ par Chihiro ]
Voilà, j'ai un gros problème dans mon script qui ne marche pas, parce que je suis vraiment nulle en programmation... Est ce que quelqu'un pourrait y j
Tester Labyrinthus v2.8 améliorer mon jeu [ par yanndroniou ]
Yann Droniou<img src=/imgs2/smile_approve.gif border=0 align="absmiddle"
Stratégie de jeu [ par ralota ]
Je souhaite créer un jeu en ligne utilisant javascript et php comme langages. Ce jeu consiste à déplacer des poins tout comme l'échec mais il s'agit d
Instit en détresse besoin d'aide - javascript [ par jojosse25 ]
AideJ'essaie de fabriquer un jeu pour des enfants de l'école.Deux frames : à gauche la page jeu ( image mappée )à droite la réponse avec commentaire (
jeu de memoire [ par gladysxxl ]
bonjour,petit souci avec le jeu de memoire ( http://www.javascriptfr.com/code.aspx?ID=22785 ) qui fonctionne tres bien en local mais lorsque je me le
Enregistrer un formulaire sur le hd [ par Ouk18 ]
J'ai fait ce formulaire<htm><head> <title>Questionaire</title></head> <Body> <center><u>Lancer le jeu
Création d'un petit jeu labyrinthe [ par Sibelle07 ]
Salut j'aimerait créer un labyrinthe en javascript , avec une image comme personnage mais ce personnage je voudrait que sa soit crash bandicoot ,
le jeu des paires [ par fabiennerey ]
Fab Bonjour Je tiens d'abord à vous féliciter pour votre site. Je possède un macintosh et je voudrais savoir s'il existe une version ma
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|