bool Bounds::hasColidedWith(Bounds otherobj) { //al_draw_filled_rectangle(getX(),getY(),getX() + getW(),getY() + getH(),al_map_rgb(255,255,255)); //al_draw_filled_rectangle(otherobj.getX(),otherobj.getY(),otherobj.getX() + otherobj.getW(),otherobj.getY() + otherobj.getH(),al_map_rgb(255,255,255)); if( getX() < otherobj.getX() + otherobj.getW() && getX() + getW() > otherobj.getX() && getY() < otherobj.getY() + otherobj.getH() && getY() + getH() > otherobj.getY()) { //cout << "HIT:{" << getX() << "|" << getY() << "|" << getW() << "|" << getH() << "},{" << otherobj.getX() << "|" << otherobj.getY() << "|" << otherobj.getW() << "|" << otherobj.getH() << endl; return true; } return false; }
//Other functions void initMenus() { al_set_display_icon(display,load_image("Images\\Icon.png")); //mymenu.addButton(20.0f,20.0f,al_load_bitmap("Images\\Menus\\Test\\btnup.png"),al_load_bitmap("Images\\Menus\\Test\\btndown.png"),"bla"); //mainmenu mainmenu = new Menu(); //mainmenu logHelperMessage(INFO,1,"Creating mainmenu"); //load images. ALLEGRO_BITMAP* mainmenubg = load_image("Images\\Menus\\main\\bg.png"); ALLEGRO_BITMAP* mainmenutitle = load_image("Images\\Menus\\main\\title.png"); ALLEGRO_BITMAP* mainmenusingle_UP = load_image("Images\\Menus\\main\\single_up.png"); ALLEGRO_BITMAP* mainmenusingle_DOWN = load_image("Images\\Menus\\main\\single_down.png"); ALLEGRO_BITMAP* mainmenumulti = load_image("Images\\Menus\\main\\multi_up.png"); ALLEGRO_BITMAP* mainmenuoptions_UP = load_image("Images\\Menus\\main\\options_up.png"); ALLEGRO_BITMAP* mainmenuoptions_DOWN = load_image("Images\\Menus\\main\\options_down.png"); ALLEGRO_BITMAP* mainmenuexit_UP = load_image("Images\\Menus\\main\\exit_up.png"); ALLEGRO_BITMAP* mainmenuexit_DOWN = load_image("Images\\Menus\\main\\exit_down.png"); ALLEGRO_BITMAP* mainmenucopyright = load_image("Images\\Menus\\main\\copywrite.png"); ALLEGRO_BITMAP* mainmenuversion = load_image("Images\\Menus\\main\\version.png"); string mainmenubgs = "Sound\\BGS\\Title.wav"; getGameRefrence()->sendMessageToAllObjects(myconcat(2,"BGM_PLAY_","Sound\\BGS\\Title.wav"),CLASSTYPE_SOUNDMANAGER); //ALLEGRO_SAMPLE* mainmenubgs = load_sound("Sound\\BGS\\Title.wav"); //create button pointer functions void(*mainmenusingleclick)() = &mainMenuClickSingle; void(*mainmenumulticlick)() = &mainMenuClickMulti; void(*mainmenuoptionclick)() = &mainMenuClickOption; void(*mainmenuexitclick)() = &mainMenuClickExit; //add buttons mainmenu->addImage(0,0,mainmenubg); mainmenu->addImage(112,60,mainmenutitle); mainmenu->addButton(266,350,mainmenusingle_UP,mainmenusingle_DOWN,"Single",mainmenusingleclick); mainmenu->addImage(266,414,mainmenumulti);//TODO:multiplayer button mainmenu->addButton(266,480,mainmenuoptions_UP,mainmenuoptions_DOWN,"Options",mainmenuoptionclick); mainmenu->addButton(266,545,mainmenuexit_UP,mainmenuexit_DOWN,"Exit",mainmenuexitclick); mainmenu->addImage(0,606,mainmenucopyright); mainmenu->addImage(575,606,mainmenuversion); mainmenu->setBgs(mainmenubgs); getGameRefrence()->registerGameObject(mainmenu);//register menu //optionsmenu menuoptions = new Menu(); // options menu logHelperMessage(INFO,1,"Creating optionmenu"); //images ALLEGRO_BITMAP* optionmenubg = load_image("Images\\Menus\\option\\bg.png"); ALLEGRO_BITMAP* optionmenutitle = load_image("Images\\Menus\\option\\options_title.png"); ALLEGRO_BITMAP* optionmenuresolution_UP = load_image("Images\\Menus\\option\\resolution_up.png"); ALLEGRO_BITMAP* optionmenuresolution_DOWN = load_image("Images\\Menus\\option\\resolution_down.png"); ALLEGRO_BITMAP* optionmenubrightness_UP = load_image("Images\\Menus\\option\\brightness_up.png"); ALLEGRO_BITMAP* optionmenubrightness_DOWN = load_image("Images\\Menus\\option\\brightness_down.png"); ALLEGRO_BITMAP* optionmenuconfig_UP = load_image("Images\\Menus\\option\\configuration_up.png"); ALLEGRO_BITMAP* optionmenuconfig_DOWN = load_image("Images\\Menus\\option\\configuration_down.png"); ALLEGRO_BITMAP* optionmenudifficulty_UP = load_image("Images\\Menus\\option\\dificulty_up.png"); ALLEGRO_BITMAP* optionmenudifficulty_DOWN = load_image("Images\\Menus\\option\\dificulty_down.png"); ALLEGRO_BITMAP* optionmenuback_UP = load_image("Images\\Menus\\option\\back_up.png"); ALLEGRO_BITMAP* optionmenuback_DOWN = load_image("Images\\Menus\\option\\back_down.png"); //function pointers void(*optionmenuresolutionclick)() = &optionsMenuClickResolution; void(*optionmenubrightnessclick)() = &optionsMenuClickBrightness; void(*optionmenuconfigclick)() = &optionsMenuClickConfig; void(*optionmenudificultyclick)() = &optionsMenuClickDificulty; void(*optionmenubackclick)() = &optionsMenuClickBack; //add information to menu menuoptions->addImage(0,0,optionmenubg); menuoptions->addImage(241,21,optionmenutitle); menuoptions->addButton(125,156,optionmenuresolution_UP,optionmenuresolution_DOWN,"resolution",optionmenuresolutionclick); menuoptions->addButton(125,254,optionmenubrightness_UP,optionmenubrightness_DOWN,"brightness",optionmenubrightnessclick); menuoptions->addButton(125,351,optionmenuconfig_UP,optionmenuconfig_DOWN,"config",optionmenuconfigclick); menuoptions->addButton(125,446,optionmenudifficulty_UP,optionmenudifficulty_DOWN,"difficulty",optionmenudificultyclick); menuoptions->addButton(125,546,optionmenuback_UP,optionmenuback_DOWN,"back",optionmenubackclick); getGameRefrence()->registerGameObject(menuoptions);//register menu //menuoverworld menuoverworld = new Menu(); logHelperMessage(INFO,1,"Creating overworldmenu"); //load images ALLEGRO_BITMAP* overworldmenubg = load_image("Images\\Menus\\overworld\\bg.jpg"); ALLEGRO_BITMAP* overworlddung_UP = load_image("Images\\Menus\\overworld\\dng.png"); ALLEGRO_BITMAP* overworlddung1_DOWN = load_image("Images\\Menus\\overworld\\dng1.png"); ALLEGRO_BITMAP* overworlddung2_DOWN = load_image("Images\\Menus\\overworld\\dng2.png"); ALLEGRO_BITMAP* overworlddung3_DOWN = load_image("Images\\Menus\\overworld\\dng3.png"); //asign function pointers void(*overworldmenuclickdung1)() = &overworldMenuClickDung1; void(*overworldmenuclickdung2)() = &overworldMenuClickDung2; void(*overworldmenuclickdung3)() = &overworldMenuClickDung3; //add buttons menuoverworld->addImage(0,0,overworldmenubg); menuoverworld->addButton(107,465,overworlddung_UP,overworlddung1_DOWN,"dung1",overworldMenuClickDung1); menuoverworld->addButton(714,416,overworlddung_UP,overworlddung2_DOWN,"dung2",overworldMenuClickDung2); menuoverworld->addButton(574,323,overworlddung_UP,overworlddung3_DOWN,"dung3",overworldMenuClickDung3); getGameRefrence()->registerGameObject(menuoverworld);//register menu //menumulti menumulti = new Menu(); //TODO: Load multiplayer gui elements getGameRefrence()->registerGameObject(menumulti);//register menu //menuingame menuingame = new Menu(); logHelperMessage(INFO,1,"Creating menuingame "); ALLEGRO_BITMAP* menuingamephpimg = load_image("Images\\Menus\\ingame\\health.png"); ALLEGRO_BITMAP* menuingamepmpimg = load_image("Images\\Menus\\ingame\\mana.png"); ALLEGRO_BITMAP* menuingameplvimg = load_image("Images\\Menus\\ingame\\life.png"); Bounds menuingamephpbounds = Bounds(608,0,192,32); Bounds menuingamepmpbounds = Bounds(416,0,192,32); Bounds menuingameplvbounds = Bounds(0,0,192,32); menuingame->addGauge(menuingamephpimg,menuingamephpbounds,GAUGE_LAYER,10,"PHP"); menuingame->addGauge(menuingamepmpimg,menuingamepmpbounds,GAUGE_LAYER,10,"PMP"); menuingame->addGauge(menuingameplvimg,menuingameplvbounds,GAUGE_LAYER,10,"PLV"); //TODO: load ingamemenu gui elements getGameRefrence()->registerGameObject(menuingame);//register menu //menucutscene menucutscene = new Menu(); //TODO: load cutscene gui elements getGameRefrence()->registerGameObject(menucutscene);//register menu //menu shop menushop = new Menu(); //TODO: load menushot gui elements getGameRefrence()->registerGameObject(menushop);//register menu //menu invintory menuinvintory = new Menu(); ALLEGRO_BITMAP* menuinvintoybg = load_image("Images\\Menus\\invintory\\bg.png"); Bounds menuinvintorybgbounds = Bounds(64,122,672,418); Bounds menuinvintorymoneybounds = Bounds(560,145,0,0); menuinvintory->addImage(menuinvintorybgbounds.getX(),menuinvintorybgbounds.getY(),menuinvintoybg); menuinvintory->addNumber(menuinvintorymoneybounds,"INVMONEY",0); getGameRefrence()->registerGameObject(menuinvintory);//register menu //TODO: load menuinvintory gui elements //menusaveload menusaveload = new Menu(); //TODO: load saveload gui elements getGameRefrence()->registerGameObject(menusaveload);//register menu }