/* octave was going HAYWIRE when it was controlled by held, * so this is a function for any buttons that can't * handle held. (Octave needed slow incrementation, one * per push. */ void keysDownOnly(int px, int py) { switch (cscreen){ case 0: if (withIn(MENU1MFY, py, MENU1MLY)) { if (withIn(octdb.fx, px, octdb.lx)) octave--; if (withIn(octub.fx, px, octub.lx)) if (octave < 7) octave++; chroot(); makeNotes(); doKeys(); break; } } if (cscreen == 2) { if (withIn(208, px, 253)) { if (withIn(46, py, 90)) wOval = ! wOval; if (withIn(92, py, 136)) fTri = !fTri; } } }
void isWeHasButton(int px, int py) { int ra; int inde; if (withIn(TOPMENUFY, py, TOPMENULY)) { if (withIn(1, px, 49)) { cscreen = 0; setMenuUP(); } if (withIn(52, px, 101)) { cscreen = 1; setMenuUP(); } if (withIn(103, px, 152)) { cscreen = 2; setMenuUP(); } if (withIn(208, px, 255)) { cscreen = 4; setMenuUP(); } } if (cscreen == 0) { if (withIn(MENU1TFY, py, MENU1TLY)) { if (withIn(majorb.fx, px, majorb.lx)) scale = 0; if (withIn(minorb.fx, px, minorb.lx)) scale = 1; if (withIn(melminb.fx, px, melminb.lx)) scale = 2; if (withIn(phrygb.fx, px, phrygb.lx)) scale = 3; if (withIn(bluesb.fx, px, bluesb.lx)) scale = 4; doKeys(); } if (withIn(MENU1BFY, py, MENU1BLY)) { if (withIn(keyab.fx, px, keyab.lx)) curkey = 0; if (withIn(keyasb.fx, px, keyasb.lx)) curkey = 1; if (withIn(keybb.fx, px, keybb.lx)) curkey = 2; if (withIn(keycb.fx, px, keycb.lx)) curkey = 3; if (withIn(keycsb.fx, px, keycsb.lx)) curkey = 4; if (withIn(keydb.fx, px, keydb.lx)) curkey = 5; if (withIn(keydsb.fx, px, keydsb.lx)) curkey = 6; if (withIn(keyeb.fx, px, keyeb.lx)) curkey = 7; if (withIn(keyfb.fx, px, keyfb.lx)) curkey = 8; if (withIn(keyfsb.fx, px, keyfsb.lx)) curkey = 9; if (withIn(keygb.fx, px, keygb.lx)) curkey = 10; if (withIn(keygsb.fx, px, keygsb.lx)) curkey = 11; chroot(); makeNotes(); doKeys(); } } else if (cscreen == 1) { if (withIn(MENU2MFY, py, MENU2MLY)) doPAN(px/2); if (withIn(MENU2BFY, py, MENU2BLY)) doVOLUME(px/2); if (withIn(MENU2TFY, py, MENU2TLY)) { if (withIn(0, px, 41)) doWD(0); if (withIn(43, px, 84)) doWD(1); if (withIn(86, px, 128)) doWD(2); if (withIn(129, px, 169)) doWD(3); if (withIn(171, px, 212)) doWD(4); if (withIn(214, px, 255)) doWD(5); } } else if (cscreen == 2) { if (withIn(45, py, 186)) { ra = py - 45; inde = ra - 70; if (withIn(MWHAMF, px, MWHAML)) whammy = inde*4; if (withIn(MPITCHF, px, MPITCHL)) pitching = inde; if (withIn(MVOLUMEF, px, MVOLUMEL)) volbent = inde/10; if (withIn(MPPF, px, MPPL)) { if (withIn(45, py, 65)) ppeak = 0.1; if (withIn(66, py, 86)) ppeak = 0.2; if (withIn(87, py, 107)) ppeak = 0.3; if (withIn(108, py, 128)) ppeak = 0.5; if (withIn(129, py, 149)) ppeak = 1; if (withIn(150, py, 170)) ppeak = 2; if (withIn(171, py, 186)) ppeak = 4; } } } else if (cscreen == 4) { if (withIn(33, py, 83)) { if (withIn(2, px, 63)) curkey = 0; if (withIn(65, px, 126)) curkey = 1; if (withIn(128, px, 189)) curkey = 2; if (withIn(191, px, 252)) curkey = 3; } if (withIn(86, py, 136)) { if (withIn(2, px, 63)) curkey = 4; if (withIn(65, px, 126)) curkey = 5; if (withIn(128, px, 189)) curkey = 6; if (withIn(191, px, 252)) curkey = 7; } if (withIn(140, py, 190)) { if (withIn(2, px, 63)) curkey = 8; if (withIn(65, px, 126)) curkey = 9; if (withIn(128, px, 189)) curkey = 10; if (withIn(191, px, 252)) curkey = 11; } chroot(); makeNotes(); doKeys(); } }
/** Main function **/ int main(int argc, char* args[]) { // // Initialize program // Init SDL SDL_Init(SDL_INIT_EVERYTHING); // Open window gbl::S_screen = SDL_SetVideoMode((int)cnst::WINDOW_WIDTH,(int)cnst::WINDOW_HEIGHT,32,SDL_SWSURFACE); // Set caption SDL_WM_SetCaption(cnst::WINDOW_CAPTION.c_str(), NULL); // Initialize fps regulator fpsCalc::GetInstance()->Init((double)cnst::TARGET_FPS); // // Load resources // Graphics res::S_title = imageLoad("resources/graphics/title.png"); res::S_message = imageLoad("resources/graphics/message.png"); // Sounds // // // Initialize game // Set state to title screen gbl::state = 2; // Initialize title screen scr_title_start(); // // Main loop while(gbl::loop) { /*Events*/ keystates = SDL_GetKeyState(NULL); while(SDL_PollEvent(&event)) { if(event.type == SDL_QUIT) gbl::loop = false; // event if(event.type == SDL_KEYDOWN) { switch(event.key.keysym.sym) { case SDLK_SPACE: gbl::spacePressed = true; break; } } } // keystates doKeys(); switch(gbl::state) { case 2: // title scr_title_step(); scr_title_render_graphics(); if(gbl::state == 3) scr_lvl_start(); break; case 3: // level select scr_lvl_step(); scr_lvl_render_graphics(); if(gbl::state == 4) playLevel("resources/levels/lvl_01.pkm"); break; case 4: // play //scr_title_step(); //scr_title_render_graphics(); break; }//switch }//while // // Shutdown // SDL SDL_Quit(); // Free images imageFree(res::S_title); imageFree(res::S_message); // Bye return 0; }