Direct Play with TGF - a good way for...
Author: | Simone
|
Submitted: | 19th February, 2003
|
Views: | 4341
| Rated: |
|
|
Hy all.
In this time I worked for a good way to decrease lag into direct play applications. I don't know if somebody has already done it but I found this way by myself.
To do this you will need string parser 2 and direct play. It's a good way to decrease lag cause in this way the game calculate all the movements of the other players receiving only 1 string for movement.
For example:
-At first you must set the name of all the "functions" or movements.
-Then code what the object must do at the receiving the "function".
So here we go.
//Let's have a simple example where you control an object(p1) only left and right.
*Is message waiting
-Process a msg (//Always must be the first line!)
(Now the movement engine)
*repeat while leftarrow is pressed
-set x(p1)-3
*repeat while rightarrow is pressed
-set x(p1)+3
(And the send process)
*repeat while leftarrow is pressed
*Only one action when the event loops
-send string(directplay):"movel,dir(p1)"
*repeat while rightarrow is pressed
*Only one action when the event loops
-send string(directplay):"mover,dir(p1)"
*Xrepeat while rightarrow is pressed
*Xrepeat while leftarrow is pressed
*Only one action when the event loops
-send string(directplay):"stop,dir(p1)"
//Note: stop,mover and movel are the functions names to set the otherplayer move.So now with the string parser we can translate it into a precalculated movement.Value b of otherplayer will have some sets.Let's have a look how...
*Start of level
-Add delimeter (stringParser)=","
*On receive string
-Set source string(stringparser) to:rcvdstring$(DirectPlay)
-Set dir(otherplayer) to:val(listgetat(stringparser),2)
*ListFirst(StringParser)="mover"
-Set value b of otherplayer to:1
*ListFirst(StringParser)="movel"
-Set value b of otherplayer to:-1
*ListFirst(StringParser)="stop"
-Set value b of otherplayer to:0
//And now set what Value B means for:
*ValueB(otherplayer)=1
-set x(otherplayer)+3
*ValueB(otherplayer)=-1
-set x(otherplayer)-3
Ok that's all. I pass some lines of code cause this is not a really tutorial, but an article to explain all. With this method u can also make the enemy shot ecc... I hope to have made the idea and I am sorry for the bad English but I am italian.
In the next days I will post a little game using this method...
>C1m0<
|
|
Simone
Registered 19/02/2003
Points 102
|