-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtile.go
More file actions
35 lines (31 loc) · 893 Bytes
/
Copy pathtile.go
File metadata and controls
35 lines (31 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import rl "github.com/gen2brain/raylib-go/raylib"
type Tile struct {
Board uint32 `json:"board"`
Coord Vec2 `json:"coord"`
}
func (t *Tile) Render(style BoardStyle) {
var color = ColorAt(t.Coord, style)
var pos = GetBoardOrigo().Add(t.Coord.Scale(TileSize))
rl.DrawRectangle(int32(pos.X), int32(pos.Y), TileSize, TileSize, color)
}
func ColorAt(coord Vec2, style BoardStyle) rl.Color {
var light = coord.X%2 == coord.Y%2
var color = rl.NewColor(227, 193, 111, 255)
if style == BoardStyleEarth && !light {
color = rl.NewColor(184, 139, 74, 255)
} else if style == BoardStyleHeaven {
if light {
color = rl.NewColor(255, 239, 178, 255)
} else {
color = rl.NewColor(234, 210, 28, 255)
}
} else if style == BoardStyleHell {
if light {
color = rl.NewColor(255, 127, 107, 255)
} else {
color = rl.NewColor(193, 96, 77, 255)
}
}
return color
}