Exemple #1
0
func (t *Tetromino) Show() int {
	for {
		render.Clear()
		render.PrintObject(t)
		render.Render()
		select {
		case ev := <-render.EventQueue:
			switch {
			case ev.Key == render.Enter:
				return 0
			case ev.Key == render.Esc:
				return 0
			case ev.Key == render.Left:
				t.PosX--
			case ev.Key == render.Right:
				t.PosX++
			case ev.Key == render.Down:
				if t.Orientation == 3 {
					t.Orientation = -1
				}
				t.Orientation++
			case ev.Key == render.Up:
				if t.Type == 6 {
					t.Type = -1
				}
				t.Type++
			}
		default:
			render.Render()
			//			t.PosY++
			time.Sleep(200 * time.Millisecond)
		}

	}
}
Exemple #2
0
func (p *Playfield) Show() int {
	for {
		render.Clear()
		render.PrintObject(p)
		render.Render()
		select {
		case ev := <-render.EventQueue:
			switch {
			case ev.Key == render.Enter:
				return 0
			case ev.Key == render.Esc:
				return 0
			case ev.Key == render.Down:
				return 0
			case ev.Key == render.Up:
				return 0
			}
		default:
			render.Render()
			time.Sleep(100 * time.Millisecond)
		}
	}
}