It's very good article. But, i'm creating a "football" game 1 on 1, and i want add to this a ball, with standard "bouncing ball" movement and i want make:
Every time you send co-ordinates to the other player, send the following information regarding the ball object:
it's position (x and y)
it's direction
it's speed
Then when the player receives, update the ball object with the new co-ordinates, new direction and speed.
The way I do this is the host sends the new direction of the ball, whenever the direction of the ball changes on their screen and the position at which it changes direction. First you need to identify whether the client is the host, or whether it is the player connected to the host (I usually use a counter to do this - if they are the host, set the counter to 1. If not, set the counter to 0).
+ Counter is equal to 1
+ Ball collides with edge of screen
- Send text Dir( "Ball" ) on subchannel 1
+ Counter is equal to 0
+ Message received
+ Subchannel equal to 1
- Set direction of ball to text received
Then do the same for the position of the ball - which just makes sure there are no issues with lag. That should work, I think.. I've typed this out pretty quickly
Hm, i have stop at this moment:
(That is, what i do: )
+ Counter = 1
+ (Where is this option ?, sorry but i don't know, english that much to find it ;( )
- Channel: Str$(Dir( "Active 2" )) [Active 2 = ball, only Dir("Active 2"), not work.]
+ Counter = 0
+ This is : Playern Message, or Player: On Server Message, or Server -> Connection -> On Client Message, which one that is?
+ I don't know, how do this condition.
- And this too... ;(
This text up ^ whas based on your conditions, can you tell me what is wrong?
My post just shows you how to do it - I thought you could figure out from that, but if not here is the exact events:
+ Counter = 1
+ Ball collides with the background
- Channel: Str$(Dir( "Active 2" ))
+ Counter = 0
+ Player On Message
+ P_OnMessage_GetSubchannel( "MooClick" ) = 1
- Set direction to Val(P_OnMessage_GetText$( "MooClick" ))
For the ball collides with background event, surround the outside of the frame with backdrops of which the football is to bounce off. Unless you want the football to leave the play area - I do not know. Or you can use the "Ball leaves play area" condition, which can be found by New Condition > Active 2 > Position > Test position of Active 2.
To compare the subchannel of the message, you use the "Compare two general values" condition. This should have been used and explained in my articles as it is the same condition used to compare messages which send positions of the players.
MooClick only sends strings, and the direction of the ball is a value (not a string). To convert a value to a string, you surround the value by Str$(). This allows MooClick to send the value - when the value is received you can then set the direction of the football to the string received - however you need to convert the string back to a value using val().
You probably need to be more experienced in using the actual interface of MMF first, as it seems you don't know where to find some of the conditions and events - but I hoped this helped you somewhat. If you still can't find the stuff, then tell me whether you are using MMF 1.5 or MMF 2 and I shall create you an example file.
I do step by step what you write here, but... it still doesn't work ;( .
Interface of MMF, if you write "Ball colilides with the background", i understand this, but if you write "Ball collides with edge of screen ", i don't know which condition i have to choose .
If you don't no what he means, then are you sure you should begin to make an online game? Thy are pretty hard...
Oh sweet mary.
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
11th April, 2007 at 20:19:01 -
Flava - I'm impressed by your patience and willingness to help people. Thanks for that.
Unis - I agree with Aptennap on this one. It seems that you're not all that confident in MMF, maybe you should work on some simpler games before tackling online? Online games aren't that difficult, but you will need a basic understanding of custom movements and how MMF works to make anything decent and lag free. Good luck.
I have created a quick example file for you anyway Unis. It involves a slightly different method - rather then sending the new direction when the ball leaves the player area, it sends the direction whenever the direction of the ball changes. This means that the position and direction of the ball should be correct, no matter what obstacle the ball has just collided with.
Hope it helps, however I still believe you should learn your way around MMF a bit more. Look at my example, read the comments and make sure you understand every event and what each event is doing. Hope it helps
Thanks for your patience, it works! But, there is one problem... only "server" can touch the ball. It means:
I have a "My Player" - Host.
And "Other Player" - Join.
And i have condition to "My player" collision with ball -> ball bounce. And, it send posistion (if ball has been touch by Host player). But if ball is "touched" by Other Player, then "not send position".