sets up the buttons (color, position, state) */
| 51 | |
| 52 | /* sets up the buttons (color, position, state) */ |
| 53 | void |
| 54 | initializeButtons(SDL_Renderer *renderer) |
| 55 | { |
| 56 | int i; |
| 57 | int spacing = 10; /* gap between drum buttons */ |
| 58 | SDL_Rect buttonRect; /* keeps track of where to position drum */ |
| 59 | SDL_Color upColor = { 86, 86, 140, 255 }; /* color of drum when not pressed */ |
| 60 | SDL_Color downColor = { 191, 191, 221, 255 }; /* color of drum when pressed */ |
| 61 | int renderW, renderH; |
| 62 | |
| 63 | SDL_RenderGetLogicalSize(renderer, &renderW, &renderH); |
| 64 | |
| 65 | buttonRect.x = spacing; |
| 66 | buttonRect.y = spacing; |
| 67 | buttonRect.w = renderW - 2 * spacing; |
| 68 | buttonRect.h = (renderH - (NUM_DRUMS + 1) * spacing) / NUM_DRUMS; |
| 69 | |
| 70 | /* setup each button */ |
| 71 | for (i = 0; i < NUM_DRUMS; i++) { |
| 72 | |
| 73 | buttons[i].rect = buttonRect; |
| 74 | buttons[i].isPressed = 0; |
| 75 | buttons[i].upColor = upColor; |
| 76 | buttons[i].downColor = downColor; |
| 77 | |
| 78 | buttonRect.y += spacing + buttonRect.h; /* setup y coordinate for next drum */ |
| 79 | |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | loads a wav file (stored in 'file'), converts it to the mixer's output format, |
no test coverage detected