Model/GameObject.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

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

namespace FlappyBird.Model
{
    /// <summary>
    /// 游戏对象父类
    /// </summary>
    public abstract class GameObject
    {
        /// <summary>
        /// 横坐标
        /// </summary>
        public int X { get; set; }
        /// <summary>
        /// 纵坐标
        /// </summary>
        public int Y { get; set; }
        /// <summary>
        /// 游戏宽度
        /// </summary>
        public int Width { get; set;  }
        /// <summary>
        /// 高度
        /// </summary>
        public int Height
        {
            get;
            set;
        }

        public GameObject(int x, int y, int width, int height)
        {
            this.X = x;
            this.Y = y;
            this.Width = width;
            this.Height = height;
        }

        //move的方法  draw自己的方法
        //鸟是上下移动  管子 左右移动

        public abstract void Move();

        /// <summary>
        /// 绘制游戏对象的抽象方法 具体怎么绘制 子类自己去重写
        /// </summary>
        /// <param name="g"></param>
        public abstract void Draw(Graphics g);

        public virtual Rectangle GetRectangle()
        {
            return new Rectangle(this.X, this.Y, this.Width, this.Height);
        }


    }
后面还有 1 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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