def loadTileset(self, mode, theme):
globals.Tiles = []
widths = {"M1": 16, "M3": 16, "MW": 16, "WU": 64}
themes = {0: "plain", 1: "underground", 2: "castle", 3: "airship", 4: "water", 5: "hauntedhouse"}
width = widths[mode]
Tileset = QtGui.QPixmap('tilesets/%s_Field_%s.png' % (mode, themes[theme]))
xcount = Tileset.width() // width
ycount = Tileset.height() // width
sourcex = 0
sourcey = 0
for y in range(ycount):
for x in range(xcount):
if mode == "WU":
if globals.TileWidth != 60:
bmp = Tileset.copy(sourcex + 2, sourcey + 2,
width - 4, width - 4).scaledToWidth(globals.TileWidth, Qt.SmoothTransformation)
else:
bmp = Tileset.copy(sourcex + 2, sourcey + 2, width - 4, width - 4)
else:
if globals.TileWidth != width:
bmp = Tileset.copy(sourcex, sourcey,
width, width).scaledToWidth(globals.TileWidth, Qt.SmoothTransformation)
else:
bmp = Tileset.copy(sourcex, sourcey, width, width)
globals.Tiles.append(bmp)
sourcex += width
sourcex = 0
sourcey += width
评论列表
文章目录