-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.go
70 lines (58 loc) · 1.17 KB
/
objects.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package hanabi
import (
"math"
)
type BaseObject struct {
Id int
X, Y int
Height, Width int
centerX, centerY, radius int
}
func (o *BaseObject) getId() int {
return o.Id
}
func (o *BaseObject) getWidth() int {
return o.Width
}
func (o *BaseObject) getHeight() int {
return o.Height
}
func (o *BaseObject) getX() int {
return o.X
}
func (o *BaseObject) getY() int {
return o.Y
}
func clamp(x, min, max int) int {
if x < min {
return min
}
if x > max {
return max
}
return x
}
func (o *BaseObject) tick(passedSeconds float64) {
o.X = o.centerX + int(float64(o.radius)*math.Cos(math.Pi*2*float64(passedSeconds)/2))
o.Y = o.centerY + int(float64(o.radius)*math.Sin(math.Pi*2*float64(passedSeconds)/2))
}
type CardColor int
const ColorCount = 5
const NumberMax = 5
const NumberMin = 1
type Card struct {
Id int
Color CardColor // Color == 0 means unknown color (to client)
Number int // Number == 0 means unknown number
ColorHinted bool
NumberHinted bool
}
func newCard(id int, color CardColor, number int) *Card {
return &Card{
id,
color,
number,
false,
false,
}
}