|
@@ -67,20 +67,33 @@ func (s *StarField) Display(d *door.Door) {
|
|
|
var i int = 0
|
|
|
var last_pos StarPos
|
|
|
|
|
|
+ // maps in go are not sorted
|
|
|
for pos, _ := range s.Sky {
|
|
|
use_goto := true
|
|
|
|
|
|
if i != 0 {
|
|
|
if pos.Y == last_pos.Y {
|
|
|
dx := pos.X - last_pos.X
|
|
|
- if dx <= 0 {
|
|
|
+ // Sometimes pos.X < last_pos.X
|
|
|
+ if dx == 0 {
|
|
|
use_goto = false
|
|
|
} else {
|
|
|
- if dx < 5 {
|
|
|
- d.Write(strings.Repeat(" ", dx))
|
|
|
+ if dx < 0 {
|
|
|
+ // handle negative
|
|
|
+ // fmt.Printf("from %#v to %#v\n", last_pos, pos)
|
|
|
+ dx = -dx
|
|
|
+ if dx < 5 {
|
|
|
+ d.Write(strings.Repeat("\x08", dx))
|
|
|
+ } else {
|
|
|
+ d.Write(fmt.Sprintf("\x1b[%dD", dx))
|
|
|
+ }
|
|
|
use_goto = false
|
|
|
} else {
|
|
|
- d.Write(fmt.Sprintf("\x1b[%dC", dx))
|
|
|
+ if dx < 5 {
|
|
|
+ d.Write(strings.Repeat(" ", dx))
|
|
|
+ } else {
|
|
|
+ d.Write(fmt.Sprintf("\x1b[%dC", dx))
|
|
|
+ }
|
|
|
use_goto = false
|
|
|
}
|
|
|
}
|