📄 stars.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 + -