示例#1
0
        public void Draw(Bitmap bgimg, FallingStone Pebble, List <Obstacle> Obstacles, int speed, int tick)
        {
            if (shift > destinationRect.Width / 2)
            {
                shift = shift % (destinationRect.Width / 2);
            }
            if (tick % 15 == 1)
            {
                score += (5 * (speed - 2));
            }
            destinationRect.X = shift += (1 + speed);
            graphics.DrawImage(bgimg, sourceRect, destinationRect, GraphicsUnit.Pixel);
            graphics.DrawImage(Pebble.Pic, Pebble.ScaledPengRect, Pebble.DefPengRect, GraphicsUnit.Pixel);

            //Debug
            //graphics.FillRectangle(new SolidBrush(Color.Red), 450 / 2, 450 / 2, 2, 2);
            //graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black), 1), Pebble.ScaledPengRect);

            Pebble.Fly();
            foreach (Obstacle obs in Obstacles)
            {
                graphics.DrawImage(Ice, obs.rectangle, obs.defrectangle, GraphicsUnit.Pixel);
                obs.Shift(speed);
            }
            graphics.DrawString
            (
                score.ToString(),
                new Font(FontFamily.GenericMonospace, 30, FontStyle.Bold, GraphicsUnit.Pixel),
                new SolidBrush(Color.WhiteSmoke),
                450 - 21 * (score.ToString().Length),
                0
            );
            Parent.Invalidate();
        }