Advertisement
Guest User

Processing code

a guest
May 10th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.99 KB | None | 0 0
  1. //Allow the arduino to be used in processing
  2. import processing.serial.*;
  3.  
  4. Serial myPort; // Create the serial object that is the arduino
  5.  
  6. //Stores the state of which buttons have been pressed
  7. int state[] = {0,0,0,0,0,0,0,0,0,0};
  8. //Stores what song is currently being played and sends it to the arduino
  9. int songState;
  10.  
  11. //Stores if the button has been pressed or not
  12. int button1 = 0;
  13. int button2 = 0;
  14. int button3 = 0;
  15. int button4 = 0;
  16. int button5 = 0;
  17. int button6 = 0;
  18. int button7 = 0;
  19. int button8 = 0;
  20. int button9 = 0;
  21. int button10 = 0;
  22.  
  23. //Stores the movement y value of the notes
  24. float y = 0;
  25. //Stores the speed of the notes
  26. float speed = 2;
  27. //Stores the current score
  28. int score = 0;
  29. //Stores the high scores
  30. int[] scores = new int[6];
  31. //Stores the high scores in a string array so that they can be saved and loaded from a file
  32. String scoreData[] = new String[6];
  33.  
  34. //Stores the score text used in game
  35. String scoreText = "Score: ";
  36. //Stores the text width
  37. float tw;
  38. //Stores a tempory variable that will convert the score int to string to be displayed
  39. String temp;
  40.  
  41. //Stores the Y position of the menu icon
  42. int menuIcon = 0;
  43. //Stores the current state of the menu
  44. int menuState = 1;
  45.  
  46. //Stores the colours for the notes
  47. color color1 = color(0,255,0);
  48. color color2 = color(255,0,0);
  49. color color3 = color(255,255,0);
  50. color color4 = color(0,0,255);
  51. color color5 = color(255,108,0);
  52. color color6 = color (210,0,255);
  53. color color7 = color(0,255,255);
  54. color color8 = color(0);
  55. color color9 = color(210,117,178);
  56. color color10 = color(48,150,75);
  57.  
  58. //Stores what state the game is currently in
  59. boolean startScreen = true;
  60. boolean gamePlaying = false;
  61. //If the game is playing stop keyboard input
  62. boolean cutout = false;
  63. //Sets if the note has been hit correctly so adds to the score
  64. boolean hit = false;
  65. //Stores what song is currently playing
  66. int song1 = 0;
  67. int song2 = 0;
  68. int song3 = 0;
  69. int song4 = 0;
  70. int song5 = 0;
  71. //Once the song has finished go back to the menu
  72. int timer = 0;
  73.  
  74. //Stores the font
  75. PFont font;
  76.  
  77. //Declares all the images for the start screen
  78. PImage title;
  79. PImage icon;
  80. PImage song1Image;
  81. PImage song2Image;
  82. PImage song3Image;
  83. PImage song4Image;
  84. PImage song5Image;
  85. PImage topScoreText;
  86. PImage durationText;
  87. PImage difficultyText;
  88. PImage difficultyStar;
  89.  
  90. //Declares all the images for ingame
  91. PImage button1Image;
  92. PImage button2Image;
  93. PImage button3Image;
  94. PImage button4Image;
  95. PImage button5Image;
  96. PImage button6Image;
  97. PImage button7Image;
  98. PImage button8Image;
  99. PImage button9Image;
  100. PImage button10Image;
  101. PImage buttonPressed;
  102.  
  103. void setup()
  104. {
  105. //Sets the size of the window
  106. size(1060, 600);
  107. //Tells processing what serial port to use
  108. myPort = new Serial(this, "COM3", 9600);
  109. //Sets the font to be used
  110. font = loadFont("LucidaConsole-24.vlw");
  111. //Loads all the images to be used in the start screen
  112. title = loadImage("Title.png");
  113. icon = loadImage("icon.png");
  114. song1Image = loadImage("song1.png");
  115. song2Image = loadImage("song2.png");
  116. song3Image = loadImage("song3.png");
  117. song4Image = loadImage("song4.png");
  118. song5Image = loadImage("song5.png");
  119. topScoreText = loadImage("topScore.png");
  120. durationText = loadImage("duration.png");
  121. difficultyText = loadImage("difficulty.png");
  122. difficultyStar = loadImage("difficultyStar.png");
  123.  
  124. //Loads all the images to be used in game
  125. button1Image = loadImage("button1.png");
  126. button2Image = loadImage("button2.png");
  127. button3Image = loadImage("button3.png");
  128. button4Image = loadImage("button4.png");
  129. button5Image = loadImage("button5.png");
  130. button6Image = loadImage("button6.png");
  131. button7Image = loadImage("button7.png");
  132. button8Image = loadImage("button8.png");
  133. button9Image = loadImage("button9.png");
  134. button10Image = loadImage("button10.png");
  135. buttonPressed = loadImage("buttonPressed.png");
  136.  
  137. //Loads up the high score data and converts it to an int again
  138. scoreData = loadStrings("data/scores.ddd");
  139. for(int i = 0; i <= 5; i++)
  140. {
  141. scores[i] = int(scoreData[i]);
  142. }
  143.  
  144. //Sets the frameRate for the program
  145. frameRate(60);
  146. }
  147.  
  148. void draw()
  149. {
  150. //If the start screen is true then display the start screen
  151. if (startScreen == true)
  152. {
  153. background(188,222,255);
  154. setUpStartScreen();
  155. }
  156.  
  157. //If the game is playing then set up the game
  158. if (gamePlaying == true)
  159. {
  160. background(255);
  161. //Send what song is being played
  162. send();
  163. //Check what buttons are being pressed
  164. receive();
  165. //Move the notes
  166. move();
  167. //Set which notes should be coming down the screen
  168. notes();
  169. //Sets up the buttons
  170. buttons();
  171. //Sets the score at the bottom of the page
  172. setupScore();
  173. //Adds to the timer
  174. timer++;
  175. }
  176. }
  177.  
  178. void setupScore()
  179. {
  180. //Sets the font and size
  181. textFont(font,24);
  182. //Sets the fill to red
  183. fill(255,0,0);
  184.  
  185. //Gets the text width
  186. tw = textWidth(scoreText);
  187. //Displays the text
  188. text(scoreText, (width-tw)/2-40, 570);
  189. //Converts the int score to a string
  190. temp = nf(score,0);
  191. //Gets the text width
  192. tw = textWidth(temp);
  193. //Displayed the score
  194. text(temp, (width-tw)/2+50, 570);
  195. }
  196.  
  197. void setUpStartScreen()
  198. {
  199. //If the menu state goes above the top of the screen put it back at the bottom
  200. if(menuState < 1)
  201. {
  202. menuState = 5;
  203. }
  204. //If the menu state goes below the bottom of the screen put it back at the top
  205. if(menuState > 5)
  206. {
  207. menuState = 1;
  208. }
  209.  
  210. //Loads the font
  211. textFont(font, 24);
  212. //Sets the font fill
  213. fill(255,0,0);
  214.  
  215. //If the first song is currently being selected then display this
  216. if(menuState == 1)
  217. {
  218. //Sets the menu Icon X position
  219. menuIcon = 131;
  220. //Displays the high score for the first song
  221. text(scores[1], 800, 215);
  222. //Adds the duration of the song
  223. text("26 seconds", 750, 345);
  224. //Shows how difficult the song is
  225. image(difficultyStar, 655, 460);
  226. image(difficultyStar, 720, 460);
  227. image(difficultyStar, 785, 460);
  228. image(difficultyStar, 850, 460);
  229. image(difficultyStar, 915, 460);
  230. }
  231. if(menuState == 2)
  232. {
  233. menuIcon = 210;
  234. text(scores[2], 800, 215);
  235. text("21 seconds", 750, 345);
  236. image(difficultyStar, 655, 460);
  237. }
  238. if(menuState == 3)
  239. {
  240. menuIcon = 297;
  241. text(scores[3], 800, 215);
  242. text("34 seconds", 750, 345);
  243. image(difficultyStar, 655, 460);
  244. image(difficultyStar, 720, 460);
  245. image(difficultyStar, 785, 460);
  246. image(difficultyStar, 850, 460);
  247. }
  248. if(menuState == 4)
  249. {
  250. menuIcon = 375;
  251. text(scores[4], 800, 215);
  252. text("39 seconds", 750, 345);
  253. image(difficultyStar, 655, 460);
  254. image(difficultyStar, 720, 460);
  255. image(difficultyStar, 785, 460);
  256. }
  257. if(menuState == 5)
  258. {
  259. menuIcon = 473;
  260. text(scores[5], 800, 215);
  261. text("24 seconds", 750, 345);
  262. image(difficultyStar, 655, 460);
  263. image(difficultyStar, 720, 460);
  264. }
  265.  
  266. //Sets the background for the song images
  267. fill(200, 200, 200);
  268. rect(30, 85, 520, 480);
  269.  
  270. //Loads the title
  271. image(title, 40, 17);
  272. //Loads the menuIcon
  273. image(icon, 40, menuIcon);
  274. //Loads the song images
  275. image(song1Image, 100, 131);
  276. image(song2Image, 100, 210);
  277. image(song3Image, 107, 267);
  278. image(song4Image, 177, 375);
  279. image(song5Image, 155, 453);
  280. //Adds the menu text
  281. image(topScoreText, 700, 130);
  282. image(durationText, 712, 260);
  283. image(difficultyText, 706, 390);
  284. }
  285.  
  286. //Sends the current song to the arduino
  287. void send()
  288. {
  289. myPort.write(song1);
  290. myPort.write(song2);
  291. myPort.write(song3);
  292. myPort.write(song4);
  293. myPort.write(song5);
  294. }
  295.  
  296. void receive()
  297. {
  298. //If the are 10 or more pieces of information available
  299. if(myPort.available() >= 10)
  300. {
  301. //Run a loop to store all the data
  302. for(int i=0; i<10; i++)
  303.  
  304. //Reads in all the button states and stores them in an array
  305. state[i] = myPort.read();
  306.  
  307. //Sets if the button is pressed or not
  308. button1 = state[0];
  309. button2 = state[1];
  310. button3 = state[2];
  311. button4 = state[3];
  312. button5 = state[4];
  313. button6 = state[5];
  314. button7 = state[6];
  315. button8 = state[7];
  316. button9 = state[8];
  317. button10 = state[9];
  318.  
  319. //Prints the buttons to processing
  320. print(button1);
  321. print(button2);
  322. print(button3);
  323. print(button4);
  324. print(button5);
  325. print(button6);
  326. print(button7);
  327. print(button8);
  328. print(button9);
  329. println(button10);
  330. }
  331. }
  332.  
  333. void move()
  334. {
  335. //Moves the y position depending on the speed
  336. y += speed;
  337. }
  338.  
  339. void playSong()
  340. {
  341. //If song 1 has been selected then start the game
  342. if(menuState == 1)
  343. {
  344. //Set song 1 as playing
  345. song1 = 1;
  346. //Turn off the start screen
  347. startScreen = false;
  348. //Load up the ingame screen
  349. gamePlaying = true;
  350. //Cut out the keyboard commands
  351. cutout = true;
  352. }
  353. if(menuState == 2)
  354. {
  355. song2 = 1;
  356. startScreen = false;
  357. gamePlaying = true;
  358. cutout = true;
  359. }
  360. if(menuState == 3)
  361. {
  362. song3 = 1;
  363. startScreen = false;
  364. gamePlaying = true;
  365. cutout = true;
  366. }
  367. if(menuState == 4)
  368. {
  369. song4 = 1;
  370. startScreen = false;
  371. gamePlaying = true;
  372. cutout = true;
  373. }
  374. if(menuState == 5)
  375. {
  376. song5 = 1;
  377. startScreen = false;
  378. gamePlaying = true;
  379. cutout = true;
  380. }
  381. }
  382.  
  383. void keyPressed()
  384. {
  385. //If the game is currently playing
  386. if(cutout == false)
  387. {
  388. switch(key)
  389. {
  390. //If the player pressed 1 select the first song
  391. case('1'):
  392. menuState = 1;
  393. break;
  394. case('2'):
  395. menuState = 2;
  396. break;
  397. case('3'):
  398. menuState = 3;
  399. break;
  400. case('4'):
  401. menuState = 4;
  402. break;
  403. case('5'):
  404. menuState = 5;
  405. break;
  406. }
  407. switch(keyCode)
  408. {
  409. //Allows you to select a song with the arrow keys
  410. case(DOWN):
  411. menuState++;
  412. break;
  413. case(UP):
  414. menuState--;
  415. break;
  416. //Press enter to play the song
  417. case(ENTER):
  418. playSong();
  419. break;
  420. }
  421. }
  422. //If the game is playing then you can press R to restart the song
  423. if(cutout == true)
  424. {
  425. switch(key)
  426. {
  427. case('r'):
  428. endSong();
  429. playSong();
  430. break;
  431. }
  432. }
  433. }
  434.  
  435. void buttons()
  436. {
  437. //If the button is pressed display the button pressed image otherwise display the default image
  438. if (button1 == 1)
  439. {
  440. image(buttonPressed, 30, 500);
  441. }
  442. else
  443. {
  444. image(button1Image, 30, 500);
  445. }
  446. if (button2 == 1)
  447. {
  448. image(buttonPressed, 132, 500);
  449. }
  450. else
  451. {
  452. image(button2Image, 132, 500);
  453. }
  454. if (button3 == 1)
  455. {
  456. image(buttonPressed, 232, 500);
  457. }
  458. else
  459. {
  460. image(button3Image, 232, 500);
  461. }
  462. if (button4 == 1)
  463. {
  464. image(buttonPressed, 332, 500);
  465. }
  466. else
  467. {
  468. image(button4Image, 332, 500);
  469. }
  470. if (button5 == 1)
  471. {
  472. image(buttonPressed, 432, 500);
  473. }
  474. else
  475. {
  476. image(button5Image, 432, 500);
  477. }
  478. if (button6 == 1)
  479. {
  480. image(buttonPressed, 532, 500);
  481. }
  482. else
  483. {
  484. image(button6Image, 532, 500);
  485. }
  486. if (button7 == 1)
  487. {
  488. image(buttonPressed, 632, 500);
  489. }
  490. else
  491. {
  492. image(button7Image, 632, 500);
  493. }
  494. if (button8 == 1)
  495. {
  496. image(buttonPressed, 732, 500);
  497. }
  498. else
  499. {
  500. image(button8Image, 732, 500);
  501. }
  502. if (button9 == 1)
  503. {
  504. image(buttonPressed, 832, 500);
  505. }
  506. else
  507. {
  508. image(button9Image, 832, 500);
  509. }
  510. if (button10 == 1)
  511. {
  512. image(buttonPressed, 932, 500);
  513. }
  514. else
  515. {
  516. image(button10Image, 932, 500);
  517. }
  518. //Sets the fill to black
  519. fill(0);
  520. //Draws lines to seperate each of the notes
  521. line(25, 0, 25, height);
  522. line(130, 0, 130, height);
  523. line(230, 0, 230, height);
  524. line(330, 0, 330, height);
  525. line(430, 0, 430, height);
  526. line(530, 0, 530, height);
  527. line(630, 0, 630, height);
  528. line(730, 0, 730, height);
  529. line(830, 0, 830, height);
  530. line(930, 0, 930, height);
  531. line(1035, 0, 1035, height);
  532. }
  533.  
  534. //Function to allow the notes to be created easier
  535. void note(int button/*Sets which note it should be*/,int duration/*How long the note should last*/, int noteY/*What position it should be depending on the sequence of notes*/)
  536. {
  537. //If the note is on screen then draw
  538. if((((y-noteY) + duration + 20) > 0 && ((y-noteY) + duration + 20) < 600) || (y-noteY > 0 && y-noteY < 600))
  539. {
  540. //Declares the noteX
  541. int noteX = 0;
  542. //Sets the noteFill
  543. color noteFill = color(0,0,0);
  544.  
  545. //If the note is meant to be on button 1
  546. if (button == 1)
  547. {
  548. //Set the X position to the first column
  549. noteX = 50;
  550. //Set the colour to the same as the first button
  551. noteFill = color(0,255,0);
  552.  
  553. //If the first button is pressed while the note is on top of it then add to the score
  554. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button1 == 1)
  555. {
  556. hit = true;
  557. }
  558. else
  559. {
  560. hit = false;
  561. }
  562. }
  563. if (button == 2)
  564. {
  565. noteX = 150;
  566. noteFill = color(255,0,0);
  567.  
  568. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button2 == 1)
  569. {
  570. hit = true;
  571. }
  572. else
  573. {
  574. hit = false;
  575. }
  576. }
  577. if (button == 3)
  578. {
  579. noteX = 250;
  580. noteFill = color(255,255,0);
  581.  
  582. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button3 == 1)
  583. {
  584. hit = true;
  585. }
  586. else
  587. {
  588. hit = false;
  589. }
  590. }
  591. if (button == 4)
  592. {
  593. noteX = 350;
  594. noteFill = color(0,0,255);
  595.  
  596. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button4 == 1)
  597. {
  598. hit = true;
  599. }
  600. else
  601. {
  602. hit = false;
  603. }
  604. }
  605. if (button == 5)
  606. {
  607. noteX = 450;
  608. noteFill = color(255,165,0);
  609.  
  610. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button5 == 1)
  611. {
  612. hit = true;
  613. }
  614. else
  615. {
  616. hit = false;
  617. }
  618. }
  619. if (button == 6)
  620. {
  621. noteX = 550;
  622. noteFill = color(165,0,165);
  623.  
  624. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button6 == 1)
  625. {
  626. hit = true;
  627. }
  628. else
  629. {
  630. hit = false;
  631. }
  632. }
  633. if (button == 7)
  634. {
  635. noteX = 650;
  636. noteFill = color(13,255,249);
  637.  
  638. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button7 == 1)
  639. {
  640. hit = true;
  641. }
  642. else
  643. {
  644. hit = false;
  645. }
  646. }
  647. if (button == 8)
  648. {
  649. noteX = 750;
  650. noteFill = color(0);
  651.  
  652. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button8 == 1)
  653. {
  654. hit = true;
  655. }
  656. else
  657. {
  658. hit = false;
  659. }
  660. }
  661. if (button == 9)
  662. {
  663. noteX = 850;
  664. noteFill = color(244,158,158);
  665.  
  666. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button9 == 1)
  667. {
  668. hit = true;
  669. }
  670. else
  671. {
  672. hit = false;
  673. }
  674. }
  675. if (button == 10)
  676. {
  677. noteX = 950;
  678. noteFill = color(172,245,166);
  679.  
  680. if (y-noteY < 500 && ((y-noteY) + duration + 20) > 500 && button10 == 1)
  681. {
  682. hit = true;
  683. }
  684. else
  685. {
  686. hit = false;
  687. }
  688. }
  689. //Sets the note fill
  690. fill(noteFill);
  691. //Draws a rectangle for the note
  692. rect(noteX,y-noteY,60,duration);
  693.  
  694. //If the note has been hit then add to the score
  695. if (hit == true)
  696. {
  697. score++;
  698. }
  699. }
  700. }
  701.  
  702. void notes()
  703. {
  704. //If song 1 is playing then add the notes
  705. if (song1 == 1)
  706. {
  707. song1Play();
  708. }
  709. if (song2 == 1)
  710. {
  711. song2Play();
  712. }
  713. if (song3 == 1)
  714. {
  715. song3Play();
  716. }
  717. if(song4 == 1)
  718. {
  719. song4Play();
  720. }
  721. if(song5 == 1)
  722. {
  723. song5Play();
  724. }
  725. }
  726.  
  727. void endSong()
  728. {
  729. //If the current score is greater than the current high score then replace the high score with the current score
  730. if(menuState == 1)
  731. {
  732. if(score > scores[1])
  733. {
  734. scores[1] = score;
  735. }
  736. }
  737. if(menuState == 2)
  738. {
  739. if(score > scores[2])
  740. {
  741. scores[2] = score;
  742. }
  743. }
  744. if(menuState == 3)
  745. {
  746. if(score > scores[3])
  747. {
  748. scores[3] = score;
  749. }
  750. }
  751. if(menuState == 4)
  752. {
  753. if(score > scores[4])
  754. {
  755. scores[4] = score;
  756. }
  757. }
  758. if(menuState == 5)
  759. {
  760. if(score > scores[5])
  761. {
  762. scores[5] = score;
  763. }
  764. }
  765. //Stores the high scores in the scoreData array
  766. for(int i = 0; i <= 5; i++)
  767. {
  768. scoreData[i] = str(scores[i]);
  769. }
  770. //Saves the score data
  771. saveStrings("data/scores.ddd", scoreData);
  772. //Resets the timer to 0
  773. timer = 0;
  774. //Stops the songs playing
  775. song1 = 0;
  776. song2 = 0;
  777. song3 = 0;
  778. song4 = 0;
  779. song5 = 0;
  780. //Resets the score
  781. score = 0;
  782. //Resets the start screen
  783. gamePlaying = false;
  784. startScreen = true;
  785. //Allows further keyboard input
  786. cutout = false;
  787. //resets the y position
  788. y = 0;
  789. }
  790.  
  791. void song1Play() //Imperial March
  792. {
  793. //Sets the initial y value
  794. int noteY = 100;
  795.  
  796. //Once the timer reaches this number then end the song
  797. if (timer >= 1560)
  798. {
  799. endSong();
  800. }
  801.  
  802. //Create a note for button 1 with a duration of 50
  803. note(1, 50, noteY);
  804. //Create a note for button 1 with a duration of 50 then set the y position 70 behind the last note
  805. //50 for the duration of the note plus a small 20 delay so the notes dont get mixed up
  806. note(1, 50, noteY += 70);
  807. note(1, 50, noteY += 70);
  808. note(2, 35, noteY += 55);
  809. note(3, 15, noteY += 35);
  810. note(1, 50, noteY += 70);
  811. note(2, 35, noteY += 55);
  812. note(3, 15, noteY += 35);
  813. note(1, 100, noteY += 120);
  814. note(4, 50, noteY += 70);
  815. note(4, 50, noteY += 70);
  816. note(4, 50, noteY += 70);
  817. note(5, 35, noteY += 55);
  818. note(3, 15, noteY += 35);
  819. note(1, 50, noteY += 70);
  820. note(2, 35, noteY += 55);
  821. note(3, 15, noteY += 35);
  822. note(1, 100, noteY += 120);
  823. note(7, 50, noteY += 70);
  824. note(1, 35, noteY += 55);
  825. note(1, 15, noteY += 35);
  826. note(7, 50, noteY += 70);
  827. note(8, 25, noteY += 45);
  828. note(9, 25, noteY += 45);
  829. note(9, 13, noteY += 33);
  830. note(5, 13, noteY += 33);
  831. note(9, 25, noteY += 45);
  832. note(6, 25, noteY += 70);
  833. note(4, 50, noteY += 70);
  834. note(10, 25, noteY += 45);
  835. note(3, 25, noteY += 45);
  836. note(3, 13, noteY += 33);
  837. note(6, 13, noteY += 33);
  838. note(3, 25, noteY += 45);
  839. note(2, 13, noteY += 58);
  840. note(6, 50, noteY += 70);
  841. note(2, 38, noteY += 58);
  842. note(1, 13, noteY += 33);
  843. note(3, 50, noteY += 70);
  844. note(1, 38, noteY += 58);
  845. note(3, 13, noteY += 33);
  846. note(4, 100, noteY += 120);
  847. }
  848.  
  849. void song2Play() //James Bond theme
  850. {
  851. int noteY = 100;
  852.  
  853. if (timer >= 1260)
  854. {
  855. endSong();
  856. }
  857.  
  858. note(1, 25, noteY);
  859. note(2, 13, noteY += 33);
  860. note(2, 13, noteY += 33);
  861. note(2, 25, noteY += 45);
  862. note(2, 50, noteY += 70);
  863. note(1, 25, noteY += 45);
  864. note(1, 25, noteY += 45);
  865. note(1, 25, noteY += 45);
  866. note(1, 25, noteY += 45);
  867. note(3, 13, noteY += 33);
  868. note(3, 13, noteY += 33);
  869. note(3, 25, noteY += 45);
  870. note(3, 50, noteY += 70);
  871. note(2, 25, noteY += 45);
  872. note(2, 25, noteY += 45);
  873. note(2, 25, noteY += 45);
  874. note(1, 25, noteY += 45);
  875. note(2, 13, noteY += 33);
  876. note(2, 13, noteY += 33);
  877. note(2, 25, noteY += 45);
  878. note(2, 50, noteY += 70);
  879. note(1, 25, noteY += 45);
  880. note(1, 25, noteY += 45);
  881. note(1, 25, noteY += 45);
  882. note(1, 25, noteY += 45);
  883. note(3, 13, noteY += 33);
  884. note(3, 13, noteY += 33);
  885. note(3, 25, noteY += 45);
  886. note(3, 50, noteY += 70);
  887. note(2, 25, noteY += 45);
  888. note(4, 25, noteY += 45);
  889. note(1, 25, noteY += 45);
  890. note(5, 25, noteY += 45);
  891. note(6, 100, noteY += 120);
  892. note(7, 25, noteY += 45);
  893. note(8, 25, noteY += 45);
  894. note(7, 100, noteY += 120);
  895.  
  896. }
  897.  
  898. void song3Play() //Indiana Jones
  899. {
  900. int noteY = 100;
  901.  
  902. if (timer >= 2040)
  903. {
  904. endSong();
  905. }
  906.  
  907. note(1, 70, noteY);
  908. note(2, 13, noteY += 33);
  909. note(3, 25, noteY += 25);
  910. note(4, 85, noteY += 143);
  911. note(5, 70, noteY += 103);
  912. note(1, 13, noteY += 33);
  913. note(2, 130, noteY += 150);
  914. note(3, 70, noteY += 90);
  915. note(6, 13, noteY += 33);
  916. note(7, 25, noteY += 45);
  917. note(8, 85, noteY += 143);
  918. note(6, 70, noteY += 103);
  919. note(7, 13, noteY += 33);
  920. note(4, 150, noteY += 170);
  921. note(9, 150, noteY += 170);
  922. note(10, 50, noteY += 70);
  923. note(1, 70, noteY += 120);
  924. note(2, 13, noteY += 33);
  925. note(3, 25, noteY += 45);
  926. note(4, 85, noteY += 143);
  927. note(9, 70, noteY += 103);
  928. note(10, 13, noteY += 33);
  929. note(8, 130, noteY += 150);
  930. note(3, 20, noteY += 40);
  931. note(3, 13, noteY += 83);
  932. note(10, 150, noteY += 170);
  933. note(9, 13, noteY += 33);
  934. note(3, 13, noteY += 83);
  935. note(10, 150, noteY += 170);
  936. note(9, 70, noteY += 90);
  937. note(3, 13, noteY += 33);
  938. note(10, 150, noteY += 170);
  939. note(9, 70, noteY += 90);
  940. note(3, 13, noteY += 33);
  941. note(8, 160, noteY += 170);
  942. note(10, 70, noteY += 90);
  943. note(9, 13, noteY += 33);
  944. note(4, 85, noteY += 105);
  945. }
  946.  
  947. void song4Play() //Jurassic Park theme
  948. {
  949. int noteY = 100;
  950.  
  951. if (timer >= 2310)
  952. {
  953. endSong();
  954. }
  955.  
  956. note(1, 30, noteY += 50);
  957. note(2, 30, noteY += 50);
  958. note(1, 70, noteY += 90);
  959. note(1, 30, noteY += 70);
  960. note(2, 30, noteY += 50);
  961. note(1, 70, noteY += 90);
  962. note(1, 30, noteY += 70);
  963. note(2, 30, noteY += 50);
  964. note(1, 70, noteY += 90);
  965. note(3, 30, noteY += 50);
  966. note(3, 50, noteY += 70);
  967. note(4, 30, noteY += 50);
  968. note(4, 50, noteY += 70);
  969. note(5, 30, noteY += 70);
  970. note(1, 30, noteY += 50);
  971. note(3, 70, noteY += 90);
  972. note(2, 30, noteY += 50);
  973. note(6, 30, noteY += 50);
  974. note(5, 50, noteY += 70);
  975. note(1, 30, noteY += 50);
  976. note(3, 70, noteY += 90);
  977. note(7, 50, noteY += 100);
  978. note(1, 50, noteY += 70);
  979. note(4, 70, noteY += 90);
  980. note(5, 30, noteY += 50);
  981. note(5, 70, noteY += 90);
  982. note(3, 30, noteY += 50);
  983. note(3, 70, noteY += 90);
  984. note(1, 30, noteY += 100);
  985. note(2, 30, noteY += 50);
  986. note(1, 70, noteY += 90);
  987. note(1, 30, noteY += 70);
  988. note(2, 30, noteY += 50);
  989. note(1, 70, noteY += 90);
  990. note(1, 30, noteY += 70);
  991. note(2, 30, noteY += 50);
  992. note(1, 70, noteY += 90);
  993. note(3, 30, noteY += 50);
  994. note(3, 50, noteY += 70);
  995. note(4, 30, noteY += 50);
  996. note(4, 50, noteY += 70);
  997. note(5, 30, noteY += 70);
  998. note(1, 30, noteY += 50);
  999. note(3, 70, noteY += 90);
  1000. note(2, 30, noteY += 50);
  1001. note(6, 30, noteY += 50);
  1002. note(5, 50, noteY += 70);
  1003. note(1, 30, noteY += 50);
  1004. note(3, 70, noteY += 90);
  1005. note(7, 50, noteY += 100);
  1006. note(1, 50, noteY += 70);
  1007. note(4, 70, noteY += 90);
  1008. note(5, 30, noteY += 50);
  1009. note(5, 70, noteY += 90);
  1010. note(3, 30, noteY += 50);
  1011. note(3, 70, noteY += 90);
  1012. }
  1013.  
  1014. void song5Play() //Superman theme
  1015. {
  1016. int noteY = 100;
  1017.  
  1018. if (timer >= 1440)
  1019. {
  1020. endSong();
  1021. }
  1022.  
  1023. note(1, 20, noteY);
  1024. note(1, 20, noteY += 40);
  1025. note(1, 20, noteY += 40);
  1026. note(2, 40, noteY += 60);
  1027. note(2, 20, noteY += 40);
  1028. note(3, 60, noteY += 80);
  1029. note(3, 40, noteY += 85);
  1030. note(4, 26, noteY += 46);
  1031. note(3, 13, noteY += 33);
  1032. note(5, 20, noteY += 40);
  1033. note(3, 80, noteY += 100);
  1034. note(1, 20, noteY += 65);
  1035. note(1, 20, noteY += 40);
  1036. note(1, 20, noteY += 40);
  1037. note(2, 40, noteY += 60);
  1038. note(2, 20, noteY += 40);
  1039. note(3, 60, noteY += 80);
  1040. note(3, 20, noteY += 65);
  1041. note(4, 26, noteY += 46);
  1042. note(3, 13, noteY += 33);
  1043. note(5, 20, noteY += 40);
  1044. note(4, 20, noteY += 40);
  1045. note(3, 90, noteY += 110);
  1046. note(2, 20, noteY += 65);
  1047. note(2, 20, noteY += 40);
  1048. note(2, 20, noteY += 40);
  1049. note(6, 90, noteY += 110);
  1050. note(3, 60, noteY += 80);
  1051. note(2, 20, noteY += 40);
  1052. note(2, 20, noteY += 40);
  1053. note(2, 20, noteY += 40);
  1054. note(6, 20, noteY += 40);
  1055. note(4, 20, noteY += 40);
  1056. note(6, 20, noteY += 40);
  1057. note(7, 60, noteY += 80);
  1058. note(2, 20, noteY += 40);
  1059. note(2, 20, noteY += 40);
  1060. note(2, 20, noteY += 40);
  1061. note(2, 20, noteY += 40);
  1062. note(2, 20, noteY += 40);
  1063. note(2, 60, noteY += 80);
  1064. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement