예제 #1
0
        public void changePipeLocation(Pipe pipe)
        {
            int lowerPipeHeight  = rnd.Next(20, (this.Height - Consts.BIRD_HEIGHT * Consts.PIPE_BIRDS_SPACE - 20));
            int higherPipeHeight = Height - lowerPipeHeight - Consts.BIRD_HEIGHT * Consts.PIPE_BIRDS_SPACE;


            pipe.LowerPipe.Size  = new Size(Consts.PIPE_WIDTH, lowerPipeHeight);
            pipe.HigherPipe.Size = new Size(Consts.PIPE_WIDTH, higherPipeHeight);

            pipe.LowerPipe.Image  = Consts.ResizeImage(Desktop_Minigames.Properties.Resources.flappy_bird_pipe, Consts.PIPE_WIDTH, lowerPipeHeight);
            pipe.HigherPipe.Image = Consts.ResizeImage(Desktop_Minigames.Properties.Resources.flappy_bird_pipe_rotated, Consts.PIPE_WIDTH, higherPipeHeight);

            moveControl(pipe.LowerPipe, new Point(this.Width, 400 + Consts.BIRD_HEIGHT - lowerPipeHeight));
            moveControl(pipe.HigherPipe, new Point(this.Width, pipe.HigherPipe.Location.Y));
        }
예제 #2
0
        private void createNewGame()
        {
            TransparentPictureBox start_button = new TransparentPictureBox();

            start_button.Click   += new EventHandler(start);
            start_button.Location = new Point(300, 200);
            start_button.Size     = new Size(200, 100);
            start_button.Padding  = new Padding(5);
            start_button.Dock     = DockStyle.Fill;
            start_button.Image    = Consts.ResizeImage(Desktop_Minigames.Properties.Resources.flappy_bird_start_button, 200, 100);
            Controls.Add(start_button);
            bird.Location = new Point(200, 200);
            gameOver      = false;
            gameCounter   = 0;
            changeCounter();
        }
예제 #3
0
        public void createPipes(int x)
        {
            int lowerPipeHeight  = rnd.Next(20, (this.Height - Consts.BIRD_HEIGHT * Consts.PIPE_BIRDS_SPACE - 20));
            int higherPipeHeight = Height - lowerPipeHeight - Consts.BIRD_HEIGHT * Consts.PIPE_BIRDS_SPACE;

            Image lowerPipeImage = Desktop_Minigames.Properties.Resources.flappy_bird_pipe;

            lowerPipeImage = Consts.ResizeImage(lowerPipeImage, Consts.PIPE_WIDTH, lowerPipeHeight);

            Image higherPipeImage = Desktop_Minigames.Properties.Resources.flappy_bird_pipe_rotated;

            higherPipeImage = Consts.ResizeImage(higherPipeImage, Consts.PIPE_WIDTH, higherPipeHeight);

            PictureBox lowerPipe = new PictureBox();

            lowerPipe.Location = new Point(x, 400 + Consts.BIRD_HEIGHT - lowerPipeHeight);
            lowerPipe.Image    = lowerPipeImage;
            lowerPipe.Size     = new Size(Consts.PIPE_WIDTH, lowerPipeHeight);

            PictureBox higherPipe = new PictureBox();

            higherPipe.Location = new Point(x, 0);
            higherPipe.Image    = higherPipeImage;
            higherPipe.Size     = new Size(Consts.PIPE_WIDTH, higherPipeHeight);
            Invoke(new singleControlDelegate(addControl), higherPipe);
            Invoke(new singleControlDelegate(addControl), lowerPipe);

            lowerPipe.Click  += new EventHandler(pipeClick);
            higherPipe.Click += new EventHandler(pipeClick);

            lowerPipe.BackColor  = Color.Transparent;
            higherPipe.BackColor = Color.Transparent;

            Pipe pipe = new Pipe();

            pipe.LowerPipe  = lowerPipe;
            pipe.HigherPipe = higherPipe;
            pipes.Add(pipe);
        }
예제 #4
0
        public FlappyBird()
        {
            InitializeComponent();

            this.Size = new Size(800, 400 + Consts.BIRD_HEIGHT * 2 - 15);
            Image bird_image = Desktop_Minigames.Properties.Resources.flappy_bird_bird;

            bird_image = Consts.ResizeImage(bird_image, Consts.BIRD_WIDTH, Consts.BIRD_HEIGHT);
            Image background_image = Desktop_Minigames.Properties.Resources.flappy_bird_background;

            background_image = Consts.ResizeImage(background_image, this.Width, this.Height);

            gameCounterLabel.Text      = "" + gameCounter;
            gameCounterLabel.Font      = new Font("Arial", 20);
            gameCounterLabel.Size      = new Size(50, 50);
            gameCounterLabel.BackColor = Color.Transparent;
            Controls.Add(gameCounterLabel);

            bird                 = new PictureBox();
            bird.BackColor       = Color.Transparent;
            bird.Size            = new Size(Consts.BIRD_WIDTH, Consts.BIRD_HEIGHT);
            bird.Image           = bird_image;
            bird.Location        = new Point(200, 200);
            this.BackgroundImage = background_image;
            Controls.Add(bird);

            TransparentPictureBox start_button = new TransparentPictureBox();

            start_button.Click   += new EventHandler(start);
            start_button.Location = new Point(300, 200);
            start_button.Size     = new Size(200, 100);
            start_button.Padding  = new Padding(5);
            start_button.Dock     = DockStyle.Fill;
            start_button.Image    = Consts.ResizeImage(Desktop_Minigames.Properties.Resources.flappy_bird_start_button, 200, 100);

            Controls.Add(start_button);
        }