Warfans
Benvenuti!!!!! Warfans è il forum più completo che riguarda computer e giochi di qualsiasi tipo!!!! ! Che aspettate? Iscrivetevi ed entrerete nella nostra community

1- L'utente continuando la navigazione nel sito dichiara di aver letto attentamente il Regolamento.
2- Tutti i nuovi Utenti sono pregati di presentarsi nella sezione Presentazioni.
3- Lo Staff cerca: Moderatori, Coder, Graphic. Se vi interessa scrivete il Curriculum nella sezione Zona Reclutamento.
Warfans
Benvenuti!!!!! Warfans è il forum più completo che riguarda computer e giochi di qualsiasi tipo!!!! ! Che aspettate? Iscrivetevi ed entrerete nella nostra community

1- L'utente continuando la navigazione nel sito dichiara di aver letto attentamente il Regolamento.
2- Tutti i nuovi Utenti sono pregati di presentarsi nella sezione Presentazioni.
3- Lo Staff cerca: Moderatori, Coder, Graphic. Se vi interessa scrivete il Curriculum nella sezione Zona Reclutamento.
Warfans
Vuoi reagire a questo messaggio? Crea un account in pochi click o accedi per continuare.

Warfans

La nuova frontiera dei videogiochi
 
IndiceHomeUltime immaginiRegistratiAccedi
E' obbligatorio presentarsi nella sezione "presentazioni" prima di formulare una richiesta!!!!

 

 Guida creare un tris

Andare in basso 
3 partecipanti
AutoreMessaggio
jan1996

jan1996


Numero di messaggi : 38
Età : 27
Località : Roma

Guida creare un tris Empty
MessaggioTitolo: Guida creare un tris   Guida creare un tris Icon_minitimeDom 20 Giu 2010, 15:19

Materiale:

1 Form
Un Panel di grandezza 302x302

Cancellate tutto poi e scrivete:

Codice:
Public Class Form1
Private statoCaselle(2, 2) As Integer
Private areaCaselle(2, 2) As Rectangle
Private turnoGiocatore1, turnoGiocatore2 As Boolean
Private numeroMosse As Integer = 0


Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
e.Graphics.DrawLine(Pens.Black, 101, 0, 101, 302)
e.Graphics.DrawLine(Pens.Black, 202, 0, 202, 302)
e.Graphics.DrawLine(Pens.Black, 0, 101, 302, 101)
e.Graphics.DrawLine(Pens.Black, 0, 202, 302, 202)
For i As Integer = 0 To statoCaselle.GetLength(0) - 1
For j As Integer = 0 To statoCaselle.GetLength(1) - 1
Select Case (statoCaselle(i, j))
Case 0 : e.Graphics.DrawEllipse(Pens.Black, areaCaselle(i, j).X + 10, areaCaselle(i, j).Y + 10, 80, 80)
Case 1 : e.Graphics.DrawLine(Pens.Black, areaCaselle(i, j).X + 10, areaCaselle(i, j).Y + 10, areaCaselle(i, j).X + 90, areaCaselle(i, j).Y + 90)
e.Graphics.DrawLine(Pens.Black, areaCaselle(i, j).X + 90, areaCaselle(i, j).Y + 10, areaCaselle(i, j).X + 10, areaCaselle(i, j).Y + 90)
End Select
Next
Next
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To statoCaselle.GetLength(0) - 1
For j As Integer = 0 To statoCaselle.GetLength(1) - 1
statoCaselle(i, j) = -1
areaCaselle(i, j) = New Rectangle(i * 101, j * 101, 100, 100)
Next
Next
turnoGiocatore1 = True
turnoGiocatore2 = False
numeroMosse = 0
End Sub

Private Sub Panel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel1.Click

End Sub

Private Sub Panel1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseClick
Dim x, y As Integer
x = -1
y = -1

For i As Integer = 0 To statoCaselle.GetLength(0) - 1
For j As Integer = 0 To statoCaselle.GetLength(1) - 1
If (areaCaselle(i, j).Contains(e.X, e.Y)) Then
x = i
y = j
End If
Next
Next
If (statoCaselle(x, y) = -1) Then
numeroMosse = numeroMosse + 1
statoCaselle(x, y) = Convert.ToInt32(turnoGiocatore1)
turnoGiocatore1 = Not turnoGiocatore1
turnoGiocatore2 = Not turnoGiocatore2
Else
MsgBox("errore, casella occupata")
End If

Dim simbolo As Integer = -1
Panel1.Refresh()
If (finePartita(simbolo)) Then
Dim s As String = ""
If (simbolo = 0) Then
s = "cerchio"
MsgBox("Il vincitore è il giocatore che usa il simbolo : " + s)
ElseIf (simbolo = 1) Then
s = "croce"
MsgBox("Il vincitore è il giocatore che usa il simbolo : " + s)
Else
MsgBox("la partita è finita in parità")
End If

If (MsgBox("Vuoi giocare una nuova partita ? ", MsgBoxStyle.YesNo) = MsgBoxResult.Yes) Then
Me.Form1_Load(Me, New EventArgs())
Panel1.Refresh()
Else
Application.Exit()
End If
End If


End Sub
Private Function finePartita(ByRef simboloVincente As Integer) As Boolean
Dim rigaV As Boolean = True
Dim colonnaV As Boolean = True
Dim fine As Boolean = False
Dim simbolo As Integer = -1
simboloVincente = -1
If (numeroMosse < 9) Then
For i As Integer = 0 To statoCaselle.GetLength(0) - 1
Dim contatore As Integer = 0
simbolo = statoCaselle(i, 0)
For j As Integer = 0 To statoCaselle.GetLength(1) - 1
If (simbolo = statoCaselle(i, j) And Not simbolo = -1) Then
contatore = contatore + 1
End If
Next
If (contatore = 3) Then
fine = True
simboloVincente = simbolo
Continue For
End If

Next
If (Not fine) Then
For i As Integer = 0 To statoCaselle.GetLength(0) - 1
Dim contatore As Integer = 0
simbolo = statoCaselle(0, i)
For j As Integer = 0 To statoCaselle.GetLength(1) - 1
If (simbolo = statoCaselle(j, i) And Not simbolo = -1) Then
contatore = contatore + 1
End If
Next
If (contatore = 3) Then
fine = True
simboloVincente = simbolo
Continue For
End If
Next
End If
If (Not fine) Then
Dim contatore As Integer = 0
simbolo = statoCaselle(0, 0)
For i As Integer = 0 To statoCaselle.GetLength(0) - 1
If (simbolo = statoCaselle(i, i) And Not simbolo = -1) Then
contatore = contatore + 1
End If
If (contatore = 3) Then
fine = True
simboloVincente = simbolo
Continue For
End If
Next
End If
If (Not fine) Then
Dim contatore As Integer = 0
simbolo = statoCaselle(2, 0)
For i As Integer = 0 To statoCaselle.GetLength(0) - 1
If (simbolo = statoCaselle(2 - i, i) And Not simbolo = -1) Then
contatore = contatore + 1
End If
If (contatore = 3) Then
fine = True
simboloVincente = simbolo
Continue For
End If
Next
End If
Else
fine = True
End If

finePartita = fine

End Function
End Class

Risultato:


Guida creare un tris Immaginezm

Fonte:
[Devi essere iscritto e connesso per vedere questo link] (No Spam)
Torna in alto Andare in basso
http://janforum.forumattivo.com/forum
ElMaTaDoR

ElMaTaDoR


Numero di messaggi : 280
Età : 25
Località : Napoli,Portici

Guida creare un tris Empty
MessaggioTitolo: Re: Guida creare un tris   Guida creare un tris Icon_minitimeDom 04 Lug 2010, 15:00

cos'è il form?Non lo mai sentito e mai visto nel mio computer si deve scaricare????????
Torna in alto Andare in basso
Franciccio90

Franciccio90


Numero di messaggi : 31

Guida creare un tris Empty
MessaggioTitolo: Re: Guida creare un tris   Guida creare un tris Icon_minitimeMer 14 Lug 2010, 19:42

O_O... xD e meglio ke prima ke fai un tris studi le basi del visual basic, un form e la semplicissima finestra principale...
Torna in alto Andare in basso
jan1996

jan1996


Numero di messaggi : 38
Età : 27
Località : Roma

Guida creare un tris Empty
MessaggioTitolo: Re: Guida creare un tris   Guida creare un tris Icon_minitimeVen 13 Gen 2012, 18:15

-.-'
Torna in alto Andare in basso
http://janforum.forumattivo.com/forum
jan1996

jan1996


Numero di messaggi : 38
Età : 27
Località : Roma

Guida creare un tris Empty
MessaggioTitolo: Re: Guida creare un tris   Guida creare un tris Icon_minitimeVen 13 Gen 2012, 18:15

grazie
Torna in alto Andare in basso
http://janforum.forumattivo.com/forum
Contenuto sponsorizzato





Guida creare un tris Empty
MessaggioTitolo: Re: Guida creare un tris   Guida creare un tris Icon_minitime

Torna in alto Andare in basso
 
Guida creare un tris
Torna in alto 
Pagina 1 di 1
 Argomenti simili
-
» [Guida]Come creare LockMob VB.Net (Metin2)
» [GUIDA]Creare Server Metin2 (VIDEO) Prt. 1
» [GUIDA]Creare Server Metin2 (VIDEO) Prt. 2
» Guida kome creare hack D3D Warrock
» [GUIDA]come creare un server privato di metin2 dedicato

Permessi in questa sezione del forum:Non puoi rispondere agli argomenti in questo forum.
Warfans :: Programmazione :: Visual basic-
Vai verso: