Browse Source

Added documentation to starfield.

Steve Thielemann 3 years ago
parent
commit
5e1ad7aa9d
1 changed files with 10 additions and 0 deletions
  1. 10 0
      starfield.go

+ 10 - 0
starfield.go

@@ -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")