LAN Saving and loading randomly spawning actors

Non-platform specific questions.

LAN Saving and loading randomly spawning actors

Postby ResourceDragon » Sun Apr 01, 2012 5:57 am

Hello, it's me again. I've been working on a multiplayer game over a LAN (That works through our household's HomeGroup), And i've hit my last roadblock. If I can get this to work, all the technical coding and such will be done.

Now, the problem i've come across, is I have an actor that randomly spawns an enemy and a random time. The actors it spawns are the same actor. (So they are clones)

How would I go about saving the x, y, animpos, hp, speed, etc. Of all the clones, and loading all of these into the other game?(Preferably without lag)

One way i've found would work would be requiring making another variable for EVERY actor.variable, but this would take hundreds of variables, and a crap load of time I don't have. The end result would be extreme lag, and how would you know how many clones and when to spawn them into the other game?

Another way i've thought about doing it, would be that one computer has the whole game with three canvas' that draw from the three corresponding players, save the drawing and load it into other games the other three players have. The problems with this would be that I don't know how the canvas' work, or how to save and load the drawn items, and how the other three players would be able to control there players with keys, let alone moving each players cursor to aim their weapon.

Figuring out how to do this would up the games fun value immensely.(It's already fun, but it would be awesome to get a LAN Setup up and running.)

I have the non-random variables I need working(i.e. Player1's x and y, Player2's x and y) But it's just these enemy clones that I need help with.

Please help..
ResourceDragon
 
Posts: 39
Joined: Thu Feb 16, 2012 2:17 am
Score: 0 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby Hblade » Sun Apr 01, 2012 6:05 am

Code: Select all
int XSAV[20000], YSAV[20000], APSAV[20000], HPSAV[20000], SPSAV[20000], ETC[20000];

After creating those arrays, you can store 20,000 actor's data in them. (Prefered you create the arrays normally through the variable creation)
Code: Select all
Array[cloneindex]=value;

Replace Array with the array name, XSAV for example, and replace value; with the value, x or y for example, or animpos.

Example:
Code: Select all
XSAV[cloneindex]=x;


When loaded:
Code: Select all
x=XSAV[cloneindex];


:)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby ResourceDragon » Sun Apr 01, 2012 4:57 pm

Hm, I thought arrays would be an answer too the problem...but i've never used them before.


Ohhh... I see. This just might work, you've given light to some new ideas for me. Thanks! I'll be back with my findings.
ResourceDragon
 
Posts: 39
Joined: Thu Feb 16, 2012 2:17 am
Score: 0 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby DST » Sun Apr 01, 2012 5:36 pm

That's too much data to send over a network. The lag will be absolutely horrible.

Consider instead, making a pregenerated list of random numbers, and sending that list to all clients at the start of the game. Then all of them will spawn the same enemies. Then you pass the actions of the players, and if player 2 kills something in his version of the game, his identical position and action will kill that enemy in the other players' versions of the game.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby ResourceDragon » Sun Apr 01, 2012 5:56 pm

I thought about that too, but then you would have the same enemy in two different locations... It would be nice for the enemies to keep their x, y, and animpos the same in all the clients... :/ And I just realized i've got to be able to tell the other clients the said enemy died, as well. Hmmm..

The pregenerated list of numbers fixes problem 1 of 3 though. thanks.
ResourceDragon
 
Posts: 39
Joined: Thu Feb 16, 2012 2:17 am
Score: 0 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby Hblade » Sun Apr 01, 2012 6:15 pm

Then you could set it up where you have an array of 64 instead, and it only captures the loneindex of actors that are on the screen of either 2 (meaning, a total of 32 enemies max on screen per player)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby ResourceDragon » Sun Apr 01, 2012 6:46 pm

That might work too, but i've noticed even trying to SAVE any variables, let alone load them, causes GE games to lag..
ResourceDragon
 
Posts: 39
Joined: Thu Feb 16, 2012 2:17 am
Score: 0 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby Hblade » Sun Apr 01, 2012 7:49 pm

oh DX

try FILE *file = fopen or w/e :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby ResourceDragon » Sun Apr 01, 2012 11:28 pm

uh...

Can you put an example for the FILE* code?
ResourceDragon
 
Posts: 39
Joined: Thu Feb 16, 2012 2:17 am
Score: 0 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby Hblade » Mon Apr 02, 2012 12:57 am

Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby ResourceDragon » Mon Apr 02, 2012 4:25 am

....

I'm sorry... DX But that just confuses me more... :cry:
ResourceDragon
 
Posts: 39
Joined: Thu Feb 16, 2012 2:17 am
Score: 0 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby skydereign » Mon Apr 02, 2012 5:12 am

Well the point is there actually are a lot of FILE* explanations on these forums. In fact if you search my posts, I've explained how FILE*s a number of times. That actually goes about almost any questions people have. But, here's hopefully a more informative link.
http://game-editor.com/forum/viewtopic.php?f=2&t=11396&p=80049&#p80049
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: LAN Saving and loading randomly spawning actors

Postby Hblade » Mon Apr 02, 2012 4:30 pm

Thats the post I was looking for ^^ I fail at reserach :oops: sorry hehe.

Sky's explanation will so.ve your confusion :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest