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
[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|