Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Multiplayer PONG EXE not working on friend's PC.

Author
Message
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 24th Sep 2011 19:23
Hi guys!

I spent the good half of last night wallowing through the commands and multiplayer secrets tutorial to try and come up with a multiplayer pong game.

Well, it's all pretty much futile.

When my buddy tries to run the test EXE, he gets:

And a incorrect parameter error also.

Here's the code:



Any help would be greatly appreciated! After this is fixed, I'll either put this in the 20 line challenge or code snippets.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 24th Sep 2011 19:43 Edited at: 24th Sep 2011 19:52
If anyone can successfully run this, would you be willing to test it out with me? The current time here is 12:42 UTC-5.

EDIT: I'm trying it with "localhost" and it's freezing up for the host/not drawing the sprites for the client.

If anyone can help, it would be appreciated.

Thanks.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Sep 2011 19:56 Edited at: 24th Sep 2011 19:58
It compiled and ran fine on win7 32-bit. UC7_& RC7

I am having an issue launching the app twice under different names, and finding the network game... but I may be doing something wrong, + a combination of running ZoneAlarm. Sometimes I am able to do this with network games. I haven't tried launching the app separeately on different computers on my network. But I guess the real issue is if it would launch.

Still no problem with compiling and running the .exe

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 24th Sep 2011 20:07
Thanks zenassem. Would you mind to try running it on two separate PCs on your network and see if it works?

I'm using Win8 32-bit. My friend was using Win7 64-bit.

I tried running two copies on my machine and it pulled it up, but it didn't display any of the sprites on the client side, and the host side didn't accept any input. Also the ball didn't move like it should have.

It's really confusing why it's doing that.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Sep 2011 20:16
Ill try it in a few. I just looked through your code. It would have been helpful if you would have stated that it doesn't detect the nat'd internal local IP automatically to play within a local network. You have a harcoded IP address that needs to be changed in the code before compile.

Your signature has been erased by a mod please reduce it to 600 x 120.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Sep 2011 20:26 Edited at: 24th Sep 2011 20:27
Im getting the same results you are. Graphics for bats and ball displayed on host before player 2 joins. Player 2 joins the game and I get scores for player1 and player 2 but no other graphics. the host game shows the graphics but just sits there and doesn't accept input. Will have to look over the code to see what is going wrong... but I don't have time right away. I'll post back a bit later if someone else doesn't get to it before me.

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 24th Sep 2011 20:45
Thanks man... at least I know now I'm not alone with it behaving like that.
One thing I just realized on the client side when I copied over the host loop and reworked it for the client, it accidentally deleted the "SYNC" command at the end of the loop. That'll do it for the sprites not showing up in that.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Sep 2011 22:00 Edited at: 24th Sep 2011 22:17
Nevermind, i thought I saw a problem with the goto line. But that in itself is not the problem when hitting the return in label _ste. What I do need to figure out, is tracing the program more. It seems that the call to star_main_host is coming from setting up the net connections, so when the host sets up and is waiting for the player, it will hit that goto line and then return from the last gosub call. I'm having an issue of where it returns to. Maybe it's not a problem at all. I just have too look over the code more to understand all of its flow. Confusing for the person who didnt code it

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 24th Sep 2011 22:10
Well, that RETURN is actually for GOSUB _main_loop_host that's there earlier.

It seems like the problem is in the HOST since it just hangs after it's set up... Almost like it never gets the message "Player2 Joined The Game".

Is it possible for packets to be missed by the receiving party?
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Sep 2011 22:17 Edited at: 24th Sep 2011 22:18
Yeah i just changed my post as you were posting

I need to add some debugging codes into the program to see what is going on.

Your signature has been erased by a mod please reduce it to 600 x 120.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Sep 2011 22:23 Edited at: 24th Sep 2011 22:28
Quote: "Well, that RETURN is actually for GOSUB _main_loop_host that's there earlier."


I am confused though. what exaclty is suppose to happen that label is called from the "gosub" and hits that return line ?

That question I actually think i get... but it sets up this question

what happens when that label is called from the "goto" and hits that return line?

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 24th Sep 2011 22:40
It doesn't because it goes back to the beginning of the loop if that makes sense. I'm thinking that somehow the packet is being missed.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Sep 2011 22:52
gotcha!!! wasn't really thinking I guess. Strange way to write code. I take it, if I am now thinking straight the gousb call to it never hits that reutrn either. anyways, it's not the problem so... will continue looking. I'll admit I have never used the multiplayer commands, so it's a bit of a learning experience for me.

Your signature has been erased by a mod please reduce it to 600 x 120.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Sep 2011 23:19
Yeah the packet is being missed, and the hosts loop is getting locked up somewhere, trying to find it. Not sure if it is getting hung up checking msgs. I had put test stubs in the host players loop, and even forced wait_for_player = 0 (not relying on send message) to see if I could get the hosts loop to continue, but nothing. I can move the paddle up and down on player 2 (the client). so something is happening in not getting messages, and the fact that I can't yet track where the hosts loop is getting stuck.

Your signature has been erased by a mod please reduce it to 600 x 120.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Sep 2011 01:37 Edited at: 25th Sep 2011 01:40
This is the correct way to write that Goto loop code...


// Get Packets First
repeat
GOSUB _host_send_recv_packets
CLS
Sync
until wait_for_player = 0

Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 04:05 Edited at: 25th Sep 2011 04:40
Quote: "Yeah the packet is being missed, and the hosts loop is getting locked up somewhere, trying to find it. Not sure if it is getting hung up checking msgs. I had put test stubs in the host players loop, and even forced wait_for_player = 0 (not relying on send message) to see if I could get the hosts loop to continue, but nothing. I can move the paddle up and down on player 2 (the client). so something is happening in not getting messages, and the fact that I can't yet track where the hosts loop is getting stuck."


Odd... Same scenario here. I'm going to put a print statement in the loop to see if the packet gets received or if it freezes at that point, and then have the client repeat the packet to the host until the host sends a message of return back for it and see if that fixes things.

EDIT: I tried both, the print statement didn't show anything, and the second method was odd... This time the client just showed the ball at the top lefthand side of the window, and no paddles. The host still did the same thing.

Quote: "This is the correct way to write that Goto loop code...


// Get Packets First
repeat
GOSUB _host_send_recv_packets
CLS
Sync
until wait_for_player = 0
"


Do you think this is where the hangup is in the host program?
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 04:59
Here's the current code...

zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 05:08
I'm not sure where it is yet. I had to get some things done beofore I could really sit down, and modify the code to give it the proper look. I will try to do that now. My guess,,was either hanging up there (though I did get to modify the wait_for_player to automatically go to 0 once the client connected) or the only other place I could see was it getting hung up in getting messages,, as if there's always a message in the buffer, never allowing the host to get out of that loop. Ill try some things out in a bit with the current code you have.

I'm pretty sure it's a simple error somewhere, and with a proper mindset I can track it down. I just have to adjust to your code style as well.

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 05:29 Edited at: 25th Sep 2011 06:41
Okay man, thanks. Though just as a bit of forewarning, all the current code changed was that the host polls to check for the first message "Player2 Joined The Game" from player 2, then sends a message back saying request accepted. However, I think I explained it in the previous post what happened with that, so that may have broke the code even further.

EDIT: I tried doing what you said earlier, which was instead of checking for a initiating packet, checking for new connections...

It's weird... it joins, but then both players act like clients and each is controlling paddle 2, with no interaction between each other.

Here's the code if you want it:



I just thought it was kind of peculiar.

In short, I got rid of the variable checking to see if it was waiting for a player, and put in another subroutine in front of the drawing routine and main loop. This subroutine loops, waiting to see if the amount of players is > 1, and if it is, continues on with the game. But as I said, then it hands everything over to (what appears to be) the client loop, even for the host side.


EDIT: I found out why the host acted like a client... I forgot to put in a "RETURN" at the end of _increase_ball_position. Also I left an unnecessary variable in from before. I'm going to retest it now. I retested it, and the good news is the host does what it's supposed to do, except it's not exchanging packets with the client. Neither one is updating the state for the other, which means the packets aren't going through correctly. I need to look at my packet routines in more depth it seems.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 06:44 Edited at: 25th Sep 2011 06:46
I tried just getting the host working. So I eliminated dependencies on the client, and set waiting for player to 0. I also got rid of the returns at the end of the main_loop_host and used a goto for the call to it. There is never a need to return from that gosub anyway.

The funny thing was... I was able to move the paddle with the up and down keys for the host. BUT... it was moving the paddle on the right which should be associated with the client. Kind of odd. Can't figure out why. I may need to put in some breaks, with output to the debugger as I don't think any of the messages are getting through.

***just read your post in full, and I see that you too are getting the issue where the host code acts like it's the client.

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 06:52
Yeah... Put a "RETURN" at the end of that _increase_ball_position function and that should fix it.

I'm playing around with the packet routines, it could be that it's checking for messages that aren't there because I haven't put them in the message queue yet.

What I mean is



might not have any messages in queue yet, the reason I think that is if you look at the command help for "GET NET MESSAGE", it has the following code example where it calls "GET NET MESSAGE" before it even checks the queue:

zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 07:04
Yeah, we got to the same point around the same time. I put the return in, and both my host and client are responding. It's just a matter of having them communicate their positions, and getting the ball positon to the client. I think you're on the right track with the messages.

Your signature has been erased by a mod please reduce it to 600 x 120.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 07:10
i don't think this is setup right


You keep looping through this on the host. resetting the values each time and, later only send the message from the host if Timer()-my_time is greater than or equal to ping_rate. Well what if it's not greater? The next time through the loop it has no chance of being greater.

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 07:11 Edited at: 25th Sep 2011 07:12
I FIXED IT!!!!

Here's the working code:



Yeah... I was dead on with the messages. It needed the GET NET MESSAGE to process the queue first before it checked if there were any messages in the queue.

Also it didn't like the ping check for some reason (probably too slow). EDIT: Your previous post explained that... I have to rewrite that bit.

Wanna test this online? I think you and I are in the same time zone since I'm in Maryland so we can set a time and who will do what. (I supposed I could be host since that's my IP in the comments and I have the ports unblocked.)
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 07:22 Edited at: 25th Sep 2011 07:25
I thought I found an error with an "*" missing in your hosts send message????



shouldn't that be


***edit
Glad you got it working!!!! Can't wait to try it. This forced me to begin looking at the built-in multiplayer commands. So it was a good experience. Congrats

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 07:26 Edited at: 25th Sep 2011 07:30
You're right, there is an error there. There should be an asterisk separating the last two packet elements. Anyhoo, wanna give this a shot at 12:30?

Here's the updated code (hasn't changed much except for the asterisk being added to the packet):



I'll be the host and I'm waiting. Thanks for the assistance man! You helped point me in the right direction with the messages.

EDIT: You'll have to set the IP to join to the HOST one (which I forgot to do originally... sorry, the code's fixed up here now).
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 07:32
Yeah, it affected the score of the second player.

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 07:34
Hmmm... Do you have an AIM account or something, that way we can correspond a bit more in real time? I don't know if you tried to join the game but it's still waiting.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 07:48
That was a fun test game. Everything is working well. great job!!!

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 07:52
Well my friend, that was a great match of pong! Thanks again for all the help, and if you have any ideas to plus it, feel free to add to it. I might throw in a chat system in the near future here utilizing the end of those packets. But as for now, I'm going to comment in the code a bit more, and then put it on the Code Snippets forum since I'm sure there will be others who may want to stray into multiplayer gaming and want to use these commands.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 07:59
I was going to cheat and change my paddles update speed. lol

Yeah, the things I would add is:
- speeding up the balll
- adding the ability for players to add english ball
- changing the angle of reflection depending on the part of the bat it hits
- if hitting a sweet-spot in the center increase the speed + more english until other player hits
- spawn ball based on timer if no one is scoring, keep doing this until someone misses

*- chat feature would be nice

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 08:21 Edited at: 25th Sep 2011 08:24
"OH MY GOT YOU CHEATER! I KNOW YOU HACK!"

Cool ideas, though what exactly is "English Ball"? I've never heard that term before.

BTW the tutorial's been posted, so feel free to check it out if you want.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 08:38 Edited at: 25th Sep 2011 08:44
English on a ball, is like a curveball... with the abilitiy to control the severity. Think of billiards,, english on the ball allows you to put severe spin on the ball so it can curve around another ball.

More closely related to pong is the game of handball. When a player slices the ball across his hand, the result is an arc trajectory rather than a straight-back shot. the more slice the crazier the arc. And when a ball with that spin hits the wall, it's not easy to predict the way it will reflect off of it. The same could be said of tennis, except for the "wall" substitue "playing surface".

Your signature has been erased by a mod please reduce it to 600 x 120.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 08:54
Ohhhh okay. I'd actually have to look into that a bit more for me to implement it, mainly on the math side. If you could actually come up with some sort of example in code of the math behind the relationship between the sliding of the bat and the arcing of the ball, I would gladly implement it into the current code.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Sep 2011 08:57
Will do. I'm not sure how others would do it. And I wouldn't make it a physics project or anything. I am thinking of using bezier curve type function would suffice in a 2d world.

Your signature has been erased by a mod please reduce it to 600 x 120.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 25th Sep 2011 16:54
@Da_Rhyno - Well done on completing this. I've been watching this over the last few days and you've been very persistent and determined. Big thumbs up!

Warning! May contain Nuts!
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 25th Sep 2011 19:36
Quote: "@Da_Rhyno - Well done on completing this. I've been watching this over the last few days and you've been very persistent and determined. Big thumbs up! "


Thanks man! It was well worth the effort, as it helped me garner more of an understanding of multiplayer code in DBP, which I'll be using for my commercial game project (which I'm revamping the code once again to make it a bit more easily extendable, but it should have a demo out soon).


But yeah, if you feel so inclined (and haven't already), feel free to check out a more documented example in the code snippets section.
Gamer Making
19
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 26th Sep 2011 05:40 Edited at: 26th Sep 2011 05:42
For these games, is port forwarding required or is it automatically communicable between two different networks? Been spending my time making servers for various games so I got confused on a lot of things doing with networks and whatnot.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 26th Sep 2011 05:43
Well, it really depends. Generally if you are behind a router or firewall, those ports will automatically be blocked so port forwarding will be required then. If you look at the code snippets post I made with this code, it explains the necessary ports needed to be unblocked in that case.

Login to post a reply

Server time is: 2026-07-11 11:25:59
Your offset time is: 2026-07-11 11:25:59