|
@@ -17,12 +17,16 @@ type StarInfo struct {
|
|
|
Color bool
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+StarField holds the information needed to render a starfield.
|
|
|
+*/
|
|
|
type StarField struct {
|
|
|
MX int
|
|
|
MY int
|
|
|
Sky map[StarPos]StarInfo
|
|
|
}
|
|
|
|
|
|
+// Make a new StarPos in the StarField Sky.
|
|
|
func (s *StarField) make_pos(RNG *rand.Rand) StarPos {
|
|
|
for {
|
|
|
pos := StarPos{X: RNG.Intn(s.MX), Y: RNG.Intn(s.MY)}
|
|
@@ -33,6 +37,9 @@ func (s *StarField) make_pos(RNG *rand.Rand) StarPos {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// Regenerate a StarField structure.
|
|
|
+// This uses make_pos to find a new unused position.
|
|
|
+// This needs a seeded rand.Rand.
|
|
|
func (s *StarField) Regenerate(RNG *rand.Rand) {
|
|
|
s.MX = door.Width
|
|
|
s.MY = door.Height
|
|
@@ -47,6 +54,9 @@ func (s *StarField) Regenerate(RNG *rand.Rand) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// Display StarField.
|
|
|
+// This optimizes the output. Uses CURSOR LEFT/RIGHT
|
|
|
+// \x1b[C or \x1b[D to optimize output.
|
|
|
func (s *StarField) Display(d *door.Door) {
|
|
|
white := door.ColorText("WHITE")
|
|
|
dark := door.ColorText("BOLD BLACK")
|