void President::initializeImages(std::string &path) { ResourceHandler* handler = ResourceHandler::getInstance(); mTexture = &handler->getTexture(path); mPortrait.setTexture(*mTexture); mClickedPortraitTexture = &handler->getTexture("PickedLeaders/president-" + mName + "-picked"); }
Button::Button(ResourceHandler &handler, sf::RectangleShape &rect, std::string textureName, std::string hoverName): mTextureName(textureName), mRect(rect), mHoverRect(rect), mMoveToPosition(rect.getPosition().x, rect.getPosition().y), mDirection(0, 0), mIsOnPosition(true), mSpeed(100), mMode(RectangleShape) { mRect.setTexture(handler.getTexture(textureName)); mHoverRect.setTexture(handler.getTexture(hoverName)); }
//Creates a sprite representing a button Button::Button(ResourceHandler &handler, sf::Vector2f &pos, string textureName): mTextureName(textureName), mMoveToPosition(pos), mDirection(0, 0), mIsOnPosition(true), mSpeed(100), mMode(Texture) { mSprite.setTexture(*handler.getTexture(textureName)); mSprite.setPosition(pos); }
//Creates a sprite representing a button Button::Button(ResourceHandler &handler, float x, float y, string textureName): mTextureName(textureName), mMoveToPosition(x, y), mDirection(0, 0), mIsOnPosition(true), mSpeed(100), mMode(Texture) { mSprite.setTexture(*handler.getTexture(textureName)); mSprite.setPosition(x, y); }
RiddleSpider::RiddleSpider(ResourceHandler &handler, sf::Vector2f position) : mPosition(position), mState(INACTIVE), mMoveTimer(0), mActiveTimer(0), mTextCounter(-1), mTexts() { mSprite.setTexture(*handler.getTexture("RiddleSpider.png")); mSprite.setPosition(position); mFont.loadFromFile("Resources/Fonts/Lora-Regular.ttf"); }
Cursor::Cursor(ResourceHandler &handler) : mode(NORMAL) { mNormalMouse = *handler.getTexture("mousecursor.png"); mEyeMouse = *handler.getTexture("eyecursor.png"); mOpenHandMouse = *handler.getTexture("openhand.png"); mClosedHandMouse = *handler.getTexture("closedhand.png"); mSpeechMouse = *handler.getTexture("speechbubble.png"); mSceneChangeMouse = *handler.getTexture("scenechangecursor.png"); mMouseCursor.setTexture(mNormalMouse); mMouseCursor.setScale(sf::Vector2f(0.2f, 0.2f)); }
void Level2::toggleActive(ResourceHandler &handler, sf::RenderWindow &window, UI *ui) { if (!mIsActive) { handler.loadLevel2(window); //Default bool values mItemInteraction = false; mLevelComplete = false; mMouseReleased = false; mAutoDialogueTriggered = false; mTalkedToArnold = false; mSteamMachineWorking = false; mActiveScene = 0; //Room Textures //Background texture background.setSize(sf::Vector2f(1520, 576)); background.setTexture(handler.getTexture("Workshop.png")); //Playground texture /*playground.setSize(sf::Vector2f(1024, 576)); playground.setTexture(handler.getTexture("thomaspg.png"));*/ //Foreground texture /*foreground.setSize(sf::Vector2f(1024, 576)); foreground.setTexture(handler.getTexture("thomasfg.png"));*/ // Zoom Textures //Background Zoom texture /*backgroundZoom.setSize(sf::Vector2f(1024, 576)); backgroundZoom.setTexture(handler.getTexture("thomaszoombg.png"));*/ //Playground Zoom texture /*playgroundZoom.setSize(sf::Vector2f(1024, 576)); playgroundZoom.setTexture(handler.getTexture("thomaszoompg.png"));*/ //Foreground Zoom texture /*foregroundZoom.setSize(sf::Vector2f(1024, 576)); foregroundZoom.setTexture(handler.getTexture("thomaszoomfg.png"));*/ //Help rectangles rectangleSteamMachine.setPosition(sf::Vector2f(683, 189)); rectangleSteamMachine.setSize(sf::Vector2f(90, 50)); rectangleVise.setPosition(sf::Vector2f(963, 203)); rectangleVise.setSize(sf::Vector2f(60, 40)); rectangleDrawer.setPosition(sf::Vector2f(1270, 330)); rectangleDrawer.setSize(sf::Vector2f(100, 100)); rectangleBicycle.setPosition(sf::Vector2f(150, 219)); rectangleBicycle.setSize(sf::Vector2f(200, 100)); rectangleComputer.setPosition(sf::Vector2f(1440, 275)); rectangleComputer.setSize(sf::Vector2f(100, 100)); rectanglePosters.setPosition(sf::Vector2f(1400, 95)); rectanglePosters.setSize(sf::Vector2f(110, 140)); rectangleToolwall.setPosition(sf::Vector2f(813, 47)); rectangleToolwall.setSize(sf::Vector2f(200, 130)); //Sound/music /*music.openFromFile(handler.getMusic("Level1Music.ogg")); music.setLoop(true); music.setVolume(10); music.play();*/ /*mAmbientSound.setBuffer(*handler.getSound("Level1_Ambience.ogg")); mAmbientSound.setLoop(true); mAmbientSound.setVolume(10); mAmbientSound.play();*/ mCriticalItemSound.setBuffer(*handler.getSound("Critical_Item.ogg")); mCriticalItemSound.setVolume(70); mRegularItemSound.setBuffer(*handler.getSound("Regular_Item_Pickup.ogg")); mMenuMainUISound.setBuffer(*handler.getSound("Menu_MainUI.ogg")); mMenuHatSound.setBuffer(*handler.getSound("Menu_Hat.ogg")); mMenuInventorySound.setBuffer(*handler.getSound("Menu_Inventory.ogg")); music.openFromFile(handler.getMusic("Level2Music.ogg")); music.setLoop(true); music.setVolume(50); music.play(); //View mView.setCenter(512, 288); mView.setSize(1024, 576); //Player mPlayer = new Player(handler, sf::Vector2f(414, 342)); //Inventory mInventory = new Inventory(handler); mInventory->setCraftableItems(handler, 1); //DialogueSystem mDialogueSystem = new DialogueSystem(handler, 1); //Mouse Cursor mCursor = new Cursor(handler); //Menu mUI = ui; //TODO - Test mUI** and &ui if not working //Clues mClues = new Clue(handler, "ClueBackground1.png"); /*mClues->add(handler, "Clue1First.png", sf::Vector2f(58, 31)); mClues->getClue(0)->setStrings("Jag måste hitta en stjärna, en \nastronaut, och en skruvmakapär.", ""); mClues->getClue(0)->setState1(); mClues->add(handler, "thomasstar.png", sf::Vector2f(210, 185)); mClues->getClue(1)->setStrings("Först måste jag hitta stjärnan.", "Jag hittade stjärnan på golvet!"); mClues->getClue(1)->setState1(); mClues->add(handler, "thomasastronaut.png", sf::Vector2f(405, 80)); mClues->getClue(2)->setStrings("Nu måste jag hitta astronauten.", "Astronauten är i akvariumet \nmen jag måste fiska upp den!"); mClues->add(handler, "Clue1Aqua.png", sf::Vector2f(610, 70)); mClues->getClue(3)->setStrings("Jag måste hitta något att fiska \nupp astronauten med.", "Med magnetfiskaren kan jag få \ntag i astronauten!"); mClues->add(handler, "FishingRodMagnet.png", sf::Vector2f(710, 260)); mClues->getClue(4)->setStrings("Nu måste jag bara fiska upp \nastronauten också.", "Astronauten har blivit hittad!"); mClues->add(handler, "ScrewDeviceINV.png", sf::Vector2f(800, 400)); mClues->getClue(5)->setStrings("Var kan nu skruvmakapären \nvara?", "Äntligen! Skruvmakapären är \nhittad!"); mClues->add(handler, "InfoIcon.png", sf::Vector2f(280, 450)); mClues->getClue(6)->setStrings("Detta är ledtrådskartan. \nHär kan du läsa vad du har gjort \nhittills och vad du bör göra \nhärnäst. Bara håll musen över \nen ledtråd för att läsa den. \nPilarna låter dig se ledtrådar \nför banor du tidigare klarat.", ""); mClues->getClue(6)->setState1();*/ //Create Items mCable = new Item(handler, sf::Vector2f(595, 165), "Cable"); mAirbag = new Item(handler, sf::Vector2f(74, 321), "Airbag"); mFilledBalloon = new Item(handler, sf::Vector2f(74, 321), "FilledBalloon"); //Invisible/Not Active, get from Steam Machine mJuice = new Item(handler, sf::Vector2f(74, 321), "Juice"); //Invisible/Not Active, get from Arnold mGlove = new Item(handler, sf::Vector2f(895, 226), "Glove"); mKey = new Item(handler, sf::Vector2f(1170, 45), "Key"); //Invisible, get from Birdnest mWorkshopStick = new Item(handler, sf::Vector2f(1058, 120), "WorkshopStick"); mCloth = new Item(handler, sf::Vector2f(805, 225), "Cloth"); mCan = new Item(handler, sf::Vector2f(1330, 112), "Can"); //Invisible/Not Active, get from Putte mPutte = new Item(handler, sf::Vector2f(1330, 112), "Putte"); mArnold = new Item(handler, sf::Vector2f(480, 165), "Arnold"); mSteamMachine = new Item(handler, sf::Vector2f(683, 189), "SteamMachine"); mVise = new Item(handler, sf::Vector2f(963, 203), "Vise"); mDrawer = new Item(handler, sf::Vector2f(1270, 330), "Drawer"); //Item Glow /*mAstronautGlow.setTexture(*handler.getTexture("AstronautGlow.png")); mAstronautGlow.setPosition(477, 287); mAstronautGlow.setScale(0.7f, 0.7f);*/ //Playground rectangles mPlayRects.push_back(createRect(295, 334, 940, 224)); mPlayRects.push_back(createRect(1255, 430, 135, 127)); //Add Rects here ////Steam machine //mRects.push_back(createRect(683, 189, 90, 50)); ////Vise //mRects.push_back(createRect(963, 203, 60, 40)); ////Drawer //mRects.push_back(createRect(1270, 330, 100, 100)); //Bicycle mRects.push_back(createRect(150, 219, 200, 100)); //Computer mRects.push_back(createRect(1440, 275, 100, 100)); //Posters mRects.push_back(createRect(1400, 95, 110, 140)); //Toolwall mRects.push_back(createRect(813, 47, 200, 130)); //Scenechange //mRects.push_back(createRect(963, 203, 60, 40)); //Items - Set as Active, Pickupable, Interactable mCable->toggleActive(); mCable->togglePickupable(); mAirbag->toggleActive(); mAirbag->togglePickupable(); mGlove->toggleActive(); mGlove->togglePickupable(); mKey->toggleActive(); mKey->togglePickupable(); mWorkshopStick->toggleActive(); mWorkshopStick->togglePickupable(); mCloth->toggleActive(); mCloth->togglePickupable(); mPutte->toggleActive(); mArnold->toggleActive(); //TODO - Toggle later instead? mSteamMachine->toggleActive(); mVise->toggleActive(); mDrawer->toggleActive(); mDrawer->toggleInteractable(); //Add to ItemVector addItem(mCable); addItem(mAirbag); addItem(mGlove); addItem(mKey); addItem(mWorkshopStick); addItem(mCloth); addItem(mPutte); addItem(mArnold); addItem(mSteamMachine); addItem(mVise); addItem(mDrawer); } else { delete mPlayer; delete mInventory; delete mDialogueSystem; delete mClues; mItems.clear(); mRects.clear(); mPlayRects.clear(); mUI->setActiveAnimation("None"); //TODO - Add Volume Fadeout? music.stop(); mAmbientSound.stop(); } mIsActive = !mIsActive; }
void Level1::toggleActive(ResourceHandler &handler, sf::RenderWindow &window, UI *ui) { if (!mIsActive) { handler.loadLevel1(window); //Default bool values mItemInteraction = false; mPickedUpFishingRod = false; mPickedUpMagnet = false; mLookedAtAquarium = false; mPushingBlock = false; mBlockPushed = false; mCubePlaced = false; mReadyForScrewdevice = false; mPickedUpScrewdevice = false; mMovedStar = false; mReadyToLeave = false; mLevelComplete = false; mHasCraftedFishingRod = false; mMouseReleased = false; mLookedAtBooks = false; mLookedAtLamp = false; mLookedAtRadio = false; mLookedAtPosters = false; mLookedAtBackpack = false; mActiveScene = 0; //Room Textures //Background texture background.setSize(sf::Vector2f(1024, 576)); background.setTexture(handler.getTexture("thomasbg.png")); //Playground texture playground.setSize(sf::Vector2f(1024, 576)); playground.setTexture(handler.getTexture("thomaspg.png")); //Foreground texture foreground.setSize(sf::Vector2f(1024, 576)); foreground.setTexture(handler.getTexture("thomasfg.png")); // Zoom Textures //Background Zoom texture backgroundZoom.setSize(sf::Vector2f(1024, 576)); backgroundZoom.setTexture(handler.getTexture("thomaszoombg.png")); //Playground Zoom texture playgroundZoom.setSize(sf::Vector2f(1024, 576)); playgroundZoom.setTexture(handler.getTexture("thomaszoompg.png")); //Foreground Zoom texture foregroundZoom.setSize(sf::Vector2f(1024, 576)); foregroundZoom.setTexture(handler.getTexture("thomaszoomfg.png")); //Help rectangles rectangle.setPosition(sf::Vector2f(440, 150)); rectangle.setSize(sf::Vector2f(215, 200)); //Sound/music music.openFromFile(handler.getMusic("Level1Music.ogg")); music.setLoop(true); music.setVolume(10); music.play(); mAmbientSound.setBuffer(*handler.getSound("Level1_Ambience.ogg")); mAmbientSound.setLoop(true); mAmbientSound.setVolume(10); mAmbientSound.play(); mAquariumSound.setBuffer(*handler.getSound("Aquarium.ogg")); mAquariumSound.setLoop(true); mAquariumSound.setVolume(0); mAquariumSound.play(); mCriticalItemSound.setBuffer(*handler.getSound("Critical_Item.ogg")); mCriticalItemSound.setVolume(70); mRadioSound.setBuffer(*handler.getSound("Radio_Noise.ogg")); mMagnetCatchSound.setBuffer(*handler.getSound("Magnet_Catch.ogg")); mMagnetDropSound.setBuffer(*handler.getSound("Magnet_Drop.ogg")); mPushingObjectSound.setBuffer(*handler.getSound("Pushing_Object.ogg")); mRegularItemSound.setBuffer(*handler.getSound("Regular_Item_Pickup.ogg")); mMenuMainUISound.setBuffer(*handler.getSound("Menu_MainUI.ogg")); mMenuHatSound.setBuffer(*handler.getSound("Menu_Hat.ogg")); mMenuInventorySound.setBuffer(*handler.getSound("Menu_Inventory.ogg")); //View mView.setCenter(512, 288); mView.setSize(1024, 576); //Player mPlayer = new Player(handler, sf::Vector2f(705, 500)); //Inventory mInventory = new Inventory(handler); mInventory->setCraftableItems(handler, 0); //DialogueSystem mDialogueSystem = new DialogueSystem(handler, 0); mDialogueSystem->setLevel1Start(); //Mouse Cursor mCursor = new Cursor(handler); mCursor->setMode(Cursor::DIALOGUE); //Menu mUI = ui; //TODO - Test mUI** and &ui if not working //Clues mClues = new Clue(handler, "ClueBackground1.png"); mClues->add(handler, "Clue1First.png", sf::Vector2f(58, 31)); mClues->getClue(0)->setStrings("Jag måste hitta en stjärna, en \nastronaut, och en skruvmakapär.", ""); mClues->getClue(0)->setState1(); mClues->add(handler, "thomasstar.png", sf::Vector2f(210, 185)); mClues->getClue(1)->setStrings("Först måste jag hitta stjärnan.", "Jag hittade stjärnan på golvet!"); mClues->getClue(1)->setState1(); mClues->add(handler, "thomasastronaut.png", sf::Vector2f(405, 80)); mClues->getClue(2)->setStrings("Nu måste jag hitta astronauten.", "Astronauten är i akvariumet \nmen jag måste fiska upp den!"); mClues->add(handler, "Clue1Aqua.png", sf::Vector2f(610, 70)); mClues->getClue(3)->setStrings("Jag måste hitta något att fiska \nupp astronauten med.", "Med magnetfiskaren kan jag få \ntag i astronauten!"); mClues->add(handler, "FishingRodMagnet.png", sf::Vector2f(710, 260)); mClues->getClue(4)->setStrings("Nu måste jag bara fiska upp \nastronauten också.", "Astronauten har blivit hittad!"); mClues->add(handler, "ScrewDeviceINV.png", sf::Vector2f(800, 400)); mClues->getClue(5)->setStrings("Var kan nu skruvmakapären \nvara?", "Äntligen! Skruvmakapären är \nhittad!"); mClues->add(handler, "InfoIcon.png", sf::Vector2f(280, 450)); mClues->getClue(6)->setStrings("Detta är ledtrådskartan. \nHär kan du läsa vad du har gjort \nhittills och vad du bör göra \nhärnäst. Bara håll musen över \nen ledtråd för att läsa den. \nPilarna låter dig se ledtrådar \nför banor du tidigare klarat.", ""); mClues->getClue(6)->setState1(); //Spooky scary spider mSpider = new RiddleSpider(handler, sf::Vector2f(750, -500)); //Create Items mScrewdevice = new Item(handler, sf::Vector2f(380, 400), "Screwdevice"); mMagnet = new Item(handler, sf::Vector2f(325, 270), "Magnet"); mStar = new Item(handler, sf::Vector2f(475, 435), "Star"); mAstronaut = new Item(handler, sf::Vector2f(560, 160), "Astronaut"); mBlock = new Item(handler, sf::Vector2f(570, 160), "Block"); mString = new Item(handler, sf::Vector2f(250, 370), "String"); mBowl = new Item(handler, sf::Vector2f(320, 158), "Bowl"); mCube = new Item(handler, sf::Vector2f(352, 222), "Cube"); mWallStar = new Item(handler, sf::Vector2f(900, 190), "WallStar"); mRoger = new Item(handler, sf::Vector2f(530, 150), "Roger"); //Item Glow mAstronautGlow.setTexture(*handler.getTexture("AstronautGlow.png")); mAstronautGlow.setPosition(477, 287); mAstronautGlow.setScale(0.7f, 0.7f); //Playground rectangles mPlayRects.push_back(createRect(110, 360, 610, 200)); mPlayRects.push_back(createRect(670, 330, 160, 80)); //Fishtank, Zoom mRects.push_back(createRect(440, 150, 215, 200)); //Books in bookcase mRects.push_back(createRect(200, 50, 100, 200)); //Lamp mRects.push_back(createRect(75, 165, 50, 100)); //Radio mRects.push_back(createRect(10, 245, 50, 60)); //Posters mRects.push_back(createRect(410, 20, 260, 120)); //Backpack mRects.push_back(createRect(750, 420, 50, 70)); //Rug mRects.push_back(createRect(380, 400, 40, 40)); //Door mRects.push_back(createRect(690, 50, 150, 275)); //Items - Set as Active, Pickupable, Interactable mScrewdevice->toggleActive(); mMagnet->toggleActive(); mMagnet->togglePickupable(); mStar->toggleActive(); mStar->toggleInteractable(); mBlock->toggleActive(); mString->toggleActive(); mString->togglePickupable(); mBowl->toggleActive(); mCube->toggleActive(); mWallStar->toggleIsLookedAt(); mRoger->toggleActive(); mRoger->toggleIsLookedAt(); mRoger->setActiveAnimation("RogerSwim"); mRoger->moveToPosition(470, 150); mRoger->setSpeed(10.0f); //Add to ItemVector addItem(mMagnet); addItem(mStar); addItem(mBlock); addItem(mAstronaut); addItem(mString); addItem(mBowl); addItem(mCube); addItem(mRoger); mUI->setActiveAnimation("CluesIconGlow"); } else { delete mPlayer; delete mInventory; delete mDialogueSystem; delete mClues; mItems.clear(); mRects.clear(); mPlayRects.clear(); mUI->setActiveAnimation("None"); //TODO - Add Volume Fadeout? music.stop(); mAmbientSound.stop(); mAquariumSound.stop(); } mIsActive = !mIsActive; }