Esempio n. 1
0
func main() {
	fmt.Print("hello from devdraw\n")

	// Make the window.
	d, err := draw.Init(nil, "", "experiment1", "")
	if err != nil {
		log.Fatal(err)
	}

	// make some colors
	back, _ := d.AllocImage(image.Rect(0, 0, 1, 1), d.ScreenImage.Pix, true, 0xDADBDAff)

	fmt.Printf("background colour: %v\n ", back)

	// get mouse positions
	mousectl := d.InitMouse()
	redraw(d, false)

	for {
		select {
		case <-mousectl.Resize:
			redraw(d, true)
		case m := <-mousectl.C:
			fmt.Printf("mouse field %v buttons %d\n", m, m.Buttons)
			// TODO(rjkroege): insert code here to do some drawing and stuff.
			d.ScreenImage.Draw(image.Rect(m.X, m.Y, m.X+10, m.Y+10), back, nil, image.ZP)
			d.Flush(true)
		}
	}

	fmt.Print("bye\n")
}
Esempio n. 2
0
func main() {
	args := os.Args
	p := pieces4
	name := "4s"
	if len(args) > 1 && args[1] == "-5" {
		p = pieces5
		name = "5s"
	}

	d, err := draw.Init(nil, "", name, "")
	if err != nil {
		log.Fatal(err)
	}

	Play(p, d)
}
Esempio n. 3
0
func main() {
	d, err := draw.Init(nil, "", "spacewar", "512x512")
	if err != nil {
		log.Fatal(err)
	}

	var m SpacewarPDP1
	m.Init(d)
	m.PC = 4
	f := bytes.NewBuffer([]byte(spacewarCode))
	if err = m.Load(f); err != nil {
		log.Fatalf("loading %s: %s", "spacewar.lst", err)
	}
	for err == nil {
		//fmt.Printf("step PC=%06o ", m.PC);
		//fmt.Printf("inst=%06o AC=%06o IO=%06o OV=%o\n",
		//	m.Mem[m.PC], m.AC, m.IO, m.OV);
		err = m.Step()
	}
	log.Fatalf("step: %s", err)
}