diff --git a/1sec.wav b/1sec.wav deleted file mode 100644 index 2f3bfdb..0000000 Binary files a/1sec.wav and /dev/null differ diff --git a/main.cmi b/main.cmi index 764570c..9db80ab 100644 Binary files a/main.cmi and b/main.cmi differ diff --git a/main.cmx b/main.cmx index 42b02b3..c3e5123 100644 Binary files a/main.cmx and b/main.cmx differ diff --git a/main.ml b/main.ml index 67c853d..6ff4702 100644 --- a/main.ml +++ b/main.ml @@ -75,7 +75,7 @@ let default_sphere = { score = 0 ; } ;; -let univ_g = 800.0 ;; +let univ_g = 750.0 ;; let pi = 3.14159265358979343 ;; let winBL = { @@ -110,7 +110,7 @@ let playbeep id = while true do if beep_boop.(id) then begin beep_boop.(id) <- false ; - ignore (Unix.system "./sound 1sec.wav") ; + ignore (Unix.system "./sound wah/scored_hit.wav") ; end; Unix.sleepf 0.005 ; done;; @@ -121,7 +121,9 @@ let beep_list = Array.init n_threads (fun k -> Thread.create playbeep k) ;; let play_music () = while true do - ignore (Unix.system "./sound 1sec.wav") ; + ignore (Unix.system "./sound wah/wah_metal.wav") ; + ignore (Unix.system "./sound wah/wah_eurobeat.wav") ; + ignore (Unix.system "./sound wah/wah_hardcore.wav") ; done;; let theme_thr = Thread.create play_music () ;; @@ -339,6 +341,10 @@ let is_collision_p (b : ball) (poly : polygon) (dt : float) = | ReturnInt b -> b end ;; +let playbeep () = + beep_boop.(!beep_id) <- true ; + beep_id := (!beep_id+1) mod n_threads ;; + let is_collision_s (b : ball) (s : sphere) (dt : float) = if not (is_in_bounding_box_s b s) then false @@ -354,6 +360,9 @@ let update_ball_data (b : ball) (polys : polygon array) (spheres : sphere array) if hit <> -1 then begin score := !score + polys.(p).score ; + if polys.(p).score > 0 then + playbeep () ; + (* apply normal reaction force *) let hit2 = (hit +1) mod (Array.length polys.(p).vertexes) in let proj = return_proj_of_point b.xy polys.(p).vertexes.(hit) polys.(p).vertexes.(hit2) in @@ -376,8 +385,8 @@ let update_ball_data (b : ball) (polys : polygon array) (spheres : sphere array) if is_collision_s b spheres.(s) dt then begin score := !score + spheres.(s).score ; - beep_boop.(!beep_id) <- true ; - beep_id := (!beep_id+1) mod n_threads ; + if spheres.(s).score > 0 then + playbeep () ; (* apply normal reaction force *) let proj_n = vect_normalize_2D (vect_diff_2D b.xy spheres.(s).center) in @@ -645,10 +654,6 @@ let simulate (data : polygon dynamic) (dats : sphere dynamic) = auto_synchronize false ; clear_graph () ; - set_color black ; - set_line_width 4 ; - draw_integer 600 770 !score 50 ; - set_line_width 1 ; for d = 0 to data.len -1 do draw_polygon data.tab.(d) @@ -661,6 +666,10 @@ let simulate (data : polygon dynamic) (dats : sphere dynamic) = set_color (rgb 128 128 32) ; draw_float 25 770 (round (!ctime -. stime) 3) 25 ; + set_color black ; + set_line_width 4 ; + draw_integer 600 770 !score 50 ; + auto_synchronize true ; Unix.sleepf 0.005 ; @@ -678,6 +687,7 @@ dyn_add polygons (create_polygon [|(1150, 0); (1200, 0); (1200, 775); (1150, 775 dyn_add polygons (create_polygon [|(50, 0); (50, 200); (500, 25); (500, 0)|] 1.0 0 32 32 255) ;; dyn_add polygons (create_polygon [|(1150, 0); (1150, 200); (700, 25); (700, 0)|] 1.0 0 32 32 255) ;; dyn_add polygons (create_polygon [|(500, 0); (700, 0); (700, 25); (500, 25)|] 1.0 (-10) 192 64 64) ;; +dyn_add polygons (create_polygon [|(0, 750); (1200, 750); (1200, 800); (0, 800)|] 1.0 25 64 192 64) ;; let spheres = dyn_create default_sphere ;; dyn_add spheres (create_sphere 200 400 20. 1. 5 220 32 220) ;; diff --git a/main.o b/main.o index 8ae798e..5ea016e 100644 Binary files a/main.o and b/main.o differ diff --git a/pinball b/pinball index c7df3b0..86d07d2 100755 Binary files a/pinball and b/pinball differ diff --git a/playsound.c b/playsound.c index d9701a0..025d52a 100644 --- a/playsound.c +++ b/playsound.c @@ -14,7 +14,7 @@ int main(int argc, char** argv) { SDL_AudioDeviceID deviceId = SDL_OpenAudioDevice(NULL, 0, &wavSpec, NULL, 0); int success = SDL_QueueAudio(deviceId, wavBuffer, wavLength); SDL_PauseAudioDevice(deviceId, 0); - usleep((int)((wavLength)/88200.0*100000.0)) ; + usleep((int)((wavLength)/88200.0*100000.0)); SDL_CloseAudioDevice(deviceId); SDL_FreeWAV(wavBuffer); SDL_Quit(); diff --git a/wah/scored_hit.wav b/wah/scored_hit.wav new file mode 100644 index 0000000..97a263b Binary files /dev/null and b/wah/scored_hit.wav differ diff --git a/wah/wah_eurobeat.wav b/wah/wah_eurobeat.wav new file mode 100644 index 0000000..f5a7a3d Binary files /dev/null and b/wah/wah_eurobeat.wav differ diff --git a/wah/wah_hardcore.wav b/wah/wah_hardcore.wav new file mode 100644 index 0000000..4fe0a8b Binary files /dev/null and b/wah/wah_hardcore.wav differ diff --git a/wah/wah_metal.wav b/wah/wah_metal.wav new file mode 100644 index 0000000..aae5253 Binary files /dev/null and b/wah/wah_metal.wav differ