Advertisement
Mboy1985

Untitled

May 5th, 2023
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp14
  8. {
  9. internal class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. zagrajMelodie(1);
  14. zagrajMelodie(2);
  15.  
  16. }
  17. static void zagrajMelodie(int numer)
  18. {
  19. if (numer == 1)
  20. {
  21. //star wars
  22. int[] melodia = { 440, 440, 440, 349, 523, 440, 349, 523, 440,
  23. 0, 659, 659, 659, 698, 523, 415, 349, 523, 440, 0, 880, 880, 440, 440, 880,
  24. 831, 784, 698, 740, 0, 622, 659, 415, 440, 523, 0, 440, 523, 440, 0 };
  25. int[] czasTrwania = { 500, 500, 500, 350, 150, 500, 350, 150,
  26. 650, 500, 500, 500, 500, 350, 150, 500, 350, 150, 650, 500, 500, 500, 350,
  27. 150, 500, 350, 150, 650, 150, 500, 150, 500, 150, 1000, 500, 350, 150, 500,
  28. 350, 150, 650 };
  29.  
  30. for (int i = 0; i < melodia.Length; i++)
  31. {
  32. if (melodia[i] != 0)
  33.  
  34. {
  35. Console.Beep(melodia[i], czasTrwania[i]);
  36. }
  37. else
  38. {
  39. // pauza
  40. System.Threading.Thread.Sleep(czasTrwania[i]);
  41. }
  42. }
  43. }
  44. else if (numer == 2)
  45. { //Mario Bros
  46. int[] melodia = { 659, 659, 0, 659, 0, 523, 659, 0, 784, 0,
  47. 392, 0, 523, 0, 392, 0, 330, 0, 440, 494, 0, 466, 0, 440, 0, 392, 659, 0, 784,
  48. 780, 0, 784, 0, 659, 0, 523, 587, 0, 494, 0, 523, 0, 392, 0, 330, 0, 440, 494,
  49. 0, 466, 0, 440, 0 };
  50.  
  51. int[] czasTrwania = { 200, 200, 200, 200, 200, 200, 200, 200,
  52. 200, 200, 400, 200, 200, 200, 400, 200, 200, 200, 200, 200, 200, 200, 200,
  53. 200, 200, 400, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
  54. 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 };
  55.  
  56. for (int i = 0; i < melodia.Length; i++)
  57. {
  58. if (melodia[i] != 0)
  59. {
  60. Console.Beep(melodia[i], czasTrwania[i]);
  61. }
  62. else
  63. {
  64. // pauza
  65. System.Threading.Thread.Sleep(czasTrwania[i]);
  66. }
  67. }
  68. }
  69. }
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement