What I got working so far is:
*Players sending and receiving each other's coordinates, rotation.
*Players sending and receiving each other's bullet coordinates, rotation,type
*Players sending and receiving the items they used(Shield, Speedup, etc)
And I'm currently working on the asteroids. Which are seperated into 3 arrays:
*big meteors
*medium meteors
*small meteors
So I started with the big meteors, and as it isn't working on the moment yet I'm already experiencing slow downs. And I know it's not related to my internet connection as I'm currently testing it locally.
Which made me wonder if I'm using the right way to send and receive data? I'm using the send to extension function. And what I send is a object with arrays.
So for example this would be placed in the Init_Meteors function:
Code: Select all
obj_example.x = new Array();
obj_example.y = new Array();
obj_example.x.push(a_player[playerID].xpos)
obj_example.y.push(a_player[playerID].ypos)
Code: Select all
public function Send_BulletData():void
{
dispatchEvent(new EventType("send.exampledata", false, false, obj_example));
}Code: Select all
smartfox.sendToExtension("ExampleExt", "send.exampledata", evt.arg[0]);Code: Select all
//Send Example Data
if (cmd == "send.exampledata")
{
var myZone = _server.getCurrentZone();
var myRoom = myZone.getRoom(fromRoom);
var playerID = user.getPlayerIndex();
var usersInRoom = myRoom.getAllUsers();
var usersToRespond = new Array();
for (index = 0; index<usersInRoom.length; index++) {
if (user != usersInRoom[index]) {
usersToRespond.push( usersInRoom[index] );
}
}
var response = {};
response._cmd = "receive.exampledata";
response.pID = playerID;
response.pObject = params;
//_server.sendResponse(response, fromRoom, null, usersToRespond);
_server.sendResponse(response, fromRoom, null, myRoom.getAllUsers());
}
which looks something like this:
Code: Select all
public function Receive_ExampleData(exampledata:Object)
{
for (var i:int = 0; i < MAX_EXAMPLES; i++)
{
a_player[i].xpos = exampledata.x;
a_player[i].ypos = exampledata.y;
}
}