Hello everyone!
I was just wondering how to send a 2D array for my game world (Tile map) over multi-sync using Dark GDK?
I have read up about Dark GDK memblocks but haven't managed to get a working example going, to show I have tried a shot at it here is my attempt. I try and load the memblock into a bitmap and read data off of that;
client side:
dbCreateBitmap(1,300,300);
dbSetCurrentBitmap(1);
dbCLS(dbRGB(0,0,0));
dbMakeMemblockFromBitmap(1,1);
NetGetData(reinterpret_cast<char*>(dbGetMemblockPtr(1)),dbGetMemblockSize(1));
for(int x = 0; x < World_Map.size(); x ++)
{
for(int y = 0; y < World_Map.size(); y ++)
{
World_Map[x][y] = dbRGBR(dbPoint(x,y));
}
}
dbDeleteBitmap(1);
dbSetCurrentBitmap(0);
Player_Active = true;
Server side:
NetPutByte(Data_SpawnPoint);
NetPutInt(World_SpawnX);
NetPutInt(World_SpawnY);
NetSend(Server_PlayerJoined);
dbCreateBitmap(1,300,300);
dbSetCurrentBitmap(1);
dbCLS(dbRGB(1,0,0));
for(int x = 0; x < World_Map.size(); x ++)
{
for(int y = 0; y < World_Map.size(); y ++)
{
dbDot(x,y,dbRGB(World_Map[x][y],0,0));
}
}
NetPutByte(Data_MapWhole);
dbMakeMemblockFromBitmap(1,1);
NetPutData(reinterpret_cast<char*>(dbGetMemblockPtr(1)),dbGetMemblockSize(1));
NetSend(Server_PlayerJoined);
I would be so appreciative if I got a reply, Thanks!
Happy-programming!
from Helpfullprogrammer.