Thema Datum  Von Nutzer Rating
Antwort
Rot Tic Tac Toe Projekt
26.06.2016 12:46:15 Paddy
NotSolved

Ansicht des Beitrags:
Von:
Paddy
Datum:
26.06.2016 12:46:15
Views:
1066
Rating: Antwort:
  Ja
Thema:
Tic Tac Toe Projekt

Hallo Leute,

 

ich habe ein Frage bezüglich eines Projekts. Es ist so das ich ein kleines Spiel gestalten und programmieren muss und ich bei verschiedenen Stellen keine Lösung finde. Da Aktuell die EM ist, wollte ich ein EM-TIC-TAC-TOE machen, was mir bis hierher auch gelungen ist. Es ist so aufgebaut, dass man eine Mannschaft auswählen kann und dann bis 5 Spielt. Nun werde ich euch mal meine Probleme oder meine Vorstellungen aufzeigen, vor denen ich noch stehe.

- Man soll bevor man kein Land ausgewählt hat, nicht spielen dürfen.

- Wenn z.B. Spieler "X", 5 mal gewonnen hat, soll eine MessageBox erscheinen, in der steht das Land "...." gewonnen hat. Welche ich zuvor in der Arbeitsmappe als Tabelle angelegt habe.

- Bei Unentschieden sollte man ohne auf die Unentschieden Taste drücken zu müssen direkt weiter spielen können.

- Während des Spiels soll es nicht möglich sein die Länder zu tauschen oder zu ändern. Nur immer am Anfang eines SPieles.

Ich bin nicht der Programmier Profi und wollte euch desshalb um Hilfe fragen, da ich schon sehr lang an der Lösung des Problems sitze, aber nicht weiter komme. Wenn mir jemand Tipps geben könnte,  meinen Code verfollständigen könnte oder mir in irgendeiner Art und weise helfen könnte, wäre ich sehr dankbar.

Hier mal mein bisheriger Code: 

Option Explicit
Dim checker As Boolean


Private Sub ComboBox1_Change()
    Image2.Picture = LoadPicture(ThisWorkbook.Path & "\" & ComboBox1.Value & ".jpg")
End Sub

Private Sub ComboBox2_Change()
    Image3.Picture = LoadPicture(ThisWorkbook.Path & "\" & ComboBox2.Value & ".jpg")
End Sub

Private Sub btnTic1_Click()
    If checker = False Then
        btnTic1.Caption = "X"
        checker = True
    Else
        btnTic1.Caption = "O"
        checker = False
    End If
    btnTic1.Enabled = False
    Call score
        
End Sub

Private Sub btnTic2_Click()
    If checker = False Then
        btnTic2.Caption = "X"
        checker = True
    Else
        btnTic2.Caption = "O"
        checker = False
    End If
    btnTic2.Enabled = False
    Call score
        
End Sub

Private Sub btnTic3_Click()
    If checker = False Then
        btnTic3.Caption = "X"
        checker = True
    Else
        btnTic3.Caption = "O"
        checker = False
    End If
    btnTic3.Enabled = False
    Call score
        
End Sub

Private Sub btnTic4_Click()
    If checker = False Then
        btnTic4.Caption = "X"
        checker = True
    Else
        btnTic4.Caption = "O"
        checker = False
    End If
    btnTic4.Enabled = False
    Call score
        
End Sub

Private Sub btnTic5_Click()
    If checker = False Then
        btnTic5.Caption = "X"
        checker = True
    Else
        btnTic5.Caption = "O"
        checker = False
    End If
    btnTic5.Enabled = False
    Call score
        
End Sub

Private Sub btnTic6_Click()
    If checker = False Then
        btnTic6.Caption = "X"
        checker = True
    Else
        btnTic6.Caption = "O"
        checker = False
    End If
    btnTic6.Enabled = False
    Call score
        
End Sub

Private Sub btnTic7_Click()
    If checker = False Then
        btnTic7.Caption = "X"
        checker = True
    Else
        btnTic7.Caption = "O"
        checker = False
    End If
    btnTic7.Enabled = False
    Call score
        
End Sub

Private Sub btnTic8_Click()
    If checker = False Then
        btnTic8.Caption = "X"
        checker = True
    Else
        btnTic8.Caption = "O"
        checker = False
    End If
    btnTic8.Enabled = False
    Call score
        
End Sub

Private Sub btnTic9_Click()
    If checker = False Then
        btnTic9.Caption = "X"
        checker = True
    Else
        btnTic9.Caption = "O"
        checker = False
    End If
    btnTic9.Enabled = False
    Call score
        
End Sub

Private Sub btnStart_Click()
    MsgBox "Wählen Sie ein Land aus!", vbInformation
    btnTic1.Caption = ""
    btnTic2.Caption = ""
    btnTic3.Caption = ""
    btnTic4.Caption = ""
    btnTic5.Caption = ""
    btnTic6.Caption = ""
    btnTic7.Caption = ""
    btnTic8.Caption = ""
    btnTic9.Caption = ""
    Spieler1.Caption = 0
    Spieler2.Caption = 0
    btnStart = "Neues Spiel"

    btnTic1.Enabled = True
    btnTic2.Enabled = True
    btnTic3.Enabled = True
    btnTic4.Enabled = True
    btnTic5.Enabled = True
    btnTic6.Enabled = True
    btnTic7.Enabled = True
    btnTic8.Enabled = True
    btnTic9.Enabled = True
    btnStart.Enabled = True

    btnTic1.BackColor = &H4000&
    btnTic2.BackColor = &H4000&
    btnTic3.BackColor = &H4000&
    btnTic4.BackColor = &H4000&
    btnTic5.BackColor = &H4000&
    btnTic6.BackColor = &H4000&
    btnTic7.BackColor = &H4000&
    btnTic8.BackColor = &H4000&
    btnTic9.BackColor = &H4000&
End Sub



Private Sub score()

    If btnTic1.Caption = "X" And btnTic2.Caption = "X" And btnTic3.Caption = "X" Then
        btnTic1.BackColor = &H0&
        btnTic2.BackColor = &H0&
        btnTic3.BackColor = &H0&
        MsgBox "Spieler 1 hat die Runde gewonnen!", vbInformation
        Spieler1.Caption = Spieler1.Caption + 1
    Call Enable_False
    End If
    
    If btnTic1.Caption = "X" And btnTic4.Caption = "X" And btnTic7.Caption = "X" Then
        btnTic1.BackColor = &H0&
        btnTic4.BackColor = &H0&
        btnTic7.BackColor = &H0&
        MsgBox "Spieler 1 hat die Runde gewonnen!", vbInformation
        Spieler1.Caption = Spieler1.Caption + 1
    Call Enable_False
    End If
    
    If btnTic1.Caption = "X" And btnTic5.Caption = "X" And btnTic9.Caption = "X" Then
        btnTic1.BackColor = &H0&
        btnTic5.BackColor = &H0&
        btnTic9.BackColor = &H0&
        MsgBox "Spieler 1 hat die Runde gewonnen!", vbInformation
        Spieler1.Caption = Spieler1.Caption + 1
    Call Enable_False
    End If
    
    If btnTic3.Caption = "X" And btnTic5.Caption = "X" And btnTic7.Caption = "X" Then
        btnTic3.BackColor = &H0&
        btnTic5.BackColor = &H0&
        btnTic7.BackColor = &H0&
        MsgBox "Spieler 1 hat die Runde gewonnen!", vbInformation
        Spieler1.Caption = Spieler1.Caption + 1
    Call Enable_False
    End If
    
    If btnTic2.Caption = "X" And btnTic5.Caption = "X" And btnTic8.Caption = "X" Then
        btnTic2.BackColor = &H0&
        btnTic5.BackColor = &H0&
        btnTic8.BackColor = &H0&
        MsgBox "Spieler 1 hat die Runde gewonnen!", vbInformation
        Spieler1.Caption = Spieler1.Caption + 1
    Call Enable_False
    End If
    
    If btnTic3.Caption = "X" And btnTic6.Caption = "X" And btnTic9.Caption = "X" Then
        btnTic3.BackColor = &H0&
        btnTic6.BackColor = &H0&
        btnTic9.BackColor = &H0&
        MsgBox "Spieler 1 hat die Runde gewonnen!", vbInformation
        Spieler1.Caption = Spieler1.Caption + 1
    Call Enable_False
    End If
    
    If btnTic4.Caption = "X" And btnTic5.Caption = "X" And btnTic6.Caption = "X" Then
        btnTic4.BackColor = &H0&
        btnTic5.BackColor = &H0&
        btnTic6.BackColor = &H0&
        MsgBox "Spieler 1 hat die Runde gewonnen!", vbInformation
        Spieler1.Caption = Spieler1.Caption + 1
    Call Enable_False
    End If
    
    If btnTic7.Caption = "X" And btnTic8.Caption = "X" And btnTic9.Caption = "X" Then
        btnTic7.BackColor = &H0&
        btnTic8.BackColor = &H0&
        btnTic9.BackColor = &H0&
        MsgBox "Spieler 1 hat die Runde gewonnen!", vbInformation
        Spieler1.Caption = Spieler1.Caption + 1
    Call Enable_False
    End If

    If btnTic1.Caption = "O" And btnTic2.Caption = "O" And btnTic3.Caption = "O" Then
        btnTic1.BackColor = &H0&
        btnTic2.BackColor = &H0&
        btnTic3.BackColor = &H0&
        MsgBox "Spieler 2 hat die Runde gewonnen!", vbInformation
        Spieler2.Caption = Spieler2.Caption + 1
    Call Enable_False
    End If
    
    If btnTic1.Caption = "O" And btnTic4.Caption = "O" And btnTic7.Caption = "O" Then
        btnTic1.BackColor = &H0&
        btnTic4.BackColor = &H0&
        btnTic7.BackColor = &H0&
        MsgBox "Spieler 2 hat die Runde gewonnen!", vbInformation
        Spieler2.Caption = Spieler2.Caption + 1
    Call Enable_False
    End If
    
    If btnTic1.Caption = "O" And btnTic5.Caption = "O" And btnTic9.Caption = "O" Then
        btnTic1.BackColor = &H0&
        btnTic5.BackColor = &H0&
        btnTic9.BackColor = &H0&
        MsgBox "Spieler 2 hat die Runde gewonnen!", vbInformation
        Spieler2.Caption = Spieler2.Caption + 1
    Call Enable_False
    End If
    
    If btnTic3.Caption = "O" And btnTic5.Caption = "O" And btnTic7.Caption = "O" Then
        btnTic3.BackColor = &H0&
        btnTic5.BackColor = &H0&
        btnTic7.BackColor = &H0&
        MsgBox "Spieler 2 hat die Runde gewonnen!", vbInformation
        Spieler2.Caption = Spieler2.Caption + 1
    Call Enable_False
    End If
    
    If btnTic2.Caption = "O" And btnTic5.Caption = "O" And btnTic8.Caption = "O" Then
        btnTic2.BackColor = &H0&
        btnTic5.BackColor = &H0&
        btnTic8.BackColor = &H0&
        MsgBox "Spieler 2 hat die Runde gewonnen!", vbInformation
        Spieler2.Caption = Spieler2.Caption + 1
    Call Enable_False
    End If
    
    If btnTic3.Caption = "O" And btnTic6.Caption = "O" And btnTic9.Caption = "O" Then
        btnTic3.BackColor = &H0&
        btnTic6.BackColor = &H0&
        btnTic9.BackColor = &H0&
        MsgBox "Spieler 2 hat die Runde gewonnen!", vbInformation
        Spieler2.Caption = Spieler2.Caption + 1
    Call Enable_False
    End If
    
    If btnTic4.Caption = "O" And btnTic5.Caption = "O" And btnTic6.Caption = "O" Then
        btnTic4.BackColor = &H0&
        btnTic5.BackColor = &H0&
        btnTic6.BackColor = &H0&
        MsgBox "Spieler 2 hat die Runde gewonnen!", vbInformation
        Spieler2.Caption = Spieler2.Caption + 1
    Call Enable_False
    End If
    
    If btnTic7.Caption = "O" And btnTic8.Caption = "O" And btnTic9.Caption = "O" Then
        btnTic7.BackColor = &H0&
        btnTic8.BackColor = &H0&
        btnTic9.BackColor = &H0&
        MsgBox "Spieler 2 hat die Runde gewonnen!", vbInformation
        Spieler2.Caption = Spieler2.Caption + 1
    Call Enable_False
    End If

    If Spieler1.Caption = 5 Then
        MsgBox "Spieler 1 hat das Match gewonnen!!!", vbInformation
        Spieler1.Caption = 0
    End If
    
     If Spieler2.Caption = 5 Then
        MsgBox "Spieler 2 hat das Match gewonnen!!!", vbInformation
        Spieler2.Caption = 0
    End If

End Sub

Private Sub Enable_False()
    
    btnTic1.Enabled = False
    btnTic2.Enabled = False
    btnTic3.Enabled = False
    btnTic4.Enabled = False
    btnTic5.Enabled = False
    btnTic6.Enabled = False
    btnTic7.Enabled = False
    btnTic8.Enabled = False
    btnTic9.Enabled = False
    Call Reset

End Sub

Private Sub Reset()
    
    btnTic1.Caption = ""
    btnTic2.Caption = ""
    btnTic3.Caption = ""
    btnTic4.Caption = ""
    btnTic5.Caption = ""
    btnTic6.Caption = ""
    btnTic7.Caption = ""
    btnTic8.Caption = ""
    btnTic9.Caption = ""

    btnTic1.Enabled = True
    btnTic2.Enabled = True
    btnTic3.Enabled = True
    btnTic4.Enabled = True
    btnTic5.Enabled = True
    btnTic6.Enabled = True
    btnTic7.Enabled = True
    btnTic8.Enabled = True
    btnTic9.Enabled = True
    btnStart.Enabled = True

    btnTic1.BackColor = &H4000&
    btnTic2.BackColor = &H4000&
    btnTic3.BackColor = &H4000&
    btnTic4.BackColor = &H4000&
    btnTic5.BackColor = &H4000&
    btnTic6.BackColor = &H4000&
    btnTic7.BackColor = &H4000&
    btnTic8.BackColor = &H4000&
    btnTic9.BackColor = &H4000&
    btnStart.BackColor = &H4000&
    
End Sub

Mit freundlichen Grüßen

Paddy


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:

 
 

  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
Rot Tic Tac Toe Projekt
26.06.2016 12:46:15 Paddy
NotSolved