-
Notifications
You must be signed in to change notification settings - Fork 5
/
Model.fs
72 lines (64 loc) · 1.72 KB
/
Model.fs
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
71
72
module Model
open Constants
type Tile = Tile of x:int * y:int * kind:TileKind * adjacency:byte
and TileKind = Room | Door | Corridor | Block | StairsUp | StairsDown of int
type Entity = {
kind: EntityKind
state: EntityState
facing: Facing
position: int * int
health: int
events: EntityEvent list
timeBetweenTiles: float
size: int * int
origin: int * int
}
and EntityKind = Rogue | Minotaur | Skeleton
and EntityState =
| Standing of startTime:float
| Gesturing of startTime:float
| Walking of startTime:float * path:(int * int) list
| Striking of startTime:float * target:Entity * hasHit:bool
| Hit of startTime:float
| Dying of startTime:float
| Dead
and Facing = Left | Right
and EntityEvent = Struck of Entity
type GameModel =
| Playing of map:(Tile list) * player:Entity * monsters:(Entity list)
let newRogue position =
{
kind = Rogue
state = Standing 0.
facing = Left
position = position
health = 10
events = []
timeBetweenTiles = 250.
size = playerwidth, playerheight
origin = position
}
let newMinotaur position =
{
kind = Minotaur
state = Standing 0.
facing = Left
position = position
timeBetweenTiles = 350.
health = 5
events = []
size = playerwidth * 3/2, playerheight * 3/2
origin = position
}
let newSkeleton position =
{
kind = Skeleton
state = Standing 0.
facing = Left
position = position
timeBetweenTiles = 350.
health = 2
events = []
size = playerwidth, playerheight
origin = position
}