Exemplo n.º 1
0
 public Sprite(params Sprite[] sprites)
 {
     int left = 0;
     int right = 0;
     int top = 0;
     int bottom = 0;
     for (int i = 0; i < sprites.Length; i++)
     {
         left = Math.Min(sprites[i].Left, left);
         right = Math.Max(sprites[i].Right, right);
         top = Math.Min(sprites[i].Top, top);
         bottom = Math.Max(sprites[i].Bottom, bottom);
     }
     Offset = new Point(left, top);
     Image = new BitmapBits(right - left, bottom - top);
     for (int i = 0; i < sprites.Length; i++)
         Image.DrawBitmapComposited(sprites[i].Image, new Point(sprites[i].X - left, sprites[i].Y - top));
 }
Exemplo n.º 2
0
 public override void Draw(BitmapBits bmp, Point camera, ObjectEntry obj, bool includeDebug)
 {
     BitmapBits bits = new BitmapBits(img);
     bits.Flip(obj.XFlip, obj.YFlip);
     bmp.DrawBitmapComposited(bits, new Point(obj.X + offset.X - camera.X, obj.Y + offset.Y - camera.Y));
 }
Exemplo n.º 3
0
 public static Sprite MapToBmp(byte[] artfile, byte[] mapfile, int frame, int startpal)
 {
     BitmapBits[] bmp = null;
     Point off = new Point();
     switch (LevelData.EngineVersion)
     {
         case EngineVersion.S1:
             S1Mappings s1map = new S1Mappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2));
             bmp = LevelData.S1MapFrameToBmp(artfile, s1map, startpal, out off);
             break;
         case EngineVersion.S2:
         case EngineVersion.S2NA:
             S2Mappings s2map = new S2Mappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2));
             bmp = LevelData.S2MapFrameToBmp(artfile, s2map, startpal, out off);
             break;
         case EngineVersion.S3K:
         case EngineVersion.SKC:
             S3KMappings s3kmap = new S3KMappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2));
             bmp = LevelData.S3KMapFrameToBmp(artfile, s3kmap, startpal, out off);
             break;
     }
     BitmapBits Image = new BitmapBits(bmp[0].Width, bmp[0].Height);
     Image.DrawBitmapComposited(bmp[0], Point.Empty);
     Image.DrawBitmapComposited(bmp[1], Point.Empty);
     return new Sprite(Image, off);
 }
Exemplo n.º 4
0
 public static Sprite MapASMToBmp(byte[] artfile, string mapfileloc, string label, int startpal)
 {
     byte[] mapfile = LevelData.ASMToBin(mapfileloc, label);
     BitmapBits[] bmp = null;
     Point off = new Point();
     switch (LevelData.EngineVersion)
     {
         case EngineVersion.S1:
             bmp = LevelData.S1MapFrameToBmp(artfile, new S1Mappings(mapfile, 0), startpal, out off);
             break;
         case EngineVersion.S2:
         case EngineVersion.S2NA:
             bmp = LevelData.S2MapFrameToBmp(artfile, new S2Mappings(mapfile, 0), startpal, out off);
             break;
         case EngineVersion.S3K:
         case EngineVersion.SKC:
             bmp = LevelData.S3KMapFrameToBmp(artfile, new S3KMappings(mapfile, 0), startpal, out off);
             break;
     }
     BitmapBits Image = new BitmapBits(bmp[0].Width, bmp[0].Height);
     Image.DrawBitmapComposited(bmp[0], Point.Empty);
     Image.DrawBitmapComposited(bmp[1], Point.Empty);
     return new Sprite(Image, off);
 }
Exemplo n.º 5
0
 internal static BitmapBits[] S3KMapFrameToBmp(byte[] file, S3KMappings map, int startpal, out Point offset)
 {
     int left = 0;
     int right = 0;
     int top = 0;
     int bottom = 0;
     for (int i = 0; i < map.TileCount; i++)
     {
         left = Math.Min(map[i].X, left);
         right = Math.Max(map[i].X + (map[i].Width * 8), right);
         top = Math.Min(map[i].Y, top);
         bottom = Math.Max(map[i].Y + (map[i].Height * 8), bottom);
     }
     offset = new Point(left, top);
     BitmapBits[] bmp = new BitmapBits[] { new BitmapBits(right - left, bottom - top), new BitmapBits(right - left, bottom - top) };
     for (int i = map.TileCount - 1; i >= 0; i--)
     {
         BitmapBits pcbmp = new BitmapBits(map[i].Width * 8, map[i].Height * 8);
         int ti = 0;
         int pr = map[i].Tile.Priority ? 1 : 0;
         for (int x = 0; x < map[i].Width; x++)
         {
             for (int y = 0; y < map[i].Height; y++)
             {
                 pcbmp.DrawBitmapComposited(
                     ObjectHelper.TileToBmp8bpp(file, map[i].Tile.Tile + ti, (map[i].Tile.Palette + startpal) & 3),
                     new Point(x * 8, y * 8));
                 ti++;
             }
         }
         pcbmp.Flip(map[i].Tile.XFlip, map[i].Tile.YFlip);
         bmp[pr].DrawBitmapComposited(pcbmp, new Point(map[i].X - left, map[i].Y - top));
     }
     return bmp;
 }
Exemplo n.º 6
0
 public override void Draw(BitmapBits bmp, Point camera, ObjectEntry obj, bool includeDebug)
 {
     byte subtype = obj.SubType;
     if (subtype > 10) subtype = 0;
     BitmapBits bits = new BitmapBits(imgs[subtype]);
     bits.Flip(obj.XFlip, obj.YFlip);
     bmp.DrawBitmapComposited(bits, new Point(obj.X + offsets[subtype].X - camera.X, obj.Y + offsets[subtype].Y - camera.Y));
 }
Exemplo n.º 7
0
 public override void Draw(BitmapBits bmp, Point loc, byte subtype, bool XFlip, bool YFlip, bool includeDebug)
 {
     if (subtype > 10) subtype = 0;
     BitmapBits bits = new BitmapBits(imgs[subtype]);
     bits.Flip(XFlip, YFlip);
     bmp.DrawBitmapComposited(bits, new Point(loc.X + offsets[subtype].X, loc.Y + offsets[subtype].Y));
 }
Exemplo n.º 8
0
 public override void Draw(BitmapBits bmp, Point loc, byte subtype, bool XFlip, bool YFlip, bool includeDebug)
 {
     if (!includeDebug) return;
     BitmapBits bits = new BitmapBits(imgs[subtype & 0x1F]);
     bmp.DrawBitmapComposited(bits, new Point(loc.X + offsets[subtype & 0x1F].X, loc.Y + offsets[subtype & 0x1F].Y));
 }