Hello everyone ^^; long time no see lol. I sort of stop comming here because I stop learning c/c++ to learn python ^^; Well I am back sort of for some help in getting a c/c++ program hopfully going.
There is one issue tho... I don't have any of the compliers and to be honest... if I can make it out without having to have one, that be great (yea... I am sort of asking you to program it and complie it for me =/)...
I understand the rules, and I don't think I am breaking it when asking this, but can comeone help me covert the follow code from python to c/c++?
Code:
from math import sqrt, pow, floor
class MatrixMap:
def __init__(self):
self.gridSize = 375
self.GridMap = {}
#------------------------------------------------------------------------------
def Add_Area(self, Area):
for x in Area:
self.GridMap[x] = {}
#------------------------------------------------------------------------------
def Add(self, objects):
for object in objects:
self.SetIntoMap(object)
#------------------------------------------------------------------------------
def Update(self, objects):
for object in objects:
self.RemoveFromMap(object)
self.SetIntoMap(object)
#------------------------------------------------------------------------------
def Remove(self, objects):
for object in objects:
self.RemoveFromMap(object)
#------------------------------------------------------------------------------
def BlockInfo(self, object, other="IP"):
Block = []
Poisition = object.Data("Position").split()
for ZNum in xrange(-self.gridSize, self.gridSize+1, self.gridSize):
Z = int((float(Poisition[2])+ZNum)/self.gridSize)
for XNum in xrange(-self.gridSize, self.gridSize+1, self.gridSize):
X = int((float(Poisition[0])+XNum)/self.gridSize)
for YNum in xrange(-self.gridSize, self.gridSize+1, self.gridSize):
Y = int((float(Poisition[1])+YNum)/self.gridSize)
if (X,Y,Z) in self.GridMap[object.Data("Area")]:
for objects in self.GridMap[object.Data("Area")][(X,Y,Z)]:
if objects not in Block and objects is not object and objects.Data("Type") in other:
Block.append(objects)
return Block
#------------------------------------------------------------------------------
def CellInfo(self, object):
Poisition = object.Data("Position").split()
cell = int(float(Poisition[0])/self.gridSize), int(float(Poisition[1])/self.gridSize), int(float(Poisition[2])/self.gridSize)
return self.GridMap[object.Data("Area")][cell]
#------------------------------------------------------------------------------
def SetIntoMap(self, object):
Poisition = object.Data("Position").split()
cell = int(float(Poisition[0])/self.gridSize), int(float(Poisition[1])/self.gridSize), int(float(Poisition[2])/self.gridSize)
if cell in self.GridMap[object.Data("Area")]:
if object not in self.GridMap[object.Data("Area")][cell]:
self.GridMap[object.Data("Area")][cell].append(object)
else:
self.GridMap[object.Data("Area")][cell] = [object]
#------------------------------------------------------------------------------
def RemoveFromMap(self, object):
DeleteList = []
for Areas in self.GridMap:
for Cells in self.GridMap[Areas]:
if object in self.GridMap[Areas][Cells]:
self.GridMap[Areas][Cells].remove(object)
The idea is simple, but I am not sure how about passing python objects to c++ objects or is it all done auto-magic like?
The code it self tracks objects in a 3d grid in blocks to help lower down the anount of update calls... aka Player A moves into block B... all objects in Block B gets the information about Player A movements now leaving all other blocks out of communation.