⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stars.cs

📁 Beginning C# Game Programming 的源代码
💻 CS
字号:
using System;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.DirectDraw;

namespace SpaceWar {
	/// <summary>
	/// Draw the starry background of the game screen
	/// </summary>
	public class Stars {
		Star[] stars;

		public Stars(Rectangle screenBounds, int count) {
			stars = new Star[count];

			for (int i = 0; i < count; i++) {
				stars[i] = new Star(screenBounds);
			}
		}

		public void Draw(Surface surface) {
			surface.ForeColor = Color.FromArgb(Constants.StarColorFull);
			foreach (Star star in stars) {
				star.Draw(surface);
			}
			int index = Constants.random.Next(stars.Length);
			surface.ForeColor = Color.FromArgb(Constants.StarColorDim);
			stars[index].Draw(surface);
		}
	}
}

⌨️ 快捷键说明

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