Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
4123 connectés 

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

jeux

n°1836618
weshwesh94
Posté le 11-01-2009 à 17:47:44  profilanswer
 

Bonjour à tous,
Voila je suis débutant et j'ai entrepris de réaliser un jeu de mémoire. Mon problème et d'écrire un algorithme qui contrôlera les cases des tableaux:
il faudrait que lorsque je clique une première fois, puis une seconde fois et que quand les deux cases soit de la même couleurs , ces deux cases restent activent et quand les couleurs ne sont pas pareils que les cases se désactives. Après plusieurs jours de recherchent je n'arrive pas à avancer.
Merci à vous.
 
Public Class Form1
    Dim tableau1(5, 5) As Button
    Dim tableau2(5, 5) As Button
    Dim i As Integer
    Dim j As Integer
 
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Size = New Size(700, 600)
 
        For i As Integer = 0 To 5
            For j As Integer = 0 To 5
                tableau1(i, j) = New Button
                tableau1(i, j).Visible = True
                Me.Controls.Add(tableau1(i, j))
 
                tableau1(i, j).Tag = i.ToString + ";" + j.ToString
 
                AddHandler tableau1(i, j).Click, AddressOf tableau_Click
 
                tableau1(i, j).Top = i * 100
                tableau1(i, j).Left = j * 100
                tableau1(i, j).Width = 90
                tableau1(i, j).Height = 90
                tableau1(i, j).BackColor = Color.Transparent
            Next
        Next
 
        For i As Integer = 0 To 5
            For j As Integer = 0 To 5
 
                tableau2(i, j) = New Button
 
                tableau2(i, j).Visible = True
                Me.Controls.Add(tableau2(i, j))
 
                tableau2(i, j).Top = i * 100
                tableau2(i, j).Left = j * 100
                tableau2(i, j).Width = 90
                tableau2(i, j).Height = 90
 
 
            Next
        Next
        tableau2(0, 0).BackColor = Color.Yellow
        tableau2(0, 1).BackColor = Color.Yellow
        tableau2(0, 2).BackColor = Color.DarkBlue
        tableau2(0, 3).BackColor = Color.DarkBlue
        tableau2(0, 4).BackColor = Color.AliceBlue
        tableau2(1, 0).BackColor = Color.DarkMagenta
        tableau2(1, 1).BackColor = Color.DarkMagenta
        tableau2(1, 2).BackColor = Color.Indigo
        tableau2(1, 3).BackColor = Color.Indigo
        tableau2(1, 4).BackColor = Color.AliceBlue
        tableau2(1, 5).BackColor = Color.DarkTurquoise
        tableau2(2, 0).BackColor = Color.Maroon
        tableau2(2, 1).BackColor = Color.Maroon
        tableau2(2, 2).BackColor = Color.Orange
        tableau2(2, 3).BackColor = Color.Orange
        tableau2(2, 4).BackColor = Color.Azure
        tableau2(2, 5).BackColor = Color.DarkSeaGreen
        tableau2(3, 0).BackColor = Color.Black
        tableau2(3, 1).BackColor = Color.Black
        tableau2(3, 2).BackColor = Color.Turquoise
        tableau2(3, 3).BackColor = Color.Turquoise
        tableau2(3, 4).BackColor = Color.Azure
        tableau2(3, 5).BackColor = Color.DarkTurquoise
        tableau2(4, 0).BackColor = Color.Beige
        tableau2(4, 1).BackColor = Color.Beige
        tableau2(4, 2).BackColor = Color.BlanchedAlmond
        tableau2(4, 3).BackColor = Color.BlanchedAlmond
        tableau2(4, 4).BackColor = Color.DarkTurquoise
        tableau2(4, 5).BackColor = Color.AliceBlue
        tableau2(5, 0).BackColor = Color.DarkSalmon
        tableau2(5, 1).BackColor = Color.DarkSalmon
        tableau2(5, 2).BackColor = Color.DeepSkyBlue
        tableau2(5, 3).BackColor = Color.DeepSkyBlue
        tableau2(5, 4).BackColor = Color.Goldenrod
        tableau2(5, 5).BackColor = Color.Goldenrod
 
        For i As Integer = 0 To 5
            For j As Integer = 0 To 5
                Randomize()
                Dim value1 As Integer = CInt(Int((6 * Rnd())))
                Dim value2 As Integer = CInt(Int((6 * Rnd())))
 
                Dim button1 As Color = tableau2(i, j).BackColor
                tableau2(i, j).BackColor = tableau2(value1, value2).BackColor
                tableau2(value1, value2).BackColor = button1
 
            Next
        Next
     
    End Sub
    Private Sub tableau_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim coord() As String
 
        coord = Split(sender.tag, ";" )
 
        i = CType(coord(0), Integer)
        j = CType(coord(1), Integer)
 
 
        'Debug.WriteLine("Touche activée" )
 
        If tableau1(i, j).BackColor.Equals(Color.Transparent) Then
 
            tableau1(i, j).Visible = False
        End If
 
    End Sub
 
    Private Sub JOUER_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JOUER.Click
        For i As Integer = 0 To 5
            For j As Integer = 0 To 5
                Randomize()
                Dim value1 As Integer = CInt(Int((6 * Rnd())))
                Dim value2 As Integer = CInt(Int((6 * Rnd())))
 
                Dim button1 As Color = tableau2(i, j).BackColor
                tableau2(i, j).BackColor = tableau2(value1, value2).BackColor
                tableau2(value1, value2).BackColor = button1
 
            Next
        Next
 
    End Sub
End Class

mood
Publicité
Posté le 11-01-2009 à 17:47:44  profilanswer
 

n°1836629
weshwesh94
Posté le 11-01-2009 à 18:31:10  profilanswer
 

PERSONNE????

n°1836990
theShockWa​ve
I work at a firm named Koslow
Posté le 12-01-2009 à 17:12:18  profilanswer
 

tu n'arrives pas à avancer, mais quelle est ta question, précisément ?


---------------
last.fm
n°1837143
weshwesh94
Posté le 12-01-2009 à 23:59:41  profilanswer
 

En faites le joueur clique une première fois sur une case du tableau pour afficher la couleur de celle-ci, puis une deuxième fois sur une autres case. Mon problème réside après ceci. Je n'arrive pas à créer une opération qui me permetrai de vérifier si les couleurs des deux cases sont identique, pour ensuite les laissés afficher ou les rendrent de nouveaux invisibles dans le cas contraire. Merci pour vos réponses.

n°1838094
tegu
Posté le 15-01-2009 à 10:26:05  profilanswer
 

Il faut, dans l'ordre :
1/ que tu saches combien de cases sont appuyées (variable)
2/ que tu puisses comparer les couleurs quand exactement deux cases sont appuyées
3/ laisser activées ou désactiver les cases suivant le résultat du test 2/
 
Où est ton problème ?


Aller à :
Ajouter une réponse
 

Sujets relatifs
Jeux de caractère Mysqlcreation de jeux en ligne
cherche programmeur pour jeux iPhone !PSPprog, créer des jeux en C pour la PSP !
Programmer un jeux de poker sur InternetCreer un systeme de base de donnees poru jeux flash
font importé dans bibliothèque et jeux de caractères? probleme bizarrejeux pour vous ?????
Projet de Jeux vidéo[C/C++] Création de jeux
Plus de sujets relatifs à : jeux


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)