generated from ElnuDev/ocaml-project
parent
e77e6c0174
commit
c492499402
5 changed files with 38 additions and 3 deletions
2
bin/dune
2
bin/dune
|
@ -1,4 +1,4 @@
|
|||
(executable
|
||||
(public_name ocaml_pong)
|
||||
(name main)
|
||||
(libraries ocaml_pong))
|
||||
(libraries ocaml_pong tsdl))
|
||||
|
|
32
bin/main.ml
32
bin/main.ml
|
@ -1 +1,31 @@
|
|||
let () = print_endline "Hello, World!"
|
||||
open Tsdl
|
||||
|
||||
let run () =
|
||||
let (let*) = Result.bind in
|
||||
let* _ = Sdl.init Sdl.Init.everything in
|
||||
let* w = Sdl.create_window "Hello World!"
|
||||
~x:Sdl.Window.pos_centered
|
||||
~y:Sdl.Window.pos_centered
|
||||
~w:620
|
||||
~h:387
|
||||
Sdl.Window.shown in
|
||||
let* r = Sdl.create_renderer w
|
||||
~index:(-1)
|
||||
~flags:Sdl.Renderer.software in
|
||||
for _ = 0 to 20 do
|
||||
ignore @@ Sdl.render_clear r;
|
||||
Sdl.render_present r;
|
||||
Sdl.delay (Int32.of_int 100);
|
||||
done;
|
||||
|
||||
Sdl.destroy_renderer r;
|
||||
Sdl.destroy_window w;
|
||||
Sdl.quit ();
|
||||
Ok ()
|
||||
|
||||
let () =
|
||||
match run () with
|
||||
| Ok _ -> exit 0
|
||||
| Error (`Msg e) ->
|
||||
Sdl.log "Error: %s" e;
|
||||
exit 1
|
|
@ -17,7 +17,10 @@
|
|||
(name ocaml_pong)
|
||||
(synopsis "An OCaml pong clone")
|
||||
(description "An pong clone written in OCaml, using the TSDL SDL bindings")
|
||||
(depends ocaml)
|
||||
(depends
|
||||
ocaml
|
||||
tsdl
|
||||
)
|
||||
(tags
|
||||
("game")))
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
pname = "ocaml_pong";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
buildInputs = [ tsdl ];
|
||||
inherit meta;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ tags: ["game"]
|
|||
depends: [
|
||||
"dune" {>= "3.18"}
|
||||
"ocaml"
|
||||
"tsdl"
|
||||
"odoc" {with-doc}
|
||||
]
|
||||
build: [
|
||||
|
|
Loading…
Add table
Reference in a new issue