Пример #1
0
func drawPiece(s *sdl.Surface, col, row int, p c4.Piece) {
	// Load images
	if redImage == nil {
		redImage = sdl.Load("red.png")
	}
	if blackImage == nil {
		blackImage = sdl.Load("black.png")
	}
	if noneImage == nil {
		noneImage = sdl.Load("empty.png")
	}

	// Select image
	var image *sdl.Surface
	if p == c4.Red {
		image = redImage
	} else if p == c4.Black {
		image = blackImage
	} else {
		image = noneImage
	}

	// Draw image
	s.Blit(
		&sdl.Rect{
			int16(SCREEN_WIDTH * col / c4.MaxColumns),
			int16(SCREEN_HEIGHT * (c4.MaxRows - row - 1) / c4.MaxRows),
			0,
			0},
		image,
		nil)
}
Пример #2
0
func apply_surface(x, y int16, src, dest *sdl.Surface) {
	var offset sdl.Rect

	offset.X = x
	offset.Y = y

	dest.Blit(&offset, src, nil)
}
Пример #3
0
func draw_sdl(o *Object, s *sdl.Surface) {
	var ss *sdl.Surface
	if o.Collides {
		ss = surfaceb
	} else {
		ss = surface
	}

	s.Blit(
		&sdl.Rect{int16(float64(o.Pos.X) * ssw),
			int16(float64(o.Pos.Y) * ssh),
			uint16(float64((o.Pos.X + o.Size.X)) * ssw),
			uint16(float64((o.Pos.Y + o.Size.Y)) * ssh)},
		ss,
		&sdl.Rect{0, 0, uint16(o.Size.X), uint16(o.Size.Y)})
}