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 Discussion / Online Multiplayer question

Author
Message
Coolest Dealz
20
Years of Service
User Offline
Joined: 13th Mar 2005
Location: Macromedia MX Pro 05
Posted: 15th Mar 2005 03:08
I don't quite understand how it works, what I mean is, if their are 3 players online, and a player moves their character, what would the code be for when this player moves its character, it's not going to be

if upkey()=1 then move character

what excatly is it? Do you follow me?


Backup Your Data Free - http://www.coolestdealz.com
Los
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 15th Mar 2005 10:32
Well I would start off by thinking each player has their own position in the world you've created. Each player has it's own model to control, so you would load up these three objects. Perhaps instead of using numbers you could assign names to the objects?

blueguy = 1
greenguy = 2
black guy = 3

**Officialy has a mental illness.
" Ahh to finish something! My boy, have you ever accomplished anything? "
Coolest Dealz
20
Years of Service
User Offline
Joined: 13th Mar 2005
Location: Macromedia MX Pro 05
Posted: 15th Mar 2005 14:31
good idea, but what would be the controls?

if upkey()=1 the plyernet1 moves....


I'm still a little lost with this


Backup Your Data Free - http://www.coolestdealz.com
Coolest Dealz
20
Years of Service
User Offline
Joined: 13th Mar 2005
Location: Macromedia MX Pro 05
Posted: 17th Mar 2005 05:45
please can you help me!


Backup Your Data Free - http://www.coolestdealz.com
waffle
22
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 21st Mar 2005 07:35
your making it too complicated Think simple.

Each player controls only 1 model. So, all code is basically the same. The only thing your not thinking about is game updates. To start you off, do something like this ...

global NextSend
NextSend=Timer()+1000

then, somewhere about where you end your main loop ....
if NextSend<Timer()
updatethegamestatetoallusers()
NextSend=Timer()+1000
endif
checkforupdates()
sync

here's the key to your game ....
in the update function,
you transmit the location of just the users location
thats it. no matter how many players you have,
that's all you transmit.

in the checkforupdates() function ...
you see if there is data,
then you update data just for the user that sent the data.
again, thats all.


OK, now for the complicated part
What I recomment is you create a memblock (not required,
but if you use text instead, its just more work)
then in each byte of the memblock you place data ...

floats are 4 bytes .... so to send player data
x,y,z plus facing ax,ay,az ....
then on the receive data part,
you set the object based on this memblock data ...

get it ?

Login to post a reply

Server time is: 2025-05-31 05:35:32
Your offset time is: 2025-05-31 05:35:32