예제 #1
0
 internal void SetStaticSprite(GameObject obj, GraphicsID id, PaletteID palette, Bitmap source, int width)
 {
     gameObjectMap[obj] = new StaticSprite(source, id, width, source.Width / width)
     {
         Palette = palette
     };
 }
예제 #2
0
        internal static void SwapColors(Bitmap source, PaletteID palette)
        {
            if ((int)palette == (int)PaletteID.Blinky || palette == (int)PaletteID.Empty)
            {
                return;
            }
            IDictionary <Color, Color> paletteMap = GetColorMap(palette);
            BitmapData bmpData = source.LockBits(new Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadWrite, source.PixelFormat);

            IntPtr ptr   = bmpData.Scan0;
            int    bytes = Math.Abs(bmpData.Stride) * source.Height;

            byte[] values = new byte[bytes];
            Marshal.Copy(ptr, values, 0, bytes);

            for (int i = 0; i < bytes; i += 4)
            {
                Color src  = Color.FromArgb(values[i + 3], values[i + 2], values[i + 1], values[i]);
                Color dest = paletteMap[src];
                values[i + 3] = dest.A;
                values[i + 2] = dest.R;
                values[i + 1] = dest.G;
                values[i]     = dest.B;
            }

            Marshal.Copy(values, 0, ptr, bytes);
            source.UnlockBits(bmpData);
        }
예제 #3
0
        private static IDictionary <int, Color> GetPaletteMap(PaletteID id)
        {
            Bitmap palette = GetPalette(id);
            var    map     = new Dictionary <int, Color>();

            for (int i = 0; i < ColorsPerPalette; ++i)
            {
                map.Add(i, palette.GetPixel(0, i));
            }
            return(map);
        }
예제 #4
0
        internal static IDictionary <Color, Color> GetColorMap(PaletteID id)
        {
            var results = new Dictionary <Color, Color>();
            var destMap = GetPaletteMap(id);

            for (int i = 0; i < ColorsPerPalette; ++i)
            {
                results.Add(BasePaletteMap[i], destMap[i]);
            }
            results.Add(Color.FromArgb(0, 255, 255, 255), Color.FromArgb(0, 255, 255, 255));

            return(results);
        }
예제 #5
0
 internal GhostObject(GraphicsHandler handler, GhostType type, PacmanObject target, Maze level)
     : base(GraphicsConstants.SpriteSize)
 {
     normalPalette = type.ToPalette();
     sprite        = new GhostSprite()
     {
         Palette = normalPalette
     };
     handler.Register(this, sprite);
     Behavior = GhostAIBehavior.FromGhostType(type, this, target, level);
     State    = new GhostHomeState(this);
     PerformTurn(Direction.Down);
     Velocity = Vector2.Zero;
 }
예제 #6
0
 internal void SetStaticSprite(GameObject obj, GraphicsID id, PaletteID palette)
 => SetStaticSprite(obj, id, palette, Resources.Sprites, GraphicsConstants.SpriteWidth);
예제 #7
0
 internal static Bitmap GetPalette(PaletteID id) => Resources.Palettes.Clone(new Rectangle(new Point((int)id, 0), new Size(1, 4)), Resources.Palettes.PixelFormat);