Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. import processing.sound.*;
  2.  
  3. import sprites.*;
  4. import sprites.maths.*;
  5. import sprites.utils.*;
  6.  
  7. PImage FirstbackG;
  8. StopWatch sw = new StopWatch();
  9. SoundFile grassCrunchFile;
  10.  
  11.  
  12. //CAT SPRITE Properties
  13. Sprite cat;
  14. //SoundFile cheetahFile;
  15. SoundFile catSoundFile;
  16. float catXpos;
  17. float catYpos;
  18. //Blue Bird SPRITE Properties
  19. Sprite BBird;
  20. SoundFile birdSoundFile;
  21. //Cute Bunny Properties
  22. Sprite cuteBunny;
  23. SoundFile bunnySoundFile;
  24. //Pinky SPRITE properties
  25. Sprite pinky;
  26. SoundFile pinkySoundFile;
  27.  
  28. //fair warning when you listen to the sounds with headphones,
  29. //they don't sound right
  30. void setup() {
  31. size(1024, 512);
  32. FirstbackG = loadImage("forest.png");
  33. //
  34. //Cheetah Properties
  35. catXpos = 500;
  36. catYpos = 300;
  37. catSoundFile = new SoundFile(this, "catsound.wav");
  38. cat = new Sprite(this, "cat.png", 2, 4, 0);
  39. scale(0.1);
  40. cat.setXY(catXpos, catYpos);
  41. cat.setVelXY(0.0f, 0);
  42. cat.setFrameSequence(0, 15, 0.1);
  43.  
  44. //
  45. //Blue Bird Properties
  46. BBird = new Sprite(this, "tropic Bird.png", 3, 3, 0);
  47. BBird.setXY(300, 100);
  48. BBird.setVelXY(0.0f, 0);
  49. BBird.setFrameSequence(0, 15, 0.1);
  50. birdSoundFile = new SoundFile(this, "birdsound.wav");
  51. //
  52. //Cute Bunny Properties
  53. cuteBunny = new Sprite (this, "bunny-Sheet.png", 4, 6, 0);
  54. cuteBunny.setXY(200, 390);
  55. cuteBunny.setVelXY(0.0f, 0);
  56. cuteBunny.setFrameSequence(0, 15, 0.1);
  57. bunnySoundFile = new SoundFile(this, "bunnySound.wav");
  58. //
  59. //Pinky Properties
  60. pinky = new Sprite (this, "pinkyRun.png", 6, 1, 0);
  61. pinky.setXY (700, 390);
  62. pinky.setVelXY(0.0f, 0);
  63. pinky.setFrameSequence(0, 15, 0.1);
  64. pinkySoundFile = new SoundFile(this, "pinkySound.wav");
  65.  
  66. //
  67. registerMethod ("pre", this);
  68. }
  69.  
  70.  
  71. public void pre() {
  72.  
  73. float elapsedTime = (float)sw.getElapsedTime();
  74. S4P.updateSprites(elapsedTime);
  75. }
  76.  
  77.  
  78. void draw() {
  79. background(FirstbackG);
  80.  
  81. S4P.drawSprites();
  82. grassCrunchFile = new SoundFile(this, "grassCrunch.wav");
  83. //grassCrunchFile.play(); Fix the sound
  84. //bird
  85. if (keyPressed) {
  86. if (key == 'b') {
  87. birdSoundFile.play();
  88. BBird.setVelXY(35.0f, 0);
  89. } else {
  90. BBird.setVelXY(0.0f, 0);
  91. }
  92. }
  93.  
  94. ////bunny
  95. if (keyPressed) {
  96. if (key == 'r') {
  97. bunnySoundFile.play();
  98. cuteBunny.setVelXY(-30.0f, 0);
  99. } else {
  100. cuteBunny.setVelXY(0.0f, 0);
  101. }
  102. }
  103.  
  104.  
  105. //Cheetah is activated when 'C" pressed
  106. if (keyPressed) {
  107. if (key == 'c') {
  108. catSoundFile.play();
  109. cat.setVelXY(30.0f, 0);
  110. //break;
  111. //if (catXpos >- width)
  112.  
  113. // catXpos = 10
  114. }
  115. } //else {
  116. //cat.setVelXY(0.0f, 0);
  117. //}
  118.  
  119. if (keyPressed) {
  120. if (key == 'p') {
  121. pinky.setVelXY(30.f, 0);
  122. pinkySoundFile.play();
  123. }
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement