Joystick position: Difference between revisions

Content added Content deleted
(added ocaml)
(→‎{{header|OCaml}}: handle window resized correctly)
Line 120: Line 120:


let position app x y =
let position app x y =
let width, height = SFRenderWindow.getSize app in
let view = SFRenderWindow.getView app in
let hw = float width /. 2.0 in
let width, height = SFView.getSize view in
let hh = float height /. 2.0 in
let hw = width /. 2.0 in
let hh = height /. 2.0 in
(hw +. ((x /. 100.0) *. hw),
(hw +. ((x /. 100.0) *. hw),
hh +. ((y /. 100.0) *. hh))
hh +. ((y /. 100.0) *. hh))