예제 #1
0
func highlightCorner(game *game.Game, window draw.Window) {
	mx, my := window.MousePosition()
	w, h := window.Size()
	var position point
	const radius = 40
	const squareRadius = radius * radius

	yOffset := 0
	for y := 0; y < h; y += tileH - tileSlopeHeight {
		for x := 0; x < w; x += tileW / 2 {
			if squareDist(x, y+yOffset, mx, my) < squareRadius {
				position = point{x, y + yOffset}
			}
			yOffset = tileSlopeHeight - yOffset
		}
		yOffset = tileSlopeHeight - yOffset
	}

	if position.x != 0 || position.y != 0 {
		window.FillEllipse(
			position.x-radius, position.y-radius,
			2*radius, 2*radius,
			draw.RGBA(1, 0, 0.5, 0.75))
	}
}
예제 #2
0
func highlightEdge(game *game.Game, window draw.Window) {
	mx, my := window.MousePosition()
	for _, tile := range game.GetTiles() {
		hex := hexagonAtTile(tile.Position.X, tile.Position.Y)

		r := rect{hex[1].x - tileSlopeHeight/2, hex[1].y, tileSlopeHeight, hex[2].y - hex[1].y}
		if r.contains(mx, my) {
			window.FillRect(r.x, r.y, r.w, r.h, draw.RGBA(1.0, 0, 0.5, 0.75))
			return
		}

		r = rect{hex[3].x, hex[2].y, hex[2].x - hex[3].x, hex[3].y - hex[2].y}
		if r.contains(mx, my) {
			window.FillRect(r.x, r.y, r.w, r.h, draw.RGBA(1.0, 0, 0.5, 0.75))
			return
		}

		r = rect{hex[4].x, hex[4].y, hex[3].x - hex[4].x, hex[3].y - hex[4].y}
		if r.contains(mx, my) {
			window.FillRect(r.x, r.y, r.w, r.h, draw.RGBA(1.0, 0, 0.5, 0.75))
			return
		}
	}
}