-
Notifications
You must be signed in to change notification settings - Fork 0
/
Defs.fs
135 lines (113 loc) · 3.81 KB
/
Defs.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
namespace Coral
open SFML.System
open SFML.Graphics
open SFML.Window
// ------------------------------------------------------
// Shared types and definitions go here
// ------------------------------------------------------
type Config =
{ Width: uint32
Height: uint32
Title: string }
// type EnText = {
// Obj: SFML.Graphics.Text
// IsVisible : bool
// IsActive : bool
// }
// type EnCircle = {
// Obj: SFML.Graphics.CircleShape
// IsVisible : bool
// IsActive : bool
// }
// type IText(str: string, fnt:Font, isVisible:bool, isActive:bool) =
// inherit SFML.Graphics.Text(str, fnt)
// member this.IsVisibale:bool = isVisible
// member this.IsActive: bool = isActive
// type ICircle(r: float32, isvisible:bool, isactive:bool) =
// inherit SFML.Graphics.CircleShape(r)
// member this.IsVisible = isvisible
// member this.IsActive = isactive
type Entity =
| EnCircle of SFML.Graphics.CircleShape
| EnText of SFML.Graphics.Text
type UserCommands =
| MoveUp
| MoveRight
| MoveDown
| MoveLeft
| CloseGame
| ToggleDebugHUD
type AvailableScenes =
| MainMenuScn
| GameScn
type State = {
BallPosition: Vector2f
CurrentScene: AvailableScenes
DeltaTime: int
TickCount: int
ShowDebugHUD: bool
CurrentTickLoadsNewEntities: bool
CurrentTickUpdatesDrawables: bool
CurrentTickSetsupScene: bool
UserCommandsList : Set<UserCommands>
KeysPressed: Set<Keyboard.Key>
Entities: Map<string, Entity>
}
type HandledKeys =
| Up
| Right
| Down
| Left
// type BtnState =
// | Default of Color
// | Hover of Color
// | Click of Color
// | EnSprite of texture: Love.Texture * x: float32 * y: float32
// | EnBtn of width: float32 * height : float32 * btnState : BtnState * x: float32 * y: float32
// type DrawableEntities = {
// mutable BgLayer : Dictionary<string, Entity>
// mutable ObjLayer : Dictionary<string, Entity>
// mutable UiLayer : Dictionary<string, Entity>
// mutable DbgLayer : Dictionary<string, Entity>
// }
// type Resources = {
// Scene : AvailableScenes
// Speed : float32
// Img : Image
// }
// module Data =
// // ------------------------------------------------------
// // Constants and statis resources are declared here
// // ------------------------------------------------------
// let Res = {
// Scene = GameScn
// Speed = 300.0f
// Img = Graphics.NewImage "assets/red_ball.png"
// }
// // ------------------------------------------------------
// // Mutable game state goes in here
// // ------------------------------------------------------
// let ResetModel(): Model = {
// CurrentScene = MainMenuScn
// Counter = 0
// FPS = 0.0f
// TimeDelta = 0.0f
// BallPos = Vector2(300.0f, 300.0f)
// MainMenuStartBtnState = Default (Color.AliceBlue)
// MainMenuSettingsBtnState = Default (Color.AliceBlue)
// MainMenuExitBtnState = Default (Color.AliceBlue)
// }
// let mutable State = ResetModel()
// // ------------------------------------------------------
// // Mutable display list goes in here
// // ------------------------------------------------------
// let ResetDisplayList() = {
// BgLayer = Dictionary<string, Entity>()
// ObjLayer = Dictionary<string, Entity>()
// UiLayer = Dictionary<string, Entity>()
// DbgLayer = Dictionary<string, Entity>()
// }
// let mutable DisplayList = ResetDisplayList()
// // indexes for faster lookup of interactive elements
// let entityClickable = seq<string>
// let entityHoverable = seq<string>