-
Notifications
You must be signed in to change notification settings - Fork 0
/
components.go
59 lines (46 loc) · 891 Bytes
/
components.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
package main
import (
"math"
"github.com/hajimehoshi/ebiten/v2"
)
type Player struct{}
type Monster struct{}
type Name struct {
Label string
}
type Position struct {
X int
Y int
}
type Health struct {
MaxHealth int
CurrentHealth int
}
type UserMessage struct {
AttackMessage string
DeadMessage string
GameStateMessage string
}
type MeleeWeapon struct {
Name string
MinimumDamage int
MaximumDamage int
ToHitBonus int
}
type Armor struct {
Name string
Defense int
ArmorClass int
}
type Renderable struct {
Image *ebiten.Image
}
type Movable struct{}
func (p *Position) GetManhattanDistance(other *Position) int {
xDist := math.Abs(float64(p.X - other.X))
yDist := math.Abs(float64(p.Y - other.Y))
return int(xDist) + int(yDist)
}
func (p *Position) IsEqual(other *Position) bool {
return (p.X == other.X && p.Y == other.Y)
}