Ejemplo n.º 1
0
    def __init__(self, manager):
        self.background = Sprite("Resources/Backgrounds/level1.png").get_image(0, 0, public.display_dimensions[0], public.display_dimensions[1])

        self.manager = manager;

        self.player = Player()
        self.player.set_position(250, 254)

        minion1 = CommonMinion()
        minion1.set_movement(300, 278, 300, 500)

        self.enemies = [
            minion1
        ]

        self.tile_map = TileMap("Resources/Maps/level1.map")
Ejemplo n.º 2
0
    def __init__(self, pnl):
        wx.Frame.__init__(self,
                          None,
                          wx.ID_ANY,
                          pnl["title"],
                          size=(100, 100),
                          style=0)
        self.Bind(wx.EVT_CLOSE, self.onClose)

        self.bmps = BitMaps(os.path.join("..", "bitmaps"))
        self.tileMap = TileMap(self.bmps)

        self.fontTurnouts = wx.Font(10, wx.FONTFAMILY_TELETYPE,
                                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        self.colorTurnouts = wx.Colour(255, 128, 20)

        self.fontSignals = wx.Font(8, wx.FONTFAMILY_TELETYPE,
                                   wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        self.colorSignals = wx.Colour(255, 255, 0)

        self.fontBlocks = wx.Font(14, wx.FONTFAMILY_TELETYPE,
                                  wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        self.colorBlocks = wx.Colour(255, 20, 20)

        self.fontLabels = wx.Font(18, wx.FONTFAMILY_TELETYPE,
                                  wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        self.colorLabels = wx.Colour(255, 255, 255)

        self.loadData(pnl["filename"])

        rows = len(self.mapArray)
        cols = len(self.mapArray[0])

        sz = wx.BoxSizer(wx.VERTICAL)

        self.panelMap = []
        self.turnouts = []
        self.signals = []
        self.turnoutMap = {}  # label to turnout map
        self.signalMap = {}  # label to signal map

        for r in range(rows):
            rowsz = wx.BoxSizer(wx.HORIZONTAL)
            rowMap = []

            for c in range(cols):
                tid = self.mapArray[r][c]
                tileType = self.tileMap.getTileType(tid)
                if tileType.isSignal():
                    b = wx.StaticBitmap(self,
                                        wx.ID_ANY,
                                        tileType.getBmp(STYPE_RED),
                                        size=BMPDIM,
                                        style=0)
                    sid = len(self.signals)
                    sg = RRSignal(sid, tileType, r, c, b, self.clickSignal)
                    lbl = self.getSignalLabel(r, c)
                    if lbl is not None:
                        self.signalMap[lbl] = sg

                    self.signals.append([sg])
                    rowMap.append([b, None])
                else:
                    te = TrackElement(tileType, r, c)
                    b = wx.StaticBitmap(self,
                                        wx.ID_ANY,
                                        te.getBmp(),
                                        size=BMPDIM,
                                        style=0)
                    if tileType.isTurnout():
                        toid = len(self.turnouts)
                        to = Turnout(toid, te, b, self.clickTurnout)
                        te.setTurnout(to)
                        lbl = self.getTurnoutLabel(r, c)
                        if lbl is not None:
                            self.turnoutMap[lbl] = to

                        self.turnouts.append(to)
                        b.SetBitmap(te.getBmp())
                    rowMap.append([b, te])

                rowsz.Add(b)

            sz.Add(rowsz)
            self.panelMap.append(rowMap)

        self.SetSizer(sz)
        self.Fit()

        self.stLabels = []
        for to in self.annotations["turnouts"].values():
            self.placeLabel(to["row"] + to["offsetr"],
                            to["col"] + to["offsetc"],
                            to["adjx"],
                            to["adjy"],
                            to["label"],
                            font=self.fontTurnouts,
                            fg=self.colorTurnouts)

        for sg in self.annotations["signals"].values():
            self.placeLabel(sg["row"] + sg["offsetr"],
                            sg["col"] + sg["offsetc"],
                            sg["adjx"],
                            sg["adjy"],
                            sg["label"],
                            font=self.fontSignals,
                            fg=self.colorSignals)

        for bl in self.annotations["blocks"]["blocks"].values():
            self.placeLabel(bl["row"],
                            bl["col"],
                            bl["adjx"],
                            bl["adjy"],
                            bl["label"],
                            font=self.fontBlocks,
                            fg=self.colorBlocks)

        for lbl in self.annotations["labels"]:
            self.placeLabel(lbl["row"],
                            lbl["col"],
                            lbl["adjx"],
                            lbl["adjy"],
                            lbl["label"],
                            font=self.fontLabels,
                            fg=self.colorLabels)