mirror of
https://github.com/golang/go
synced 2024-11-22 02:14:40 -07:00
exp/spacewar: fix build.
R=rsc CC=golang-dev https://golang.org/cl/2265042
This commit is contained in:
parent
44b3b20524
commit
d181625b9c
@ -47,10 +47,11 @@ func main() {
|
|||||||
log.Exitf("av.Init: %s", err)
|
log.Exitf("av.Init: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
go quitter(w.QuitChan())
|
kc := make(chan int)
|
||||||
|
go demuxEvents(w, kc)
|
||||||
|
|
||||||
var m SpacewarPDP1
|
var m SpacewarPDP1
|
||||||
m.Init(w)
|
m.Init(w, kc)
|
||||||
m.PC = 4
|
m.PC = 4
|
||||||
f := bytes.NewBuffer([]byte(spacewarCode))
|
f := bytes.NewBuffer([]byte(spacewarCode))
|
||||||
if err = m.Load(f); err != nil {
|
if err = m.Load(f); err != nil {
|
||||||
@ -65,8 +66,13 @@ func main() {
|
|||||||
log.Exitf("step: %s", err)
|
log.Exitf("step: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func quitter(c <-chan bool) {
|
func demuxEvents(w draw.Window, kc chan int) {
|
||||||
<-c
|
for event := range w.EventChan() {
|
||||||
|
switch e := event.(type) {
|
||||||
|
case draw.KeyEvent:
|
||||||
|
kc <- e.Key
|
||||||
|
}
|
||||||
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +84,7 @@ type SpacewarPDP1 struct {
|
|||||||
pdp1.M
|
pdp1.M
|
||||||
nframe int
|
nframe int
|
||||||
frameTime int64
|
frameTime int64
|
||||||
ctxt draw.Context
|
ctxt draw.Window
|
||||||
dx, dy int
|
dx, dy int
|
||||||
screen draw.Image
|
screen draw.Image
|
||||||
ctl pdp1.Word
|
ctl pdp1.Word
|
||||||
@ -95,9 +101,9 @@ func min(a, b int) int {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SpacewarPDP1) Init(ctxt draw.Context) {
|
func (m *SpacewarPDP1) Init(ctxt draw.Window, kc chan int) {
|
||||||
m.ctxt = ctxt
|
m.ctxt = ctxt
|
||||||
m.kc = ctxt.KeyboardChan()
|
m.kc = kc
|
||||||
m.screen = ctxt.Screen()
|
m.screen = ctxt.Screen()
|
||||||
m.dx = m.screen.Bounds().Dx()
|
m.dx = m.screen.Bounds().Dx()
|
||||||
m.dy = m.screen.Bounds().Dy()
|
m.dy = m.screen.Bounds().Dy()
|
||||||
|
Loading…
Reference in New Issue
Block a user