Esempio n. 1
0
File: tmx.py Progetto: 602p/JT3
from framebase import frame
import logger, pygame, framebase
globals().update(logger.build_module_logger("tmx_loader"))

frame.loader.require_library("pygame", "pytmx")

debug("Requesting pytmx load")
try:
    frame.load_library_as_module("pytmx")
except ImportError:
    error("pytmx not availible, failing")
    frame.loader.abort_module_load("pytmx not availible")

debug("Success!")

class TMXMap:
    def __init__(self, fn):
        self.map=frame.pytmx.util_pygame.load_pygame(fn)
        self.surf=pygame.Surface((self.map.width*self.map.tilewidth, self.map.height*self.map.tileheight))
        self.named_contained_entites={}
        self.contained_entities=[]
        self._process_map()

    def _process_map(self):
        for layer in self.map.visible_layers:
            debug("Loading layer: "+str(layer))
            if isinstance(layer, frame.pytmx.TiledTileLayer):
                # debug(str(layer))
                for x, y, image in layer.tiles():
                    # debug((x,y,image))
                    self.surf.blit(image, (x*self.map.tilewidth, y*self.map.tileheight))
Esempio n. 2
0
from framebase import frame
import logger, framebase
globals().update(logger.build_module_logger("pygame"))

try: frame.load_library_as_module("pygame")
except ImportError: error("Pygame not availible, PygameCore will fail!")

@frame.register_this("pygamecore")
class PygameCore(framebase.Observer):
    def __init__(self):
        pass

    def preinit(self):
        info("Initilizing PygameCore base")
        frame.pygame.init()
        frame.screen=frame.pygame.display.set_mode((10,10))
        frame.pygame.display.set_caption("Loading")

    def run_main(self):
        info("Initializing PygameCore")
        frame.pygame.init()
        frame.screen=frame.pygame.display.set_mode((800,600))
        frame.pygame.display.set_caption(frame.loader["window_title"])
        self.clock=frame.pygame.time.Clock()
        running=True

        debug("Creating a PyConsole (enabled ="+str(frame.loader["enable_pyconsole"])+")")
        self.pyconsole=frame._pyconsole_Console(frame.screen, (0,0,800,200), localsx={"frame":frame})

        frame.send_event("core_loaded")
Esempio n. 3
0
 def handle_event_core_loaded(self):
     frame.load_library_as_module("fpsgraph")