PlantWar/Models/BackGround.cs

(完整代码) 968B

using PlantWar.Properties;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace PlantWar.Models
{
    /// <summary>
    /// 游戏背景类
    /// </summary>
    public class BackGround : GameObject
    {
        // 将背景图片绘制到窗体上
        private static  Image imgBG = Resources.background;
        //写构造函数去调用父类GameObject的构造函数
        public BackGround(int x, int y, int speed) : base(x, y, imgBG.Width, imgBG.Height, speed, 0, Direction.Down)
        { }

        //移动
        public override void Draw(Graphics g)
        {
            this.Y += this.Speed;
            if (this.Y == 0)
            {
                this.Y = -850;
            }
            //坐标改变完成后 ,将背景图像不停的绘制到我们窗体中
            g.DrawImage(imgBG, this.X, this.Y);
        }
        
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。