Exemplo n.º 1
0
func (p *Piece) render(screen *sdl.Surface) {
	if p == nil {
		return
	}
	for i := 0; i < 4; i++ {
		x := p.pos.x + p.tet.position[p.rot][i].x
		y := p.pos.y + p.tet.position[p.rot][i].y
		rect := sdl.Rect{
			int16(x * PixPerBrick),
			int16(y * PixPerBrick),
			uint16(PixPerBrick),
			uint16(PixPerBrick)}
		screen.FillRect(&rect, colorToUint32(colorTable[p.tet.color]))
	}
}
Exemplo n.º 2
0
func (p *Playfield) render(screen *sdl.Surface) {
	screen.FillRect(nil, 0x000000)
	for j := 0; j < p.height; j++ {
		for i := 0; i < p.width; i++ {
			color := p.at(i, j)
			if color != 0 {
				rect := sdl.Rect{
					int16(i * PixPerBrick),
					int16(j * PixPerBrick),
					uint16(PixPerBrick),
					uint16(PixPerBrick)}
				screen.FillRect(&rect, colorToUint32(colorTable[color]))
			}
		}
	}
}