📄 gameobject.cs
字号:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace BrickOut
{
/// <summary>
///
/// </summary>
public class GameObject
{
protected Image TheImage = null;
public Point Position = new Point(50, 50);
protected Rectangle ImageBounds = new Rectangle(0,0, 10, 10);
protected Rectangle MovingBounds = new Rectangle();
public GameObject(string fileName)
{
TheImage = Image.FromFile(fileName);
ImageBounds.Width = TheImage.Width;
ImageBounds.Height = TheImage.Height;
}
public int Width
{
get
{
return ImageBounds.Width;
}
}
public int Height
{
get
{
return ImageBounds.Height;
}
}
public virtual int GetWidth()
{
return ImageBounds.Width;
}
public Image GetImage()
{
return TheImage;
}
public virtual Rectangle GetBounds()
{
return MovingBounds;
}
public void UpdateBounds()
{
MovingBounds = ImageBounds;
MovingBounds.Offset(Position);
}
public virtual void Draw(Graphics g)
{
UpdateBounds();
g.DrawImage(TheImage, MovingBounds, 0, 0, ImageBounds.Width, ImageBounds.Height, GraphicsUnit.Pixel);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -