def __init__(self, object_set: int, palette_index: int): png = QImage(str(data_dir.joinpath("gfx.png"))) png.convertTo(QImage.Format_RGB888) rows_per_object_set = 256 // 64 y_offset = 12 * rows_per_object_set * Block.HEIGHT self.png_data = png.copy(QRect(0, y_offset, png.width(), png.height() - y_offset)) self.palette_group = load_palette_group(object_set, palette_index)
def _draw_mario(self, painter: QPainter, level: Level): mario_actions = QImage(str(data_dir / "mario.png")) mario_actions.convertTo(QImage.Format_RGBA8888) mario_position = QPoint(*level.header.mario_position()) * self.block_length x_offset = 32 * level.start_action mario_cutout = mario_actions.copy(QRect(x_offset, 0, 32, 32)).scaled( 2 * self.block_length, 2 * self.block_length ) painter.drawImage(mario_position, mario_cutout)
from PySide2.QtCore import QPoint, QRect from PySide2.QtGui import QBrush, QColor, QImage, QPainter, QPen, Qt from foundry import data_dir from foundry.game.File import ROM from foundry.game.gfx.Palette import bg_color_for_object_set, load_palette from foundry.game.gfx.PatternTable import PatternTable from foundry.game.gfx.drawable import apply_selection_overlay from foundry.game.gfx.drawable.Block import Block from foundry.game.gfx.objects.EnemyItem import EnemyObject, MASK_COLOR from foundry.game.gfx.objects.LevelObject import GROUND, LevelObject, SCREEN_HEIGHT, SCREEN_WIDTH from foundry.game.gfx.objects.ObjectLike import EXPANDS_BOTH, EXPANDS_HORIZ, EXPANDS_VERT from foundry.game.level.Level import Level png = QImage(str(data_dir / "gfx.png")) png.convertTo(QImage.Format_RGB888) def _make_image_selected(image: QImage) -> QImage: alpha_mask = image.createAlphaMask() alpha_mask.invertPixels() selected_image = QImage(image) apply_selection_overlay(selected_image, alpha_mask) return selected_image def _load_from_png(x: int, y: int): image = png.copy(QRect(x * 16, y * 16, 16, 16))