예제 #1
0
        private Image preDrawBloc(int textureID, int angle, bool shadow)
        {
            Bloc  bloc  = game.getBloc(textureID);
            Shape shape = bloc.getShape(angle);
            Image image = new Bitmap(shape.width * BOX_SIZE, shape.height * BOX_SIZE);

            using (Graphics gfx = Graphics.FromImage(image)) {
                for (int y = 0; y < shape.height; y++)   //draw each bloc forming the shape
                {
                    for (int x = 0; x < shape.width; x++)
                    {
                        int absPosX = x + shape.originX;
                        int absPosY = y + shape.originY;
                        if (shape.shape[absPosY, absPosX] == 1)   //if bloc -> draw it
                        {
                            if (shadow)
                            {
                                gfx.DrawRectangle(grayPen, x * BOX_SIZE, y * BOX_SIZE, BOX_SIZE, BOX_SIZE);
                            }
                            else
                            {
                                gfx.DrawImage(tiles[bloc.blocID], x * BOX_SIZE, y * BOX_SIZE);
                            }
                        }
                    }
                }
                gfx.DrawImage(image, 0, 0);
                //System.Console.WriteLine(image.Size.Width + "x" + image.Size.Height);
                //image.Save("test" + textureID + "_" + angle + "_" + shadow + ".bmp");
            }

            return(image);
        }
예제 #2
0
        private void drawBloc(Graphics g, Bloc bloc, bool shadow)
        {
            //System.Console.WriteLine(bloc.posX + "," + bloc.posY);
            //if (bloc.posX < 0 || bloc.posY < 0) return;
            //g.DrawImage(blocsImage[bloc.textureID-1, bloc.angle, shadow?1:0], bloc.posX*BOX_SIZE, bloc.posY*BOX_SIZE);

            for (int y = 0; y < bloc.getShape().size; y++)   //draw each bloc forming the shape
            {
                for (int x = 0; x < bloc.getShape().size; x++)
                {
                    if (bloc.getShape().shape[y, x] == 1)   //if bloc -> draw it
                    {
                        if (shadow)
                        {
                            g.DrawRectangle(grayPen, (bloc.posX + x) * BOX_SIZE, (bloc.posY + y) * BOX_SIZE, BOX_SIZE, BOX_SIZE);
                        }
                        else
                        {
                            g.DrawImage(tiles[bloc.blocID], (bloc.posX + x) * BOX_SIZE, (bloc.posY + y) * BOX_SIZE);
                        }
                    }
                }
            }
        }