star.cs

来自「Beginning C# Game Programming 的源代码」· CS 代码 · 共 24 行

CS
24
字号
using System;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.DirectDraw;

namespace SpaceWar {
	/// <summary>
	/// Drawing routine for the star background.
	/// </summary>
	public class Star {
		Point location;

		public Star(Rectangle screenBounds) {
			location = new Point(0);
			location.X = Constants.random.Next(screenBounds.Width) + screenBounds.X;
			location.Y = Constants.random.Next(screenBounds.Height) + screenBounds.Y;
		}

		public void Draw(Surface surface) {
			surface.DrawLine(location.X, location.Y, location.X + 1, location.Y + 1);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?