def rem(eventIndex, entityId):
     if entityId in EventManager.toActive[eventIndex]:
         EventManager.toActive[eventIndex].remove(entityId)
     else:
         Logger.error(
             "EvManager", "Unknown entity " + str(eventIndex) +
             ", with id : " + str(entityId.id))
	def addToTest(entityId):
		# If the entity is not yet in the table of test
		if not entityId in EntityManager.entitiesCol:
			EntityManager.entitiesCol.append(entityId)
		else:
			Logger.error("EnManager", "AddToTest() Error, with " + EntityManager.entities[
				entityId.id].type + " entity adding two same id : " + str(entityId.id))
 def addActive(eventIndex, entityId):
     if not entityId in EventManager.toActive[eventIndex]:
         EventManager.toActive[eventIndex].append(entityId)
     else:
         Logger.error(
             "EvManager", "Tow entities have the same ID " +
             str(eventIndex) + ", with id : " + str(entityId.id))
 def error(self, error):
     # When error, replace the current texture by the error texture
     Logger.error(
         "Texture", "Error while loading texture n°" + str(self.id) + " (" +
         self.path.replace(self.PATH, '') + ')')
     Logger.bold("Error returned :")
     print("  " + str(error) + "\n")
Beispiel #5
0
    def loadMap(zone, name):
        path = "game/resources/map/" + zone + "/" + name + ".json"

        try:
            getValues = json.load(open(path))

            returnValues = []
            returnValues.append([
                int(getValues["entries"]["default"]),
                int(getValues["map"]["events"])
            ])

            returnValues.append(getValues["collision"][0])
            returnValues.append(getValues["entries"])

            returnValues.append(getValues["entities"][0])

            returnValues.append(getValues["layers"])

            returnValues.append(getValues["map"]["tileset"])

            return returnValues
        except json.decoder.JSONDecodeError:
            Logger.error("MapLoading", "Can't load the map " + path)
            exit()
Beispiel #6
0
 def removeToTest(entityId):
     if entityId in EntityManager.entitiesCol:
         EntityManager.entitiesCol.remove(entityId)
     else:
         Logger.error(
             "EnManager", "RemoveToTest() Error " +
             EntityManager.entities[entityId.id].type +
             " entity want to be remove from entityCol, id : " +
             str(entityId.id))
	def addA(args):
		# Insert in args to define the entity the id with checkPlace
		args.insert(entitycollision.EntityCollision.ARGS_ID, EntityManager.checkPlace())
		result = LoadEntity.instance(args)
		if result[0] == "True":
			EntityManager.addWithId(result[1])
		else:
			# No error can append when un-resettable entity in the reset of the map can't be init a time again
			if not result[1] == "No Error":
				Logger.error("LoadEntity", str(result[1]) + "\n" + str(args))
Beispiel #8
0
    def unload():
        for key in TextureManager.textures:
            TextureManager.textures[key].unload()

        TextureManager.textures = {}

        # If there are still textures, the code will warn this
        if len(TextureManager.textures) > 0:
            Logger.error("TextureManager",
                         "Error at the end of the program ->")
            TextureManager.state()
        else:
            Logger.info("TextureManager", "No remaining textures")
Beispiel #9
0
    def setDisplayLayer(self, layer):
        if self.displayLayer != layer:
            # Delete the old id registered if the class was registered
            if not self.displayLayer == -1:
                self.em.removeToDipslay(self.displayLayer, self.entityId)

            # Security
            if layer >= 0 and layer <= 2:
                self.displayLayer = layer
                self.em.addToDisplay(self.displayLayer, self.entityId)
            else:
                Logger.error(
                    "EnDrawable", "Invalid layer (" + str(layer) + ") for " +
                    str(self.type) + " with id " + str(id))
	def init():
		colorama.init()
		Logger.info("Game", "Started")
		print("")
		Config.load()
		Window.beginTime = time.time()

		# Initializing GLFW
		if not glfw.init():
			Logger.error("GLFW", "Failed to init GLFW")
			exit()

		Window.create()  # the window

		# Init game manager
		gm.GameManager.init()
Beispiel #11
0
 def isMap(zone, map, entry):
     path = "game/resources/map/" + zone + "/" + map + ".json"
     state = os.path.isfile(path)
     if not state:
         Logger.error(
             "MapLoading", "The map : " + str(map) + " in zone: " +
             str(zone) + " doesn't exists")
         return False
     else:
         value = json.load(open(path))
         try:
             ok = value["entries"][str(entry)]
             return True
         except KeyError:
             Logger.error(
                 "MapLoading", "The map : " + str(map) + " in zone: " +
                 str(zone) + " has no entry point " + str(entry))
             return False
    def check():

        import os

        # Check if the "data" folder exists (and create it if necessary)
        path = Config.DATA_FOLDER
        if not (os.path.exists(path)) and not (os.path.isdir(path)):
            Logger.info("Config", "Creating '%s' folder..." % path)
            try:
                os.mkdir(path)
                Logger.success("Config", "Done !")
            except OSError:
                Logger.error("Config",
                             "Creation of the directory %s failed" % path)
                exit()

        # Check if the "data/config" folder exists (and create it if necessary)
        path = Config.DATA_FOLDER + "/config"
        if not (os.path.exists(path)) and not (os.path.isdir(path)):
            Logger.info("Config", "Creating '%s' folder..." % path)
            try:
                os.mkdir(path)
                Logger.success("Config", "Done !")
            except OSError:
                Logger.error("Config",
                             "Creation of the directory %s failed" % path)
                exit()

        # Check if the main configuration file exists (and create it if necessary)
        path = Config.MAIN_CONFIG_PATH
        if not (os.path.exists(path)):
            Logger.info("Config",
                        "Creating the user-specific configuration file...")
            Config.createDefaultConfig()

        # Check if the keyboard configuration file exists (and create it if necessary)
        path = Config.KEYBOARD_CONFIG_PATH
        if not (os.path.exists(path)):
            Logger.info(
                "Config",
                "Creating the user-specific key configuration file...")
            Config.createDefaultInputs()
Beispiel #13
0
    def checkServerConfig():

        import os

        # Check if the "data" folder exists (and create it if necessary)
        path = Config.DATA_FOLDER
        if not (os.path.exists(path)) and not (os.path.isdir(path)):
            Logger.info("Config", "Creating '%s' folder..." % path)
            try:
                os.mkdir(path)
                Logger.success("Config", "Done !")
            except OSError:
                Logger.error("Config",
                             "Creation of the directory %s failed" % path)
                exit()

        # Check if the server configuration file exists (and create it if necessary)
        path = Config.SERVER_CONFIG_PATH
        if not (os.path.exists(path)):
            Logger.info(
                "Config",
                "A configuration file needs to be created to connect to the server"
            )
            Config.createDefaultServerConfig()