Exemplo n.º 1
0
        void TileRow(Surface surf, Grp grp, byte[] pal, int l, int c, int r, int y)
        {
            Surface lsurf = GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(l),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);

            Surface csurf = GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(c),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);


            Surface rsurf = GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(r),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);


            surf.Blit(lsurf, new Point(0, y));
            for (int x = grp.Width; x < surf.Width - grp.Width; x += grp.Width)
            {
                surf.Blit(csurf, new Point(x, y));
            }
            surf.Blit(rsurf, new Point(surf.Width - grp.Width, y));
        }
Exemplo n.º 2
0
        void TileRow(CALayer surf, Grp grp, byte[] pal, int l, int c, int r, int y)
        {
            CALayer l_layer = GuiUtil.CreateLayerFromBitmap(grp.GetFrame(l),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);

            CALayer c_layer = GuiUtil.CreateLayerFromBitmap(grp.GetFrame(c),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);


            CALayer r_layer = GuiUtil.CreateLayerFromBitmap(grp.GetFrame(r),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);

#if notyet
            surf.Blit(lsurf, new Point(0, y));
            for (int x = grp.Width; x < surf.Width - grp.Width; x += grp.Width)
            {
                surf.Blit(csurf, new Point(x, y));
            }
            surf.Blit(rsurf, new Point(surf.Width - grp.Width, y));
#endif
        }
Exemplo n.º 3
0
    public static void Main(string[] args)
    {
        string filename    = args[0];
        string palettename = args[1];

        Console.WriteLine("grp file {0}", filename);
        Console.WriteLine("palette file {0}", palettename);

        FileStream fs = File.OpenRead(filename);

        Grp grp = new Grp();

        ((MpqResource)grp).ReadFromStream(fs);
        Pcx pal = new Pcx();

        pal.ReadFromStream(File.OpenRead(palettename), -1, -1);

        for (int i = 0; i < grp.FrameCount; i++)
        {
            BMP.WriteBMP(String.Format("output{0:0000}.bmp", i),
                         grp.GetFrame(i),
                         grp.Width, grp.Height,
                         pal.Palette);
        }
    }
Exemplo n.º 4
0
 protected override Surface CreateSurface()
 {
     return(GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(frame),
                                            grp.Width, grp.Height,
                                            Palette,
                                            true));
 }
Exemplo n.º 5
0
 protected override CALayer CreateLayer()
 {
     return(GuiUtil.CreateLayerFromBitmap(grp.GetFrame(frame),
                                          grp.Width, grp.Height,
                                          Palette,
                                          true));
 }
Exemplo n.º 6
0
    static bool Animate()
    {
        if (walking)
        {
            current_frame_num += FRAME_STEP;

            if (current_frame_num > WALK_CYCLE_END)
            {
                num_walks++;
                if (num_walks > 10)
                {
                    num_walks         = 0;
                    walking           = false;
                    current_frame_num = DEATH_CYCLE_START;
                }
                else
                {
                    current_frame_num = WALK_CYCLE_START;
                }
            }
        }
        else         /* dying */
        {
            if (current_frame_num == DEATH_CYCLE_END)
            {
                death_timer++;
                if (death_timer == 30)
                {
                    death_timer       = 0;
                    walking           = true;
                    current_frame_num = WALK_CYCLE_START;
                }
            }
            else
            {
                current_frame_num++;
            }
        }

        byte[] pixbuf_data = CreatePixbufData(grp.GetFrame(current_frame_num),
                                              grp.Width, grp.Height,
                                              Palette.default_palette);

        Gdk.Pixbuf temp = new Gdk.Pixbuf(pixbuf_data,
                                         Colorspace.Rgb,
                                         false,
                                         8,
                                         grp.Width, grp.Height,
                                         grp.Width * 3,
                                         null);

        current_frame = temp.ScaleSimple(grp.Width * 2, grp.Height * 2, InterpType.Nearest);

        temp.Dispose();

        drawing_area.QueueDraw();

        return(true);
    }
Exemplo n.º 7
0
        public override void DrawInContext(CGContext ctx)
        {
            current_frame = current_frame % frames.Length;

            if (frames[current_frame] == null)
            {
                frames[current_frame] = GuiUtil.CGImageFromBitmap(grp.GetFrame(current_frame),
                                                                  grp.Width, grp.Height,
                                                                  palette,
                                                                  true);
            }

            ctx.DrawImage(new RectangleF(x, y, grp.Width, grp.Height), frames[current_frame]);
        }
Exemplo n.º 8
0
		void TileRow (Surface surf, Grp grp, byte[] pal, int l, int c, int r, int y)
		{
			Surface lsurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (l),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);

			Surface csurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (c),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);


			Surface rsurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (r),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);


			surf.Blit (lsurf, new Point (0,y));
			for (int x = grp.Width; x < surf.Width - grp.Width; x += grp.Width)
				surf.Blit (csurf, new Point (x, y));
			surf.Blit (rsurf, new Point (surf.Width - grp.Width,y));
		}
Exemplo n.º 9
0
        void DoPlayFrame(int frame_num)
        {
            if (current_frame != frame_num)
            {
                current_frame = frame_num;

                if (sprite_surface != null)
                {
                    sprite_surface.Dispose();
                }

                sprite_surface = GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(frame_num),
                                                                 grp.Width, grp.Height,
                                                                 palette,
                                                                 true);
                Invalidate();
            }
        }
Exemplo n.º 10
0
        void Paint(DateTime now)
        {
            int draw_x = (int)(x - hot_x);
            int draw_y = (int)(y - hot_y);

            if (current_frame == grp.FrameCount)
            {
                current_frame = 0;
            }

            if (surfaces[current_frame] == null)
            {
                surfaces[current_frame] = GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(current_frame),
                                                                          grp.Width, grp.Height,
                                                                          palette,
                                                                          true);
            }

            Painter.Blit(surfaces[current_frame], new Point(draw_x, draw_y));
        }