-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ml
59 lines (51 loc) · 1.86 KB
/
main.ml
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
open Entity
open Player
open Room
open Gamestate
open Animations
open Combat
open Item
open Enemy
let main () =
print_string "JSON File to Load in Saves Folder (If unsure, leave blank):";
let load_file = read_line () in
let window = Window.create_window "3110 Project"
(GameVars.width * (int_of_float GameVars.tile_size))
(GameVars.height * (int_of_float GameVars.tile_size)) in
(* let default_enemy = make_enemy "link" 3 window in *)
(* let default_room = {(Load.load load_file window) with items =[default_item; default_item2]; enemies = [default_enemy;]} in *)
let rm_ref : Room.t option ref = ref None in
Random.self_init ();
Thread.create (fun seed -> rm_ref :=
Some (try Load.load load_file window
with e -> Room_gen.simple_gen
(Random.int 20010827)
window)) () |> ignore;
let frame = ref 0 in
let loading = Animations.load_animation
"./sprites/loading/" "loading"
(Window.get_renderer window) in
let time = Window.get_time () |> ref in
while (!rm_ref = None) do
Window.clear window;
Window.draw_image window (Animations.frame loading !frame)
(GameVars.hrad -. 2.) (GameVars.vrad -. 2.);
Window.render window;
if Window.get_time () - !time > GameVars.anim_spf_in_milli then begin
time := Window.get_time ();
frame := (!frame + 1) mod (snd loading |> Array.length) end;
done;
let () = Window.clear window in
let () = Window.render window in
let time = Window.get_time () in
Gamestate.game_loop
{running = true;
current_room = Option.get !rm_ref;
window = window;
input = [];
icons = Animations.load_icons (Window.get_renderer window);
last_anim_frame = time
} time;
Window.wait 5;
Window.exit_window window
let () = main ()