def status(): Logger.info("EnManager", "\n status with len(" + str(EntityManager.len) + ") :\n") for e in EntityManager.entities: Logger.info( "EnManager", "Entity" + str(e.entityId.id) + ", entityType" + e.type)
def unload(self, status=True): # Security when error with unloaded textures if self.correctLoaded: gl.glDeleteTextures(self.id) self.correctLoaded = False if status: Logger.info("Texture -", "Texture n°" + str(self.id) + " unloaded")
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")
def init(): Logger.info("GameManager", "Created") # Init systems TextureManager.init() TextManager.init() InputManager.init(Config.inputs) GameManager.cam = camera.Camera( 70.0, [0, 0, -2 ]) # FOV 70, Precise position of cam to render 18 * 12 tiles ShaderManager.init() GameManager.setCurrentScreen("menuscreen", [True]) GameManager.createCurrentScreen()
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()
def rem(info): id = info[0].id # Unload the entity EntityManager.entities[id].unload() del EntityManager.entities[id] EntityManager.len = len(EntityManager.entities) # Print the removing ? if info[1]: Logger.info("EnManager", "Remove entity n°" + str(id)) if id != len(EntityManager.entities): for i in range(id, EntityManager.len): EntityManager.entities[i].entityId.id -= 1
def loadImage(self, image): try: # Open the image flippedImage = image.transpose(img.FLIP_TOP_BOTTOM) imgData = flippedImage.convert("RGBA").tobytes() self.width = image.width self.height = image.height # Upload to openGL try: self.id = gl.glGenTextures(1) self.bind() gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_REPEAT) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_REPEAT) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, self.width, self.height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, imgData) Logger.info( "Texture +", "Texture n°" + str(self.id) + " loaded (" + self.path.replace(self.PATH, '') + ")") self.correctLoaded = True except Exception as error: gl.glDeleteTextures(self.id) self.error(error) return False except Exception as error: self.error(error) return False
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()
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()
def exit(): gm.GameManager.unload() glfw.terminate() print("") Logger.info("Game", "Closed") sys.exit()
def state(): Logger.info("TeManager", "Textures currently loaded :") print("=" * 45) for key in TextureManager.textures: print("Texture " + key) print("=" * 45)