Verbindung zu einem Multiserver nicht möglich

  • VB.NET

Es gibt 38 Antworten in diesem Thema. Der letzte Beitrag () ist von EiPott.

    Verbindung zu einem Multiserver nicht möglich

    Hi Leute ... ICh habe versucht in mein Spiel einen Chat einzubauen aber das geht i-wie nicht ...
    Also hier is mal der Code :

    VB.NET-Quellcode

    1. Imports System.Net.SocketsImports System.IO
    2. Public Class Form1 Private stream As NetworkStream Private streamw As StreamWriter Private streamr As StreamReader Private client As New TcpClient Private t As New Threading.Thread(AddressOf Listen) Private Delegate Sub DAddItem(ByVal s As String) Private nick As String = "unknown" Dim myx As Integer = -5 Dim myy As Integer = 10
    3. Private Sub AddItem(ByVal s As String) Dim arr = s.Split(",") Dim list = arr.ToList Dim i = ListView1.Items.Add(list.Item(0)) Dim one As String = list.Item(1) Dim two As String = list.Item(2) i.SubItems.Add(one) i.SubItems.Add(two) PictureBox1.Refresh() ListBox1.Items.Add(s) End Sub
    4. Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown 'Hoch If e.KeyCode = Keys.Up Then PictureBox1.Location = New Point(PictureBox1.Location.X + 0, PictureBox1.Location.Y - 2) End If 'Runter If e.KeyCode = Keys.Down Then PictureBox1.Location = New Point(PictureBox1.Location.X + 0, PictureBox1.Location.Y + 2) End If 'Rechts If e.KeyCode = Keys.Right Then PictureBox1.Location = New Point(PictureBox1.Location.X + 2, PictureBox1.Location.Y + 0) End If 'Links If e.KeyCode = Keys.Left Then PictureBox1.Location = New Point(PictureBox1.Location.X - 2, PictureBox1.Location.Y + 0) End If myx = PictureBox1.Location.X myy = PictureBox1.Location.Y streamw.WriteLine(nick & "," & myx & "," & myy) streamw.Flush()
    5. End Sub Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown Try client.Connect("127.0.0.1", 8000) ' hier die ip des servers eintragen. ' da dieser beim testen wohl lokal läuft, hier die loopback-ip 127.0.0.1. If client.Connected Then stream = client.GetStream streamw = New StreamWriter(stream) streamr = New StreamReader(stream)
    6. streamw.WriteLine(nick) ' das ist optional. streamw.Flush()
    7. t.Start() Else MessageBox.Show("Verbindung zum Server nicht möglich!") Application.Exit() End If Catch ex As Exception MessageBox.Show("Verbindung zum Server nicht möglich!") Application.Exit() End Try End Sub
    8. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim posx_rnd As New Random Dim posy_rnd As New Random Dim posx = posx_rnd.Next(15, Me.Width - 15) Dim posy = posy_rnd.Next(15, Me.Height - 15) myx = posx myy = posy nick = InputBox("Gib einen Spielernamen ein!") Me.KeyPreview = True Try client.Connect("127.0.0.1", 8000) If client.Connected Then stream = client.GetStream streamw = New StreamWriter(stream) streamr = New StreamReader(stream)
    9. streamw.WriteLine(nick) streamw.Flush()
    10. t.Start() Else MessageBox.Show("Verbindung zum Server nicht möglich!") Application.Exit() End If Catch ex As Exception MessageBox.Show("Verbindung zum Server nicht möglich!") Application.Exit() End Try End Sub Private Sub Listen() While client.Connected Try Me.Invoke(New DAddItem(AddressOf AddItem), streamr.ReadLine) Catch MessageBox.Show("Verbindung zum Server nicht möglich!") Application.Exit() End Try End While End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click streamw.WriteLine(TextBox1.Text) streamw.Flush() TextBox1.Clear() End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
    11. For Each item As ListViewItem In ListView1.Items Dim rnd1 As New Random Dim rnd2 As New Random Dim rnd3 As New Random
    12. Dim clr1 = rnd1.Next(1, 255) Dim clr2 = rnd2.Next(1, 255) Dim clr3 = rnd2.Next(1, 255)
    13. Dim nm_ As String = item.ToString nm_ = nm_.Replace("ListViewItem: {", "") nm_ = nm_.Replace("}", "") Dim nm As String = nm_
    14. Dim x_ As String = item.SubItems(1).ToString x_ = x_.Replace("ListViewSubItem: {", "") x_ = x_.Replace("}", "") Dim x As Single = x_
    15. Dim y_ As String = item.SubItems(2).ToString y_ = y_.Replace("ListViewSubItem: {", "") y_ = y_.Replace("}", "") Dim y As Single = y_
    16. Next
    17. End Sub
    18. End Class



    Also ich weiß nicht warum das nicht funktioniert ... Da steht immer Verbindung zum Server nicht möglich.
    Dabei hab ich diesen Multiserver laufen ...

    EDIT: ich seh grad das sind nur 22 zeilen ... das war keine absicht sry ... ich hoffe ihr könnt es trotzdem entziffern :D

    Edit by ~blaze~:
    *Thema umbenannt*

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „~blaze~“ ()

    BDG schrieb:

    EDIT: ich seh grad das sind nur 22 zeilen ... das war keine absicht sry ... ich hoffe ihr könnt es trotzdem entziffern


    Warum sollten wir dir helfen wenn wir deinen Code erst noch "entschlüsseln" müssen ?

    Gruß, Trudi ;)
    ja aber das hat das forum gemacht ! Das war ich nciht !
    Also ich versuchs nochmal :

    VB.NET-Quellcode

    1. Imports System.Net.Sockets
    2. Imports System.IO
    3. Public Class Form1
    4. Private stream As NetworkStream
    5. Private streamw As StreamWriter
    6. Private streamr As StreamReader
    7. Private client As New TcpClient
    8. Private t As New Threading.Thread(AddressOf Listen)
    9. Private Delegate Sub DAddItem(ByVal s As String)
    10. Private nick As String = "unknown"
    11. Private Sub AddItem(ByVal s As String)
    12. ListBox1.Items.Add(s)
    13. End Sub
    14. Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
    15. Try
    16. client.Connect("127.0.0.1", 8000) ' hier die ip des servers eintragen.
    17. ' da dieser beim testen wohl lokal läuft, hier die loopback-ip 127.0.0.1.
    18. If client.Connected Then
    19. stream = client.GetStream
    20. streamw = New StreamWriter(stream)
    21. streamr = New StreamReader(stream)
    22. streamw.WriteLine(nick) ' das ist optional.
    23. streamw.Flush()
    24. t.Start()
    25. Else
    26. MessageBox.Show("Verbindung zum Server nicht möglich!")
    27. Application.Exit()
    28. End If
    29. Catch ex As Exception
    30. MessageBox.Show("Verbindung zum Server nicht möglich!")
    31. Application.Exit()
    32. End Try
    33. End Sub
    34. Private Sub Listen()
    35. While client.Connected
    36. Try
    37. Me.Invoke(New DAddItem(AddressOf AddItem), streamr.ReadLine)
    38. Catch
    39. MessageBox.Show("Verbindung zum Server nicht möglich!")
    40. Application.Exit()
    41. End Try
    42. End While
    43. End Sub
    44. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    45. streamw.WriteLine(TextBox1.Text)
    46. streamw.Flush()
    47. TextBox1.Clear()
    48. End Sub
    49. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    50. nick = InputBox("Nickname: ", "Namen festlegen", "unknown")
    51. End Sub
    52. End Class
    Oh sry falscher code ... Ich send gleich mal den richtigen

    VB.NET-Quellcode

    1. Imports System.Net.Sockets
    2. Imports System.IO
    3. Public Class Form1
    4. Private stream As NetworkStream
    5. Private streamw As StreamWriter
    6. Private streamr As StreamReader
    7. Private client As New TcpClient
    8. Private t As New Threading.Thread(AddressOf Listen)
    9. Private Delegate Sub DAddItem(ByVal s As String)
    10. Private nick As String = "unknown"
    11. Private Sub AddItem(ByVal s As String)
    12. ListBox1.Items.Add(s)
    13. End Sub
    14. Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
    15. Try
    16. client.Connect("127.0.0.1", 8000) ' hier die ip des servers eintragen.
    17. ' da dieser beim testen wohl lokal läuft, hier die loopback-ip 127.0.0.1.
    18. If client.Connected Then
    19. stream = client.GetStream
    20. streamw = New StreamWriter(stream)
    21. streamr = New StreamReader(stream)
    22. streamw.WriteLine(nick) ' das ist optional.
    23. streamw.Flush()
    24. t.Start()
    25. Else
    26. MessageBox.Show("Verbindung zum Server nicht möglich!")
    27. Application.Exit()
    28. End If
    29. Catch ex As Exception
    30. MessageBox.Show("Verbindung zum Server nicht möglich!")
    31. Application.Exit()
    32. End Try
    33. End Sub
    34. Private Sub Listen()
    35. While client.Connected
    36. Try
    37. Me.Invoke(New DAddItem(AddressOf AddItem), streamr.ReadLine)
    38. Catch
    39. MessageBox.Show("Verbindung zum Server nicht möglich!")
    40. Application.Exit()
    41. End Try
    42. End While
    43. End Sub
    44. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    45. streamw.WriteLine(TextBox1.Text)
    46. streamw.Flush()
    47. TextBox1.Clear()
    48. End Sub
    49. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    50. nick = InputBox("Nickname: ", "Namen festlegen", "unknown")
    51. End Sub
    52. End Class


    hmm warte ich glaub der is gleich ... also das game hat ja funtkioniert ... nur jetzt wollte ich noch einen chat einbauen und da steht dann immer verbindung zum server nicht möglich ... Also ich hab den Code ausm dem Tutorial genommen und nur das game ein bisschen verändert . Und dann noch versucht den chat einzubauen .. Was ja leider nicht funktionierte
    hi!

    also ich habs jetzt auch nicht ganz verglichen, aber so weit ich das sehe ist es wie bereits gesagt 1:1 der code von Kevin.

    das ist natürlich kein problem, schließlich hat er ihn ja nicht zum anschauen gepostet, aber du hast einfach den ganzen code kopiert.
    ohne eine eigene Idee von deinem "spiel"

    keiner weiß was er machen soll oder was genau dein problem ist. ?( ich glaube nicht das hier jemand lust hat dir ein spiel zu machen(ohne gewähr)

    mfg genesis


    PS:
    ja aber das hat das forum gemacht ! Das war ich nciht !
    Also ich versuchs nochmal :

    nein nicht das forum aber ich weiß wo der fehler sitzt... 50 cm vor dem bildschirm ;)

    und noch ein PS:
    warum hast du hier: Mini multiplayergame bereits den fast identischen thread aufgemacht und verweißt sogar in deiner sig darauf hin?

    nochmaliges mfg Genesis
    So also ich hab jetzt gemerkt das is der falsche code .... Nun zeig ich endlich den richtigen Code:

    VB.NET-Quellcode

    1. Imports System.Net.Sockets
    2. Imports System.IO
    3. Public Class Form1
    4. Private stream As NetworkStream
    5. Private streamw As StreamWriter
    6. Private streamr As StreamReader
    7. Private client As New TcpClient
    8. Private t As New Threading.Thread(AddressOf Listen)
    9. Private Delegate Sub DAddItem(ByVal s As String)
    10. Private nick As String = "unknown"
    11. Dim myx As Integer = -5
    12. Dim myy As Integer = 10
    13. Private Sub AddItem(ByVal s As String)
    14. Dim arr = s.Split(",")
    15. Dim list = arr.ToList
    16. Dim i = ListView1.Items.Add(list.Item(0))
    17. Dim one As String = list.Item(1)
    18. Dim two As String = list.Item(2)
    19. i.SubItems.Add(one)
    20. i.SubItems.Add(two)
    21. PictureBox1.Refresh()
    22. End Sub
    23. Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    24. 'Hoch
    25. If e.KeyCode = Keys.Up Then
    26. PictureBox1.Location = New Point(PictureBox1.Location.X + 0, PictureBox1.Location.Y - 2)
    27. End If
    28. 'Runter
    29. If e.KeyCode = Keys.Down Then
    30. PictureBox1.Location = New Point(PictureBox1.Location.X + 0, PictureBox1.Location.Y + 2)
    31. End If
    32. 'Rechts
    33. If e.KeyCode = Keys.Right Then
    34. PictureBox1.Location = New Point(PictureBox1.Location.X + 2, PictureBox1.Location.Y + 0)
    35. End If
    36. 'Links
    37. If e.KeyCode = Keys.Left Then
    38. PictureBox1.Location = New Point(PictureBox1.Location.X - 2, PictureBox1.Location.Y + 0)
    39. End If
    40. streamw.WriteLine(nick & "," & myx & "," & myy)
    41. streamw.Flush()
    42. End Sub
    43. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    44. Dim posx_rnd As New Random
    45. Dim posy_rnd As New Random
    46. Dim posx = posx_rnd.Next(15, Me.Width - 15)
    47. Dim posy = posy_rnd.Next(15, Me.Height - 15)
    48. myx = posx
    49. myy = posy
    50. nick = InputBox("Gib einen Spielernamen ein!")
    51. Me.KeyPreview = True
    52. Try
    53. client.Connect("127.0.0.1", 8000)
    54. If client.Connected Then
    55. stream = client.GetStream
    56. streamw = New StreamWriter(stream)
    57. streamr = New StreamReader(stream)
    58. streamw.WriteLine(nick)
    59. streamw.Flush()
    60. t.Start()
    61. Else
    62. MessageBox.Show("Verbindung zum Server nicht möglich!")
    63. Application.Exit()
    64. End If
    65. Catch ex As Exception
    66. MessageBox.Show("Verbindung zum Server nicht möglich!")
    67. Application.Exit()
    68. End Try
    69. End Sub
    70. Private Sub Listen()
    71. While client.Connected
    72. Try
    73. Me.Invoke(New DAddItem(AddressOf AddItem), streamr.ReadLine)
    74. Catch
    75. MessageBox.Show("Verbindung zum Server nicht möglich!")
    76. Application.Exit()
    77. End Try
    78. End While
    79. End Sub
    80. Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
    81. For Each item As ListViewItem In ListView1.Items
    82. Dim rnd1 As New Random
    83. Dim rnd2 As New Random
    84. Dim rnd3 As New Random
    85. Dim clr1 = rnd1.Next(1, 255)
    86. Dim clr2 = rnd2.Next(1, 255)
    87. Dim clr3 = rnd2.Next(1, 255)
    88. Dim nm_ As String = item.ToString
    89. nm_ = nm_.Replace("ListViewItem: {", "")
    90. nm_ = nm_.Replace("}", "")
    91. Dim nm As String = nm_
    92. Dim x_ As String = item.SubItems(1).ToString
    93. x_ = x_.Replace("ListViewSubItem: {", "")
    94. x_ = x_.Replace("}", "")
    95. Dim x As Single = x_
    96. Dim y_ As String = item.SubItems(2).ToString
    97. y_ = y_.Replace("ListViewSubItem: {", "")
    98. y_ = y_.Replace("}", "")
    99. Dim y As Single = y_
    100. Dim player As New Rectangle(x, y, 15, 15)
    101. e.Graphics.DrawRectangle(Pens.Transparent, player)
    102. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(clr1, clr2, clr3)), player)
    103. Next
    104. End Sub
    105. End Class


    In diesem Code sieht man die andere Figur nicht . Wenn ich die exe zweimal starte dann sieht man die jeweils andere figur nicht ... woran liegt das ?
    2.3 Was benötigen andere, um das Problem besser nachvollziehen zu können?
    Wenn möglich, gebe ein Szenario mit an, bei dem der Fehler auftritt. Welche Werte haben die Variablen, wo muss man was eingeben oder wohin klicken, damit der Fehler auftritt. Auch Screenshots oder Testdateien können unter umständen hier hilfreich sein, welche hochgeladen und anderen zur Verfügung gestellt werden können.


    3.1 Was, wenn niemand antwortet?
    Warte mindestens 2 Tage ab, nicht jeder User ist so oft online! Ist auch nach 3 Tagen keine Antwort eingegangen, versuche das Problem noch einmal besser oder anders zu formulieren, ein einfacher „Push-Post“ ohne konstruktivem Inhalt wirkt unfreundlich und egoistisch den freiwilligen Helfern gegenüber.
    Nur mal so und ach ja Tritt dass Paint Event denn Mehrmals auf? Wenn nein wie willst du dann immer die neuen Daten übertragen...
    Also ich habe noch nie was mit den Paint Event gemacht aber Ich glaube nicht dass dass mehrmals auftritt..
    hmmm also mit dem Code kenne ich mich nicht so aus denn ich hab das vom tutorial kopiert und dann einfach
    das spiel etwas verändert ... Und jetzt sieht man aber die jeweils anderen nicht :(

    PS: dabei hab ich mir für die überschrift doch soviel mühe gegeben
    Mensch dein Code ist ganz schön unübersichtlich ^^
    Und es sind ein paar fatale Fehler drinne ..

    Erstmal :

    VB.NET-Quellcode

    1. Dim nm_ As String = item.ToString
    2. nm_ = nm_.Replace("ListViewItem: {", "")
    3. nm_ = nm_.Replace("}", "")
    4. Dim nm As String = nm_
    5. Dim x_ As String = item.SubItems(1).ToString
    6. x_ = x_.Replace("ListViewSubItem: {", "")
    7. x_ = x_.Replace("}", "")
    8. Dim x As Single = x_
    9. Dim y_ As String = item.SubItems(2).ToString
    10. y_ = y_.Replace("ListViewSubItem: {", "")
    11. y_ = y_.Replace("}", "")
    12. Dim y As Single = y_


    Um an den Text von den ListViewItems zu kommen gibt es folgende Eigenschaft : (wie bei TextBox, ComboBox, Label)

    VB.NET-Quellcode

    1. item.SubItems(1)[b].Text
    2. [/b]


    So musst du nicht den Umweg über .Replace und so machen ;)


    VB.NET-Quellcode

    1. Dim player As New Rectangle(x, y, 15, 15)
    2. e.Graphics.DrawRectangle(Pens.Transparent, player)
    3. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(clr1, clr2, clr3)), player)


    Es muss ja eigentlich an dem Stück Code hängen..
    Hast du schonmal versucht anstatt Pens.Transparent Pens.Black oder so zu schreiben ?

    Hmmm.. ;)

    VB.NET-Quellcode

    1. Imports System.Net.Sockets
    2. Imports System.IO
    3. Public Class Form1
    4. Private stream As NetworkStream
    5. Private streamw As StreamWriter
    6. Private streamr As StreamReader
    7. Private client As New TcpClient
    8. Private t As New Threading.Thread(AddressOf Listen)
    9. Private Delegate Sub DAddItem(ByVal s As String)
    10. Private nick As String = "unknown"
    11. Dim myx As Integer = -5
    12. Dim myy As Integer = 10
    13. Private Sub AddItem(ByVal s As String)
    14. Dim arr = s.Split(",")
    15. Dim list = arr.ToList
    16. Dim i = ListView1.Items.Add(list.Item(0))
    17. Dim one As String = list.Item(1)
    18. Dim two As String = list.Item(2)
    19. item.SubItems(1)[b].Text
    20. [/b]
    21. PictureBox1.Refresh()
    22. End Sub
    23. Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    24. 'Hoch
    25. If e.KeyCode = Keys.Up Then
    26. PictureBox1.Location = New Point(PictureBox1.Location.X + 0, PictureBox1.Location.Y - 2)
    27. End If
    28. 'Runter
    29. If e.KeyCode = Keys.Down Then
    30. PictureBox1.Location = New Point(PictureBox1.Location.X + 0, PictureBox1.Location.Y + 2)
    31. End If
    32. 'Rechts
    33. If e.KeyCode = Keys.Right Then
    34. PictureBox1.Location = New Point(PictureBox1.Location.X + 2, PictureBox1.Location.Y + 0)
    35. End If
    36. 'Links
    37. If e.KeyCode = Keys.Left Then
    38. PictureBox1.Location = New Point(PictureBox1.Location.X - 2, PictureBox1.Location.Y + 0)
    39. End If
    40. streamw.WriteLine(nick & "," & myx & "," & myy)
    41. streamw.Flush()
    42. End Sub
    43. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    44. Dim posx_rnd As New Random
    45. Dim posy_rnd As New Random
    46. Dim posx = posx_rnd.Next(15, Me.Width - 15)
    47. Dim posy = posy_rnd.Next(15, Me.Height - 15)
    48. myx = posx
    49. myy = posy
    50. nick = InputBox("Gib einen Spielernamen ein!")
    51. Me.KeyPreview = True
    52. Try
    53. client.Connect("127.0.0.1", 8000)
    54. If client.Connected Then
    55. stream = client.GetStream
    56. streamw = New StreamWriter(stream)
    57. streamr = New StreamReader(stream)
    58. streamw.WriteLine(nick)
    59. streamw.Flush()
    60. t.Start()
    61. Else
    62. MessageBox.Show("Verbindung zum Server nicht möglich!")
    63. Application.Exit()
    64. End If
    65. Catch ex As Exception
    66. MessageBox.Show("Verbindung zum Server nicht möglich!")
    67. Application.Exit()
    68. End Try
    69. End Sub
    70. Private Sub Listen()
    71. While client.Connected
    72. Try
    73. Me.Invoke(New DAddItem(AddressOf AddItem), streamr.ReadLine)
    74. Catch
    75. MessageBox.Show("Verbindung zum Server nicht möglich!")
    76. Application.Exit()
    77. End Try
    78. End While
    79. End Sub
    80. Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
    81. For Each item As ListViewItem In ListView1.Items
    82. Dim rnd1 As New Random
    83. Dim rnd2 As New Random
    84. Dim rnd3 As New Random
    85. Dim clr1 = rnd1.Next(1, 255)
    86. Dim clr2 = rnd2.Next(1, 255)
    87. Dim clr3 = rnd2.Next(1, 255)
    88. Dim nm_ As String = item.ToString
    89. nm_ = nm_.Replace("ListViewItem: {", "")
    90. nm_ = nm_.Replace("}", "")
    91. Dim nm As String = nm_
    92. Dim x_ As String = item.SubItems(1).ToString
    93. x_ = x_.Replace("ListViewSubItem: {", "")
    94. x_ = x_.Replace("}", "")
    95. Dim x As Single = x_
    96. Dim y_ As String = item.SubItems(2).ToString
    97. y_ = y_.Replace("ListViewSubItem: {", "")
    98. y_ = y_.Replace("}", "")
    99. Dim y As Single = y_
    100. Dim player As New Rectangle(x, y, 15, 15)
    101. e.Graphics.DrawRectangle(Pens.Transparent, player)
    102. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(clr1, clr2, clr3)), player)
    103. Next
    104. End Sub
    105. End Class

    so ist es nun ...
    Nur wozu braucht man dieses


    Dim player As New Rectangle(x, y, 15, 15)
    e.Graphics.DrawRectangle(Pens.Transparent, player)
    e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(clr1, clr2, clr3)), player)

    also eigntlich sollte das Spiel ja mit pictureboxen laufen ... deswegen is ja auch dashier :

    VB.NET-Quellcode

    1. If e.KeyCode = Keys.Up Then
    2. PictureBox1.Location = New Point(PictureBox1.Location.X + 0, PictureBox1.Location.Y - 2)
    3. End If
    4. 'Runter
    5. If e.KeyCode = Keys.Down Then
    6. PictureBox1.Location = New Point(PictureBox1.Location.X + 0, PictureBox1.Location.Y + 2)
    7. End If
    8. 'Rechts
    9. If e.KeyCode = Keys.Right Then
    10. PictureBox1.Location = New Point(PictureBox1.Location.X + 2, PictureBox1.Location.Y + 0)
    11. End If
    12. 'Links
    13. If e.KeyCode = Keys.Left Then
    14. PictureBox1.Location = New Point(PictureBox1.Location.X - 2, PictureBox1.Location.Y + 0)
    15. End If
    16. streamw.WriteLine(nick & "," & myx & "," & myy)
    17. streamw.Flush()
    das da ist für das bewegen deines eigenen spielers :rolleyes:

    und wo bewegst du/ hast du deinen gegner ?

    Warum machst du es dir hier so umständlich über Replace :

    VB.NET-Quellcode

    1. Dim nm_ As String = item.ToString
    2. nm_ = nm_.Replace("ListViewItem: {", "")
    3. nm_ = nm_.Replace("}", "")
    4. Dim nm As String = nm_
    5. Dim x_ As String = item.SubItems(1).ToString
    6. x_ = x_.Replace("ListViewSubItem: {", "")
    7. x_ = x_.Replace("}", "")
    8. Dim x As Single = x_
    9. Dim y_ As String = item.SubItems(2).ToString
    10. y_ = y_.Replace("ListViewSubItem: {", "")
    11. y_ = y_.Replace("}", "")
    12. Dim y As Single = y_


    den text von einem subitem liest man über subitem.text aus..

    Gruß, Trudi
    hmm ja sry ich bin noch sehr anfänger und den code hab ich aus einem tutorial ... und jetzt hab ich den etwas umgebaut ... aber ich kenn mich damit nicht so Gut aus ...
    kannst du mir vielleicht den ganzen code geben ? währe wirklich nett ... denn ich versuch das jetzt schon 2 wochen
    und hab auch in anderen foren gefragt aber ich krig das nicht hin sry.
    aha ich verstehe

    EDIT: hmm hab den Code jetzt bearbeitet aber man sieht den anderen immer noch nicht :( hier mal ein bild :

    wie mach ich das das beide sich gegenseitig sehen ? und welchen zweck hat die listview könnte man die nicht auch weglassen ? die stört mich irgendwie ...

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „BDG“ ()