Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
let left = 0. let right = 300. let down = 0. let up = 500. let ball = 5 let draw_ball x y = Graphics.fill_circle (int_of_float x) (int_of_float y) ball let paddle = 50 let thick = 4 let draw_paddle x = Graphics.fill_rect x 0 paddle thick let position_paddle () = let x = fst(Graphics.mouse_pos ()) in max 0 (min x ((int_of_float right)-paddle)) let rec wait n = if n=0 then Graphics.synchronize () else wait (n-1) let new_position (x, y) (vx, vy) = x +. vx, y +. vy let bounce (x, y) (vx, vy) xr = let vx = if x <= left || x>= right then -. vx else vx in let vy = if y<= float thick && x>=(float xr) && x<=(float xr +. (float paddle)) || y>= up then -. vy else vy in (vx, vy) let rec jeu (x, y) (vx, vy) = Graphics.clear_graph (); draw_ball x y; if y <= down then failwith "perdu"; let xr = position_paddle () in draw_paddle xr; wait 1_000_000; let vx, vy = bounce (x, y) (vx, vy) xr in let x', y' = new_position (x, y) (vx, vy) in jeu (x', y') (vx, vy) let () = let s = Printf.sprintf " %dx%d" (int_of_float right) (int_of_float up) in Graphics.open_graph s; Graphics.auto_synchronize false; let vx = Random.float 1. in let vy = Random.float 1. in jeu (150., float thick) (vx, vy)