-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisual.go
68 lines (59 loc) · 971 Bytes
/
visual.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import "fmt"
var visdelta = []xy{
{-1, -1},
{-1, 0},
{-1, 1},
{0, 1},
{1, 1},
{1, 0},
{1, -1},
{0, -1},
{-1, -1},
{-1, 0},
{-1, 1},
}
func visual(z int) {
var (
ix, iy int
co int
c byte
v *xy
)
co = getintpar("direction")
if co < 0 || co > 360 {
return
}
co = (co + 22) / 45
v = &visdelta[co]
ix = ship.sectx + v.x
iy = ship.secty + v.y
if ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS {
c = '?'
} else {
c = sect[ix][iy]
}
fmt.Printf("%d,%d %c ", ix, iy, c)
co++
v = &visdelta[co]
ix = ship.sectx + v.x
iy = ship.secty + v.y
if ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS {
c = '?'
} else {
c = sect[ix][iy]
}
fmt.Printf("%c ", c)
co++
v = &visdelta[co]
ix = ship.sectx + v.x
iy = ship.secty + v.y
if ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS {
c = '?'
} else {
c = sect[ix][iy]
}
fmt.Printf("%c %d,%d\n", co, ix, iy)
move.time = 0.05
move.free = false
}