|
-
Feb 8th, 2007, 05:28 PM
#1
Thread Starter
Lively Member
Help. Trying To Make Game
Hello I Need A Bit Help Please.
Tryed To Code This For 1 Week Still Doesnt Work.
I Almost Done It. this Is My Code
Hoster:
Code:
Privat Sub Form_Load()
Sock.LocalPort = "3000"
Sock.Listen
End Sub
Privat Sub Form_KeyPress(KeyAscii As Integer)
Dim CarPos1 As String
CarPos1 = Car1.Top
If KeyAscii = 119 Then
Car1.Top = Car1.Top - 10
Sock.SendData CarPos1
End If
End Sub
Private Sub Sock_ConnectionRequest(ByVal requestID As Long)
Sock.Accept requestID
End Sub
Private Sub Sock_DataArrival(ByVal bytesTotal As Long)
Dim CarPos2 As String
Sock.GetData CarPos2
Car2.Top = CarPos2
End Sub
Client:
Code:
Privat Sub Form_Load()
Sock.RemoteHost = "83.84.250.99" ' My IP Address
Sock.RemotePort = "3000"
Sock.Connect
End Sub
Privat Sub Form_KeyPress(KeyAscii As Integer)
Dim CarPos2 As String
CarPos2 = Car2.Top
If KeyAscii = 119 Then
Car2.Top = Car2.Top - 10
Sock.SendData CarPos2
End If
End Sub
Private Sub Sock_DataArrival(ByVal bytesTotal As Long)
Dim CarPos2 As String
Sock.GetData CarPos2
Car2.Top = CarPos2
End Sub
Private Sub Sock_Connect()
MsgBox("Connected")
End Sub
Theres An Error On It. But I Dont Know What It Is
Could Someone Please Help Me Thnx
-
Feb 9th, 2007, 03:50 AM
#2
Frenzied Member
Re: Help. Trying To Make Game
What is it supposed to do?
What is it not doing?
If there is an error, what does it say?
Have you used the debugger on the client and the server to see what is going on?
Why do you first put car2.top in carpos2, then change car2.top and then send carpos2 on the client?
Why do you first put car1.top in carpos1, then change car1.top and then send carpos1 on the server?
-
Feb 9th, 2007, 07:03 AM
#3
Thread Starter
Lively Member
Re: Help. Trying To Make Game
I'm Trying To Make A Kind Of Drag Racing Game.
When I Press The W Button It Goes Forward
Then It Sends The Position Of The Hoster
and On The client It Send The Psition Of the Client
So Like An Online Drag Racing Game
Car1 Is An Picture
Car2 Is An Picture
When I Connect With The Client To Hoster It Says
Run-Time error '40020' Or Something
-
Feb 9th, 2007, 08:49 AM
#4
Addicted Member
Re: Help. Trying To Make Game
in the host use this in the ConnectionRequest
VB Code:
If Sock.State <> sckClosed Then Sock.Close
Sock.Accept requestID
and in the client, the wrong car will move
-
Feb 9th, 2007, 09:14 AM
#5
Thread Starter
Lively Member
Re: Help. Trying To Make Game
Haha Thnx Man, If You Need Help I'll Help You.
Even If i'm Not Good Programmer
Last edited by XCustoms; Feb 9th, 2007 at 09:25 AM.
-
Feb 9th, 2007, 10:02 AM
#6
Addicted Member
Re: Help. Trying To Make Game
you'll need to check the Sock.State before sending anything.
when exiting, each player window should send some sort of *closing* message to the other player window and catch it in the Sock_DataArrival sub, so the other Player socket control will know about the close.(the first player to exit should do this, it would be pointless for the second to do it)
-
Feb 9th, 2007, 10:11 AM
#7
Thread Starter
Lively Member
Re: Help. Trying To Make Game
Thnx 
It says OverFlow I Did Something Wrong Lol.
I Know How To Fix 
Thnx
-
Feb 9th, 2007, 11:51 AM
#8
Addicted Member
Re: Help. Trying To Make Game
what says overflow, what line is highlighted in VB?
-
Feb 10th, 2007, 01:17 PM
#9
Thread Starter
Lively Member
Re: Help. Trying To Make Game
Hello, The Game Works Perfect
Realy Funny, I Added Speed Meter On It
But The Only Problem Is It Says Overflow
It Says Overflow When I Hold The "W" Button
Is It Fixable ?
When I Tick The "W" Button Slowly Then It Works
But Then The Game Is Not Cool.
Maybe Its That It Sends the Pssition Of The Car Too Fast
But Is It Fixable ?
Thnx
-
Feb 10th, 2007, 09:23 PM
#10
Addicted Member
Re: Help. Trying To Make Game
what line is highlighted in VB?
[EDIT] I do not know what changes you have made.
Do not use if shrinkwrap is broken or missing!
I'm learning how to fish, too!
-
Feb 11th, 2007, 06:56 AM
#11
Thread Starter
Lively Member
Re: Help. Trying To Make Game
Wel I Cant See What It HighLighet
When I Play Multiplayer On 1 PC Then It Works Perfect.
When I Play With Someone Else Then It Says OverFlow
(OverFlow When I Hold W Button)
If I Tap W Button It Works Perfect. But Its Not Cool Then
-
Feb 11th, 2007, 06:58 AM
#12
Thread Starter
Lively Member
Re: Help. Trying To Make Game
This Is The Code:
VB Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim CarPos1 As String
CarPos1 = Car1.Left
If Car1.Left >= "6480" Then
SPBar.Width = "15"
Mph.Caption = "0"
YW.Visible = True
ElseIf Car1.Left >= "6480" Then
SPBar.Width = "15"
Mph.Caption = "0"
YL.Visible = True
ElseIf Mph.Caption = "50" Then
Mph.Caption = "50"
Car1.Left = Car1.Left + Mph.Caption
Sock.SendData CarPos1
ElseIf KeyAscii = 119 Then
Car1.Left = Car1.Left + Mph.Caption
SPBar.Width = SPBar.Width + Mph.Caption
Mph.Caption = Mph.Caption + 1
Sock.SendData CarPos1
End If
End Sub
Private Sub Form_Load()
Sock.LocalPort = "3000"
Sock.Listen
YL.Visible = False
YW.Visible = False
End Sub
Private Sub Sock_ConnectionRequest(ByVal RequestID As Long)
If Sock.State <> sckClosed Then Sock.Close
Sock.Accept RequestID
End Sub
Private Sub Sock_DataArrival(ByVal bytesTotal As Long)
Dim CarPos2 As String
Sock.GetData CarPos2
Car2.Left = CarPos2
End Sub
-
Feb 11th, 2007, 11:11 AM
#13
Addicted Member
Re: Help. Trying To Make Game
can't reproduce error.
which line errors?
--also
why check for Car1.Left >= "6480" twice - maybe the second one should be Car2.
what do you mean by...?
VB Code:
ElseIf Mph.Caption = "50" Then
Mph.Caption = "50"
is this to limit top speed to 50, then
VB Code:
ElseIf Mph.Caption > "50" Then
Mph.Caption = "50"
Note: Mph.Caption is a STRING and in the line 'Car1.Left = Car1.Left + Mph.Caption'
you are ADDING the STRING to a SINGLE. VB will coerce the datatypes to work, but this could develop into a habit that can introduce errors, especially whan you add a string that doesn't have a numeric value.
Last edited by kewakl; Feb 12th, 2007 at 05:55 AM.
Reason: fix closing vbcode tags
Do not use if shrinkwrap is broken or missing!
I'm learning how to fish, too!
-
Feb 11th, 2007, 07:32 PM
#14
Thread Starter
Lively Member
Re: Help. Trying To Make Game
Oooooo Yeh Thats Why I Never Lose Lol.
Yeh Its Hard With Programming Lol.
I Think I Try To Make It With C++ (Hopes I Can Do It)
I Know 0.5% About C++ Lol.
Gonna Start To Learn.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|