Commits

Anonymous committed 0f6fa47

no need to shuffle to get a random color

  • Participants
  • Parent commits e33b485

Comments (0)

Files changed (1)

File maze/sdlmaze.ml

 (* images *)
 
 let select_img_color () =
-  let swap a i j =
-    let t = a.(i) in
-    a.(i) <- a.(j);
-    a.(j) <- t
-  in
-  let shuffle a = Array.iteri (fun i _ -> swap a i (Random.int (i +1))) a in
   let colors = [|"blue";"green";"orange";"pink";"purple";"red";"yellow" |] in
-  shuffle colors;
-  colors.(0)
+  let index = Random.int (Array.length colors) in
+  colors.(index)
 
 let load_img_bullet color =
   Sdlloader.load_image ("data/images/bullet/bullet_" ^ color ^ ".png")
   Sdlloader.load_image ("data/images/flag/flag_" ^ color ^ ".png")
 
 let load_img_castle () =
-  Sdlloader.load_image ("data/images/castle2.png")
+  Sdlloader.load_image ("data/images/castle.png")
 
 let load_img_knight () =
   Sdlloader.load_image ("data/images/knight.png")