I'm trying to rotate my triangle around, but I'm not successful: someone / someone about it Can I give ideas for how to make? This is part of my code that is riding the ship (so far I can show the ship but I can not do it for rotation ..)
width = 500 ;; Height = 300 ;; Type ship = {a: point; B: point; C: point; center point; Angle: boat} ;; Type etat = {ast: asteroid list; Ship: ship} ;; Give cent_ship = {x = width / 2; Y = height / 2} ;; Let's do a_ship = {x = (center_ship.x) -5; Y = (center_ship.y) -5} ;; B_Ship = {x = (center_ship.x) +5; Y = (center_ship.y) -5} ;; Let's c_ship = {x = (center_ship.x); Y = (center_ship.y) +20} ;; Give Ship = {A = A_Ship; B = B_ship; C = c_ship; Center = center_ship; Angle = 45.} ;; Let's show_ship e = draw_poly [| ((E.ship.ax), (E.PA.)); (E.P.B.B.X.), (E.P.S.B.)); ((E.ship.cyx)), (e.ship.cy))] ;; Let s = sin (45.) ;; Let's c = cos (45.) ;; Let's turn = function p - & gt; {X = int_of_float (float_of_int (ship.center.x) +. Float_off_ant (px-ship.center.x) * .c - float_off_ant (PA-ship.nser.i) * s); Y = int_of_float (float_of_int (ship.center.y) +. Float_off_ant (px-ship.center.x) * s. Float_off_ant (pi ship.center.i) *. C)} ;; LEFT_HIP = Function ship to rotate - & gt; {One = floating ship (ship.a); B = rotate (ship.b); C = rotation (ship C)}; Let's rotate = function E - & gt; {Ship with E. = Rotate left_ship e.ship} ;;
You have not posted that part of your code, but I guess your Animation
But the state's structure is irreversible, so
seems to state that Ieration_n = I = 1 to repeat- show_ship (rotateLeft state ) It is done that your animation loop should actually be a recursive function: Give Chet state = function to REC. 0 - & gt; () | N - & gt; Show_ship state; Chetan (Rotate Late State) (N-1)
No comments:
Post a Comment