Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #include "bubble.h"
  5. #include "dolphin.h"
  6. #include "math.h"
  7.  
  8. bool BubblePattern::load_pattern(const char* patternfilename)
  9. {
  10. FILE* f = fopen(patternfilename, "rb");
  11. if(!f)
  12. {
  13. fprintf(stderr, "Error: couldn't load \"%s\"", patternfilename);
  14. return false;
  15. }
  16.  
  17. fscanf(f, "%d\n", &nb_bubbles);
  18.  
  19. int i=0;
  20. while(!feof(f))
  21. {
  22. fscanf(f, "%d\n", &bubble_pattern[i].y);
  23. printf ("i: %d\n" , i);
  24. i++;
  25. }
  26.  
  27.  
  28. fclose(f);
  29. return true;
  30. }
  31.  
  32. bool BubblePattern::init(const char* filename, float x, float y, bool use_transp)
  33. {
  34. for (int i=0; i<BUBBLES_PER_PATTERN; i++)
  35. bubble_pattern[i].init(filename, x + BPM_MUSIC_1*i, y, use_transp);
  36.  
  37. return true;
  38. }
  39.  
  40. void BubblePattern::update(double elapsed, const SDL_Event& event)
  41. {
  42.  
  43. for (int i=0; i<BUBBLES_PER_PATTERN; i++)
  44. bubble_pattern[i].update(i, event);
  45. }
  46.  
  47. void BubblePattern::display()
  48. {
  49. for (int i=0; i<BUBBLES_PER_PATTERN; i++)
  50. bubble_pattern[i].display();
  51. }
  52.  
  53. void BubblePattern::cleanup()
  54. {
  55. for (int i=0; i<BUBBLES_PER_PATTERN; i++)
  56. bubble_pattern[i].cleanup();
  57. }
  58.  
  59. bool BubblePattern::collision_with (const Sprite& sprite)
  60. {
  61. for (int i=0; i<BUBBLES_PER_PATTERN; i++)
  62. bubble_pattern[i].collision_with(sprite);
  63. }
  64.  
  65.  
  66.  
  67. /*
  68. void BubblePattern::setPatternX(int patternX [BUBBLES_PER_PATTERN])
  69. {
  70. for (int i=0; i<BUBBLES_PER_PATTERN; i++)
  71. bubble_pattern[i].x = patternX [i];
  72. }
  73. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement