Ejemplo n.º 1
0
    def createEngine(self):

        if not self.tengine:

            tengine = tileengine.TileEngine()
            self.tengine = tengine

            self.configTileEngine(tengine)
Ejemplo n.º 2
0
    def createEngine(self):

        if not self.tengine:
            print("creating new tile engine")

            tengine = tileengine.TileEngine()
            print("built swig object")
            self.tengine = tengine

            print("swig tile engine: {}".format(tengine))
            print("config function: {}".format(self.configTileEngine))
            self.configTileEngine(tengine)
            print("configured tile engine")
        else:
            print("existing tile engine: {}".format(self.tengine))
    def __init__(
            self,
            running=False,
            timeDelay=10,
            bot=None,
            *args,
            **kwargs):
        #print "MicropolisGenericEngine.__init__", self, "calling micropolisengine.Micropolis.__init__", micropolisengine.Micropolis.__init__, args, kwargs

        micropolisengine.Micropolis.__init__(self, *args, **kwargs)

        self.builderBot = bot
        self.resourceDir = 'res'
        self.running = running
        self.timeDelay = timeDelay
        self.timerActive = False
        self.timerId = None
        self.views = []
        self.interests = {}
        self.residentialImage = None
        self.commercialImage = None
        self.industrialImage = None
        self.transportationImage = None
        self.populationDensityImage = None
        self.rateOfGrowthImage = None
        self.landValueImage = None
        self.crimeRateImage = None
        self.pollutionDensityImage = None
        self.trafficDensityImage = None
        self.powerGridImage = None
        self.fireCoverageImage = None
        self.policeCoverageImage = None
        self.dataTileEngine = tileengine.TileEngine()
        self.robots = []
        self.robotDict = {}
        self.zoneMap = {}
        self.saveFileDir = None
        self.saveFileName = None
        self.metaFileName = None
        self.title = ''
        self.description = ''
        self.readOnly = False
        self.gameMode = 'stopped'


        # NOTE: Because of a bug in SWIG, printing out the wrapped
        # objects results in a crash.  So don't do that! I hope this
        # bug in SWIG gets fixed.
        # TODO: Report SWIG bug, if it's not already known or fixed.

        # Hook the engine up so it has a handle on its Python object side.
        self.userData = micropolisengine.getPythonCallbackData(self)
        #print "USERDATA"#, self.userData

        # Hook up the language independent callback mechanism to our
        # low level C++ Python dependent callback handler.

        self.callbackHook = micropolisengine.getPythonCallbackHook()
        #print "CALLBACKHOOK"#, self.callbackHook

        # Hook up the Python side of the callback handler, defined in
        # our scripted subclass of the SWIG wrapper.

        self._invokeCallback = self.invokeCallback # Cache to prevent GC
        self.callbackData = \
            micropolisengine.getPythonCallbackData(
                self._invokeCallback)
        #print "CALLBACKDATA"#, self.callbackData

        self.expressInterest(
            self,
            ('paused',))

        self.initGame()

        if self.running:
            self.startTimer()

        return self