Forum ActionScript 3.0 Storing coins and picking up coins

Problems and discussions relating to ActionScript 3.0 here.

Storing coins and picking up coins

Postby speedtouch » May 2nd, 2011, 6:11 am

I've run into an issue in how I'm going to deal with storing coin, so that they can be picked up by the players.

What I'm planning on doing is:
    1. Making a map with coins throughout it
    2. Storing the x,y locations of the coins in a database, as well as the map name. Only to be done ONCE per map, by me, and not by players.
    3. Then when a game is started from a room, the client will tell the server which map was chosen.
    4. The server will get the coin locations based on the map name
    5. When a player picks up the coin, a message is sent to the server, which then does a check, to ensure they actually got a coin. Which then tells the rest of the players that the coin was picked up.

So my problem here is that how does the server know which coin that the player picked up? Loop through them all and check for the closest one? Could that cause problems with multiple coins close together? And if that works, how do the rest of the clients know which coin was picked up, so they can remove it?

Perhaps I'm looking at this all wrong though, is there a better way of going about it?
speedtouch
 
Posts: 4
Joined: April 23rd, 2011, 1:08 am

Re: Storing coins and picking up coins

Postby cjcenizal » May 2nd, 2011, 5:05 pm

Your process sounds good, but I would also associate an ID with the coin, if I were you. Whenever you need to know which object has been acted on within a system, just associate an ID or key with it. Hope this helps!
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am

Re: Storing coins and picking up coins

Postby speedtouch » May 3rd, 2011, 7:04 pm

Ah that's a great idea! Should be able to work through it now, thanks! :)
speedtouch
 
Posts: 4
Joined: April 23rd, 2011, 1:08 am

Re: Storing coins and picking up coins

Postby default0 » May 4th, 2011, 4:38 pm

speedtouch wrote:Ah that's a great idea! Should be able to work through it now, thanks! :)


You can save bandwidth if you send the array in the exact order as it is on the server to the client and then only sending the loop variable (ie position in the array) to identify what coin was picked up since the arrays are perfectly the same. This way you can save the bandwidth of actually sending an extra ID value over for each coin ;)

Best Regards
Try to play my Game: -->BlackGalaxy<--
User avatar
default0
 
Posts: 115
Joined: February 2nd, 2010, 6:46 pm
Location: Germany


Return to ActionScript 3.0



cron