Beispiel #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);
        }
Beispiel #2
0
 public L()
 {
     blocs[0] = new Bloc { X = 4, Y = 21 };
     blocs[1] = new Bloc { X = 4, Y = 22 };
     blocs[2] = new Bloc { X = 4, Y = 20 };
     blocs[3] = new Bloc { X = 5, Y = 20 };
 }
Beispiel #3
0
 public Ligne()
 {
     blocs[0] = new Bloc { X = 4, Y = 20 };
     blocs[1] = new Bloc { X = 4, Y = 21 };
     blocs[2] = new Bloc { X = 4, Y = 22 };
     blocs[3] = new Bloc { X = 4, Y = 23 };
 }
Beispiel #4
0
 public Marche()
 {
     blocs[0] = new Bloc { X = 3, Y = 20 };
     blocs[1] = new Bloc { X = 4, Y = 20 };
     blocs[2] = new Bloc { X = 4, Y = 21 };
     blocs[3] = new Bloc { X = 5, Y = 21 };
 }
Beispiel #5
0
 public Carree()
 {
     blocs[0] = new Bloc { X = 4, Y = 20 };
     blocs[1] = new Bloc { X = 5, Y = 20 };
     blocs[2] = new Bloc { X = 4, Y = 21 };
     blocs[3] = new Bloc { X = 5, Y = 21 };
 }
Beispiel #6
0
        private void buildBlocs()
        {
            System.Console.WriteLine("* Generating blocs...");
            blocs = new Bloc[nbBlocs];

            blocs[0] = new Bloc(shapes[0], 1);
            blocs[1] = new Bloc(shapes[1], 2);
            blocs[2] = new Bloc(shapes[2], 3);
            blocs[3] = new Bloc(shapes[3], 4);
            blocs[4] = new Bloc(shapes[4], 5);
            blocs[5] = new Bloc(shapes[5], 6);
            blocs[6] = new Bloc(shapes[6], 7);
        }
Beispiel #7
0
 public Ligne()
 {
     blocs[0] = new Bloc {
         X = 4, Y = 20
     };
     blocs[1] = new Bloc {
         X = 4, Y = 21
     };
     blocs[2] = new Bloc {
         X = 4, Y = 22
     };
     blocs[3] = new Bloc {
         X = 4, Y = 23
     };
 }
 public MarcheInverse()
 {
     blocs[0] = new Bloc {
         X = 5, Y = 20
     };
     blocs[1] = new Bloc {
         X = 4, Y = 20
     };
     blocs[2] = new Bloc {
         X = 4, Y = 21
     };
     blocs[3] = new Bloc {
         X = 3, Y = 21
     };
 }
Beispiel #9
0
 public Carree()
 {
     blocs[0] = new Bloc {
         X = 4, Y = 20
     };
     blocs[1] = new Bloc {
         X = 5, Y = 20
     };
     blocs[2] = new Bloc {
         X = 4, Y = 21
     };
     blocs[3] = new Bloc {
         X = 5, Y = 21
     };
 }
Beispiel #10
0
 public L()
 {
     blocs[0] = new Bloc {
         X = 4, Y = 21
     };
     blocs[1] = new Bloc {
         X = 4, Y = 22
     };
     blocs[2] = new Bloc {
         X = 4, Y = 20
     };
     blocs[3] = new Bloc {
         X = 5, Y = 20
     };
 }
Beispiel #11
0
        public Bloc(Bloc bloc)
        {
            if (bloc == null)
            {
                throw new TetrisException("Bloc: Bloc is null");
            }
            posX = bloc.posX;
            posY = bloc.posY;

            angle = bloc.angle;

            dropSpeed = bloc.dropSpeed;

            this.shape = bloc.shape; //todo: probably gonna crash some times.. because its sharing references

            blocID = bloc.blocID;
        }
Beispiel #12
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            //base.OnPaint(pe);
            Graphics g = pe.Graphics;

            drawGrid(g);
            drawBloc(g, game.bloc, false);

            //draw shadow bloc
            Bloc shadowBloc = new Bloc(game.bloc);

            shadowBloc.posX = game.shadowX;
            shadowBloc.posY = game.shadowY;
            drawBloc(g, shadowBloc, true);

            drawGameOver(g);
            drawReplayFinish(g);

            //draw score
            MainWindow parent = (MainWindow)this.Parent;

            parent.setScore(game.score);
        }
Beispiel #13
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);
                        }
                    }
                }
            }
        }