Problème jeux pong en multijoueur avec winsock [Fermé]

Signaler
Messages postés
9
Date d'inscription
mercredi 25 novembre 2009
Statut
Membre
Dernière intervention
30 juillet 2016
-
 Utilisateur anonyme -
Salut,
je ne sais pas du tous comment faire pour mon jeu pong car je voudrai jouer en multijoueur avec un pote mais je suis pas assez calé. J'ai créer le serveur et le client donc ont peut chatter.

Code serveur:

Public Class Form1
Dim MoveUp As Boolean
Dim MoveLeft As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If MoveLeft = True Then
ball.Left += 7
End If
If MoveLeft = False Then
ball.Left -= 7
End If
If MoveUp = True Then
ball.Top += 7
End If
If MoveUp = False Then
ball.Top -= 7
End If
If ball.Left <= ClientRectangle.Left Then
MoveLeft = True
ComWin.Text += 1
End If
If ball.Right >= ClientRectangle.Right Then
MoveLeft = False
MeWin.Text += 1
End If
If ball.Top <= ClientRectangle.Top Then
MoveUp = True
End If
If ball.Bottom >= ClientRectangle.Bottom Then
MoveUp = False
End If

If ball.Bottom > pin1.Top Then
If ball.Top < pin1.Bottom Then
If ball.Left < pin1.Right Then
MoveLeft = True
If Timer1.Interval = 1 Then
Else
Timer1.Interval -= 1
End If
End If
End If
End If
If ball.Bottom > pin2.Top Then
If ball.Top < pin2.Bottom Then
If ball.Right > pin2.Left Then
MoveLeft = False
If Timer1.Interval = 1 Then
Exit Sub
Else
Timer1.Interval -= 1

End If
End If
End If
End If

End Sub

Private Sub pin1timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles pin1timer.Tick
pin1.Top = MousePosition.Y - 200
End Sub

Private Sub pin3timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles pin3timer.Tick
If ball.Top > pin2.Top Then
pin2.Top += 30
End If
If ball.Bottom < pin2.Bottom Then
pin2.Top -= 30
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Winsock.LocalPort = 12666
Winsock.Listen()
End Sub

Private Sub Winsock_ConnectionRequest(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_ConnectionRequestEvent) Handles Winsock.ConnectionRequest
Winsock.Close()
Winsock.Accept(e.requestID)
End Sub
Private Sub Winsock_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles Winsock.DataArrival
Dim data As String = ""
Winsock.GetData(data)
MsgBox(data)
End Sub
Private Sub BouttonEnvoie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BouttonEnvoie.Click
Winsock.SendData(TextBox1.Text)
End Sub
End Class

Code client:

Public Class Form1

Private Sub BouttonConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BouttonConnect.Click
Winsock.Connect(TextBox2.Text, 12666)
End Sub

Private Sub Winsock_ConnectEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles Winsock.ConnectEvent
MsgBox("Trouvé")
End Sub

Private Sub BouttonEnvoie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BouttonEnvoie.Click
Winsock.SendData(TextBox1.Text)
End Sub

Private Sub Winsock_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles Winsock.DataArrival
Dim data As String = ""
Winsock.GetData(data)
MsgBox(data)
End Sub

Merci d'avance.

1 réponse


Salut,

As-tu pensé à faire une recherche sur ce site?
Moi j'en ai trouvé quelques dizaines d'exemples de ce jeu...

DANS CE LIEN


Cordialement


CF2i - Guadeloupe
Ingénierie Informatique