ResourceHolder::ResourceHolder()
{    
    std::list<sf::String> IDList;
    IDList.push_back("Mountains.jpg");
    IDList.push_back("Stickmaniac.png");
    IDList.push_back("BasicIdle.png");
    IDList.push_back("BadAttackAnimation.png");
    IDList.push_back("GetHitAnimation.png");
    IDList.push_back("RollingWheat.png");
    IDList.push_back("cute_image.jpg");
    IDList.push_back("icon.png");
    
    sf::Texture dummy;
    for (auto ID: IDList) {
        textureMap[ID].loadFromFile(resourcePath() + ID);
    }
    
    IDList.clear();
    IDList.push_back("sansation.ttf");
    
    for (auto && ID: IDList) {
        fontMap[ID].loadFromFile(resourcePath() + ID);
    }
    
    IDList.clear();
    IDList.push_back("nice_music.ogg");
    for (auto && ID: IDList) {
        musicMap[ID].openFromFile(resourcePath() + ID);
    }
}
Beispiel #2
0
    int TetrisWindow::create()
    {
        RenderWindow::create(sf::VideoMode(800,600), "Tetris", sf::Style::Close);
        
        // Set the Icon
        sf::Image icon;
        if (!icon.loadFromFile(resourcePath() + "icon.png")) {
            return EXIT_FAILURE;
        }
        this->setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
        

        
        // Create a graphical text to display
        sf::Font font;
        if (!font.loadFromFile(resourcePath() + "sansation.ttf")) {
            return EXIT_FAILURE;
        }
        sf::Text text("Hello SFML", font, 50);
        text.setColor(sf::Color::Black);
        
        // Load a music to play
        sf::Music music;
        if (!music.openFromFile(resourcePath() + "nice_music.ogg")) {
            return EXIT_FAILURE;
        }
        
        // Play the music
        music.play();
        return EXIT_SUCCESS;
    };
Beispiel #3
0
cPlayer::cPlayer(sf::Vector2f pos, bool vertical):
position { pos },
vert { vertical }
{
    if ( vertical )
    {
        shape.setFillColor(sf::Color::White);
        shape.setSize(sf::Vector2f(15, 150));
        shape.setOrigin(7.5, 75);
        
        tex.loadFromFile(resourcePath()+"paddle_vertical.png");
        sprite.setTexture(tex);
        sprite.setOrigin(7.5, 75);
    }
    else
    {
        shape.setFillColor(sf::Color::White);
        shape.setSize(sf::Vector2f(150, 15));
        shape.setOrigin(75, 7.5);
        tex.loadFromFile(resourcePath()+"paddle_horizontal.png");
        sprite.setTexture(tex);
        sprite.setOrigin(75, 7.5);
    }
    
    invBar.setFillColor(sf::Color::Yellow);
    boostBar.setFillColor(sf::Color::Cyan);
    saveBar.setFillColor(sf::Color::Green);
    score = 10;
    
}
Beispiel #4
0
TrackChooserView::TrackChooserView(const Rect& frame) : View(frame) {
    // Get a list of all tracks
    Rac0r::TrackFileManager fileManager;
    tracks = fileManager.getTrackList();
    
    // Load textures
    arrowDownTexture.loadFromFile(resourcePath() + "arrowDown.png");
    arrowUpTexture.loadFromFile(resourcePath() + "arrowUp.png");
    
    // Initialize arrows and the track image
    arrowRight.setTexture(arrowUpTexture);
    arrowRight.rotate(90);
    addChild(arrowRight);
    
    arrowLeft.setTexture(arrowDownTexture);
    arrowLeft.rotate(90);
    addChild(arrowLeft);

    addChild(track);
    
    // Select the first track
    if (tracks.size() > 0) {
        setTrack(0);
    }
    // Calculate the initial layout. However, it will be recalculated whenever View's setSize() is called.
    layoutChildviews();
}
Beispiel #5
0
Application::Application()
: mWindow(sf::VideoMode(640, 480), "Menus", sf::Style::Close)
, mTextures()
, mFonts()
, mPlayer()
, mStateStack(State::Context(mWindow, mTextures, mFonts, mPlayer))
, mStatisticsText()
, mStatisticsUpdateTime()
, mStatisticsNumFrames(0)
{
	mWindow.setKeyRepeatEnabled(false);

	mFonts.load(Fonts::Main, 	resourcePath() + "Sansation.ttf");

	mTextures.load(Textures::TitleScreen,		resourcePath() + "TitleScreen.png");
	mTextures.load(Textures::ButtonNormal,		resourcePath() + "ButtonNormal.png");
	mTextures.load(Textures::ButtonSelected,	resourcePath() + "ButtonSelected.png");
	mTextures.load(Textures::ButtonPressed,		resourcePath() + "ButtonPressed.png");

	mStatisticsText.setFont(mFonts.get(Fonts::Main));
	mStatisticsText.setPosition(5.f, 5.f);
	mStatisticsText.setCharacterSize(10u);

	registerStates();
	mStateStack.pushState(States::Title);
}
Beispiel #6
0
TileMap::TileMap(std::string const pMapFileName)
{
    std::vector<Tile*> tmpMap;
    m_mapFileName = pMapFileName;
    //initialization of the map with empty tiles
    std::ifstream backfile(resourcePath() + "Maps/" + m_mapFileName + "/" + m_mapFileName + "-back.txt");
    if (backfile.is_open()) {
        std::string tileLocation;
        std::getline(backfile, tileLocation);
        
        sf::Image image;
        image.loadFromFile(resourcePath() + tileLocation);
        image.createMaskFromColor(ALPHA_COLOR);
        m_tileTex.loadFromImage(image);
        m_tiles.setTexture(m_tileTex);
        
        while (!backfile.eof()) {
            std::string line, value;
            std::getline(backfile, line);
            std::stringstream stream(line);
            while (std::getline(stream, value, ',')) {
            Tile *tile = new Tile();
                tmpMap.push_back(tile);
            }
            m_map.push_back(tmpMap);
            tmpMap.clear();
        }
    } else
        std::cout << "ERROR : Unable to load the tilemap " + m_mapFileName << std::endl;
    
}
// Creates all the buttons.
void RunManager::createUI() {
    // Creates the button textures from the file path.
    buttonT.loadFromFile(resourcePath() + "Button.png");
    button2T.loadFromFile(resourcePath() + "Button2.png");
    selectorT.loadFromFile(resourcePath() + "FolderSelector.png");
    
    // Sets the sprites to the texture by using an intermediate sprite.
    sf::Sprite encryptButton(button2T);
    this->encryptButton = encryptButton;
    sf::Sprite decryptButton(button2T);
    this->decryptButton = decryptButton;
    sf::Sprite ECBButton(buttonT);
    this->ECBButton = ECBButton;
    sf::Sprite CBCButton(buttonT);
    this->CBCButton = CBCButton;
    sf::Sprite CTRButton(buttonT);
    this->CTRButton = CTRButton;
    
    sf::Sprite encryptFileSelector(selectorT);
    this->encryptFileSelector = encryptFileSelector;
    sf::Sprite decryptFileSelector(selectorT);
    this->decryptFileSelector = decryptFileSelector;
    
    // Sets the respective positions.
    this->encryptButton.setPosition(275, 165);
    this->decryptButton.setPosition(275, 400);
    
    this->ECBButton.setPosition(37.5, 500);
    this->CBCButton.setPosition(337.5, 500);
    this->CTRButton.setPosition(637.5, 500);
    
    this->encryptFileSelector.setPosition(150, 65);
    this->decryptFileSelector.setPosition(150, 300);
}
// Largely same as for buttons.
void RunManager::createText() {
    // Creates fonts from file path.
    buttonFont.loadFromFile(resourcePath() + "typewcond_regular.otf");
    titleFont.loadFromFile(resourcePath() + "sansation.ttf");
    fileSelectorFont.loadFromFile(resourcePath() + "NixieOne.ttf");
    
    // Sets base text that is used to create other texts by setting size, color and font.
    sf::Text blankText;
    blankText.setFont(buttonFont);
    blankText.setCharacterSize(32);
    blankText.setColor(sf::Color::Black);
    
    sf::Text titleText;
    titleText.setFont(titleFont);
    titleText.setColor(sf::Color::Black);
    titleText.setCharacterSize(34);
    
    sf::Text selectorText;
    selectorText.setFont(fileSelectorFont);
    selectorText.setColor(sf::Color::Black);
    selectorText.setCharacterSize(34);
    
    // Sets individual text to base text, sets string and position.
    ECBText = blankText;
    ECBText.setString("ECB");
    ECBText.setPosition(80, 515);
    
    CBCText = blankText;
    CBCText.setString("CBC");
    CBCText.setPosition(380, 515);
    
    CTRText = blankText;
    CTRText.setString("CTR");
    CTRText.setPosition(680, 515);
    
    encryptText = blankText;
    encryptText.setString("Encrypt");
    encryptText.setCharacterSize(52);
    encryptText.setPosition(315, 165);
    
    decryptText = blankText;
    decryptText.setString("Decrypt");
    decryptText.setCharacterSize(52);
    decryptText.setPosition(315, 400);
    
    encryptTitleText = titleText;
    encryptTitleText.setString("Please select the text file that you wish to encrypt.");
    encryptTitleText.setPosition(20, 15);
    
    decryptTitleText = titleText;
    decryptTitleText.setString("Please select the text file that you wish to decrypt.");
    decryptTitleText.setPosition(20, 250);
    
    encryptFileLocationText = selectorText;
    encryptFileLocationText.setPosition(155, 77.5);
    
    decryptFileLocationText = selectorText;
    decryptFileLocationText.setPosition(155, 312.5);
}
Beispiel #9
0
void World::loadTextures()
{
    mTextures.load(Textures::Entities, resourcePath() + TEXTURES + "Entities.png");
    mTextures.load(Textures::Jungle, resourcePath() + TEXTURES + "Jungle.png");
    mTextures.load(Textures::Explosions, resourcePath() + TEXTURES + "Explosion.png");
    mTextures.load(Textures::Particle, resourcePath() + TEXTURES + "Particle.png");
    mTextures.load(Textures::FinishLine, resourcePath() + TEXTURES + "FinishLine.png");
}
Beispiel #10
0
QString AsemanDevices::resourcePathQml()
{
#ifdef Q_OS_ANDROID
    return resourcePath();
#else
    return localFilesPrePath() + resourcePath();
#endif
}
Beispiel #11
0
int main(int, char const**) {
    // Window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Motor City");

    // Icon
    sf::Image icon;
    if (!icon.loadFromFile(resourcePath() + "icon.png")) {
        return EXIT_FAILURE;
    }
    window.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());


    // Background
    sf::Texture texture;
    if (!texture.loadFromFile(resourcePath() + "Background.jpg")) {
        return EXIT_FAILURE;
    }
    sf::Sprite background(texture);
    
    
    // Creating world
    World world;

    // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed) {
                window.close();
            }

            // Escape pressed : exit
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
                window.close();
            }
        }

        // Clear window
        window.clear();
        // Update simulation
        world.update();
        // Draw background
        window.draw(background);
        // Draw simulation
        window.draw(world);

        // Update the window
        window.display();
    }

    return EXIT_SUCCESS;
}
Player::Player(sf::Texture &img, int w, int h, int speed) : Sprite(img, sf::Vector2i(0,0), SOUTH, w, h, speed) {
    life = 4;
    
    no.loadFromFile(resourcePath() + "no.wav");
    hit.loadFromFile(resourcePath() + "hit.wav");
    kiss.loadFromFile(resourcePath() + "kiss.wav");
    heart.loadFromFile(resourcePath() + "heart.png");
    
    CreateAnimations(3);
}
Beispiel #13
0
MainGame::MainGame()
{
    ConfigurationManager configManager(resourcePath() + "configuration.txt");
    
    //if SDL fails, close program
    if (SDL_Init(SDL_INIT_VIDEO)) throw std::logic_error("Failed to initialize SDL!  " + std::string(SDL_GetError()));
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    
    if (configManager.GetItem<bool>("Multisampling"))
    {
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, configManager.GetItem<int>("MultisampleBuffers"));
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, configManager.GetItem<int>("MultisampleSamples"));
    }
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
    SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
    
    SDL_DisplayMode mode; SDL_GetCurrentDisplayMode(0, &mode);
    
    
    Uint32 windowFlags = SDL_WINDOW_OPENGL;
    size_t width = configManager.GetItem<float>("WindowWidth"), height = configManager.GetItem<float>("WindowHeight");
    if (configManager.GetItem<bool>("Fullscreen"))
    {
//        width = mode.w; height = mode.h;
        windowFlags|=SDL_WINDOW_FULLSCREEN_DESKTOP;
    }
    
    
    window = SDL_CreateWindow("Genetic Algorithm", 0, 0, width, height, windowFlags);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetSwapInterval(1);
    SDL_SetRelativeMouseMode(SDL_TRUE);
    if (window==nullptr) throw std::logic_error("Window failed to be initialized");
    SDL_GLContext context = SDL_GL_CreateContext(window);
    if (context==nullptr) throw std::logic_error("SDL_GL could not be initialized!");
    
    int cpuCount = SDL_GetCPUCount();
    
    
    GLManager glManager(resourcePath() + "fragmentShader.glsl", resourcePath() + "vertexShader.glsl", configManager);
    std::string fileLoc =resourcePath() + "performance.csv";
    EvolutionSystem evolutionSystem(fileLoc, configManager, cpuCount);
    Camera camera(configManager.GetItem<float>("WindowWidth"), configManager.GetItem<float>("WindowHeight"), configManager);
    
    while (GameState!=GameState::EXIT)
    {
        Update(evolutionSystem);
        camera.Update();
        glManager.Programs[0].SetMatrix4("transformMatrix", glm::value_ptr(camera.GetTransformMatrix()));
        Draw(evolutionSystem);
        SDL_GL_SwapWindow(window);
        HandleEvents(evolutionSystem,camera);
    }
}
Beispiel #14
0
StagePreview::StagePreview(MenuBarMaker *menuBarMaker)
    : wxFrame(NULL, wxID_ANY, "Preview", wxDefaultPosition, wxDefaultSize,
              wxDEFAULT_FRAME_STYLE & ~ (wxRESIZE_BORDER | wxMAXIMIZE_BOX)) {
  menuBarMaker_ = menuBarMaker;
  menusInitialized_ = false;
  fileManager_ = new FileManager();
  listener_ = 0;
  previewGfxManager_ = new GfxManager(resourcePath(), false);
  stageName_ = 0;

#ifdef __WINDOWS__
  SetIcon(wxIcon(resourcePath() + BERRYBOTS_ICO, wxBITMAP_TYPE_ICO));

  // The 8-9 point default font size in Windows is much smaller than Mac/Linux.
  wxFont windowFont = GetFont();
  if (windowFont.GetPointSize() <= 9) {
    SetFont(windowFont.Larger());
  }
#elif __WXGTK__
  SetIcon(wxIcon(resourcePath() + BBICON_128, wxBITMAP_TYPE_PNG));
#endif

  mainPanel_ = new wxPanel(this);
  infoSizer_ = new wxStaticBoxSizer(wxVERTICAL, mainPanel_);
  descSizer_ = new wxStaticBoxSizer(wxVERTICAL, mainPanel_);

  wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
  mainSizer->Add(mainPanel_, 0, wxEXPAND);
  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);

  wxImage iconImg;
  iconImg.LoadFile(std::string(resourcePath() + BBICON_128).c_str());
  visualPreview_ = new wxStaticBitmap(mainPanel_, wxID_ANY, wxBitmap(iconImg));
  topSizer->Add(visualPreview_, 0, wxALIGN_CENTER);
  topSizer->AddSpacer(8);

  wxBoxSizer *rowSizer = new wxBoxSizer(wxHORIZONTAL);
  rowSizer->Add(infoSizer_, 0, wxEXPAND);
  rowSizer->AddSpacer(4);
  rowSizer->Add(descSizer_, 1, wxEXPAND);
  topSizer->Add(rowSizer, 0, wxEXPAND);

  wxBoxSizer *borderSizer = new wxBoxSizer(wxVERTICAL);
  borderSizer->Add(topSizer, 0, wxALL | wxEXPAND, 12);
  mainPanel_->SetSizerAndFit(borderSizer);
  SetSizerAndFit(mainSizer);

  Connect(this->GetId(), wxEVT_ACTIVATE,
          wxActivateEventHandler(StagePreview::onActivate));
  Connect(this->GetId(), wxEVT_CLOSE_WINDOW,
          wxCommandEventHandler(StagePreview::onClose));

  eventFilter_ = new PreviewEventFilter(this);
  this->GetEventHandler()->AddFilter(eventFilter_);
}
Beispiel #15
0
void game :: init_font(){
    //    char cwd[1024];
    //    if (getcwd(cwd, sizeof(cwd)) != NULL) fprintf(stdout, "Current working dir: %s\n", cwd);
    //    else perror("getcwd() error");
    // profont is 9, 04b is 8
    string fontfilename =
        "ProFontWindows.ttf"
        //"Minecraftia.ttf"
        ,
        fontfilename2 =
        "04B_03.TTF"          // comment either
        //"ProFontWindows.ttf"    // comment either
        ;
    // "slkscr.ttf"
    chsz=9;
    chsz2=8;


    fontfilename = cfg->getstring("font1");
    fontfilename2 = cfg->getstring("font2");
    chsz=cfg->getint("fontsize1");
    chsz2=cfg->getint("fontsize2");

    int overridefont = conf.getint("overridefont");
    switch(overridefont)
    {
        case 1: fontfilename2=fontfilename; chsz2=chsz; break;
        case 2: fontfilename=fontfilename2; chsz=chsz2; break;
        default:break;
    }
    if(!ft.loadFromFile(
    #ifdef __APPLE__
        resourcePath()+
    #endif
        fontfilename.c_str()))
            cout << "could not open " << fontfilename << endl;
        else cout << "successfully loaded " << fontfilename <<endl;

    //if(!ff2.loadFromFile(
    if(!ft2.loadFromFile(
    #ifdef __APPLE__
        resourcePath()+
    #endif
        fontfilename2.c_str()))
            cout << "could not open " << fontfilename2 << endl;
        else cout << "successfully loaded " << fontfilename2 <<endl;

    ((sf::Texture&)ft  .getTexture(chsz)).setSmooth(false);
    ((sf::Texture&)ft2 .getTexture(chsz2)).setSmooth(false);

}
Beispiel #16
0
Player::Player()
{
    width  = 40;
    height = 56;

    texture = new sf::Texture();
    texture->loadFromFile(resourcePath() + "images/player1.png");

    walkingAnimation = new Animation();
    walkingAnimation->setSpriteSheet(*texture);
    walkingAnimation->addFrame(sf::IntRect(0, 2*height, width, height));
    walkingAnimation->addFrame(sf::IntRect(1*width, 2*height, width, height));
    walkingAnimation->addFrame(sf::IntRect(2*width, 2*height, width, height));
    walkingAnimation->addFrame(sf::IntRect(3*width, 2*height, width, height));

    stoppedAnimation = new Animation();
    stoppedAnimation->setSpriteSheet(*texture);
    stoppedAnimation->addFrame(sf::IntRect(0, 2*height, width, height));

    jumpingAnimation = new Animation();
    jumpingAnimation->setSpriteSheet(*texture);
    jumpingAnimation->addFrame(sf::IntRect(0, 2*height, width, height));

    sprite = new AnimatedSprite(sf::seconds(0.2));
    sprite->setAnimation(*stoppedAnimation);
    //sprite->setColor(sf::Color::Red);
    sprite->setOrigin(width/2.f,height/2.f);

    createEntityPhysics(*GameObjects::world, 50, 50, width, height);
}
sf::Sound SoundFileCache::GetSound(std::string soundName) const
{
    std::map<std::string, sf::SoundBuffer*>::iterator itr =
        _sounds.find(soundName);
    if(itr == _sounds.end())
    {
        sf::SoundBuffer *soundBuffer = new sf::SoundBuffer();
        if(!soundBuffer->loadFromFile(resourcePath(soundName)))
        {
            delete soundBuffer;
            throw SoundNotFoundException(
                soundName + " was not found in call to SoundFileCache::GetSound");
        }

        _sounds.insert(std::pair<std::string, sf::SoundBuffer*>
            (soundName,soundBuffer));

        sf::Sound sound;
        sound.setBuffer(*soundBuffer);
        return sound;
    }
    else
    {
        sf::Sound sound;
        sound.setBuffer(*itr->second);
        return sound;
    }

    throw SoundNotFoundException(
        soundName + " was not found in call to SoundFileCache::GetSound");
}
sf::Music* SoundFileCache::GetSong(std::string soundName) const
{
    std::map<std::string,sf::Music*>::iterator itr =
        _music.find(soundName);
    if (itr == _music.end())
    {
        sf::Music* song = new sf::Music();
        if (!song->openFromFile(resourcePath(soundName)))
        {
            delete song;
            throw SoundNotFoundException(
                soundName + " was not found in call to SoundFileCache::GetSong");
        }
        else
        {
            std::map<std::string, sf::Music*>::iterator res =
            _music.insert(std::pair<std::string, sf::Music*>(soundName,song)).first;
            return res->second;
        }
    }
    else
    {
        return itr->second;
    }

    throw SoundNotFoundException(
         soundName + " was not found in call to SoundFileCache::GetSong");
}
sf::Texture* Map::loadTexture(std::string name) {
	sf::Texture* texture = new sf::Texture();
	if (!texture->loadFromFile(resourcePath() + name))
	    return NULL;
	texture->setSmooth(true);
	return texture;
}
Beispiel #20
0
int main()
{
     sf::RenderWindow window(sf::VideoMode(1000, 800), "RoadRunner");
     window.setVerticalSyncEnabled(true);

     int floorWidth = window.getSize().x;

     int blockSize = 200;
     int floorHeightPosition = window.getSize().y - blockSize;

     sf::Texture floorTexture;
     floorTexture.loadFromFile(resourcePath() + "assets/yellow_floor.jpg");
 
     sf::RectangleShape floor[2];

     for (int x = 0; x < 2; x++)
     {
          floor[x].setSize(sf::Vector2f(floorWidth, blockSize));
          floor[x].setTexture(&floorTexture);
          floor[x].setPosition(floorWidth * x, floorHeightPosition);
     }

	while (window.isOpen())
	{
          handleEvent(window);
          update(floor, floorWidth, floorHeightPosition);
          draw(window, floor);
	}

	return 0;
}
MozQWidgetFast::MozQWidgetFast(nsWindow* aReceiver, QGraphicsItem* aParent)
{
  setParentItem(aParent);
  char exePath[MAXPATHLEN];
  QStringList arguments = qApp->arguments();
  nsresult rv =
    mozilla::BinaryPath::Get(arguments.at(0).toLocal8Bit().constData(),
                             exePath);
  if (NS_FAILED(rv)) {
    printf("Cannot read default path\n");
    return;
  }
  char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
  if (!lastSlash ||
      (lastSlash - exePath > int(MAXPATHLEN - sizeof(XPCOM_DLL) - 1))) {
     return;
  }
  strcpy(++lastSlash, "/");
  QString resourcePath(QString((const char*)&exePath) + DRAWABLE_PATH);
  mToolbar.load(resourcePath + TOOLBAR_SPLASH);
  mIcon.load(resourcePath + FAVICON_SPLASH);
  for (int i = 1; i < arguments.size(); i++) {
    QUrl url = QUrl::fromUserInput(arguments.at(i));
    if (url.isValid()) {
      mUrl = url.toString();
    }
  }
}
Beispiel #22
0
bool Game::loadResources() {
    const std::string path = resourcePath();

    _bufHit_01.loadFromFile(path + "hit_ball.wav");
    _bufHit_02.loadFromFile(path + "hit_ball_02.wav");
    _bufHit_03.loadFromFile(path + "hit_ball_03.wav");

    _bufHurt_01.loadFromFile(path + "goal_hurt_03.wav");
    _bufHurt_02.loadFromFile(path + "goal_hurt_02.wav");

    _bufBoostEmpty.loadFromFile(path + "Boost_beep.wav");
    _beepSnd.setBuffer(_bufBoostEmpty);

    _backMus_01.openFromFile(path + "Background_01.ogg");
    _backMus_01.setVolume(75);

    _boostBar2.setSize(sf::Vector2f(400, 50));
    _boostBar2.setPosition(100, 10);
    _boostBar2.setFillColor(sf::Color(0,0,255, 160));

    _boostBar1.setSize(sf::Vector2f(400, 50));
    _boostBar1.setPosition(_window.getSize().x - 500, 10);
    _boostBar1.setFillColor(sf::Color(255,0,0, 160));

    _lifeGoal1.resize(10);
    _lifeGoal2.resize(10);

    return true;
}
Beispiel #23
0
AudioManager::AudioManager()
    : m_fadeInTime      (4.f),
    m_currentFadeTime   (0.f),
    m_fxSounds          (SoundIds::Size),
    m_muted             (false)
{
    std::string resPath("");
    //if it's OS X, prepend the resourcePath
    #ifdef __APPLE__
    resPath = resourcePath();
    #endif
    
    m_musicPlayer.setVolume(0.f);
    m_musicPlayer.play(resPath + "assets/sound/background.ogg", true);

    m_soundPlayer.setVolume(0.f);
    auto files = FileSystem::listFiles(resPath + impactSoundPath);
    for (const auto& file : files)
    {
        if (FileSystem::getFileExtension(file) == ".wav")
        {
            m_impactSounds.emplace_back(sf::SoundBuffer());
            m_impactSounds.back().loadFromFile(resPath + impactSoundPath + file);
        }
    }
    
    m_fxSounds[SwitchFx].loadFromFile(resPath + "assets/sound/switch.wav");
    m_fxSounds[HealthLost].loadFromFile(resPath + "assets/sound/healthlost.wav");
    m_fxSounds[HealthGained].loadFromFile(resPath + "assets/sound/healthgained.wav");
    m_fxSounds[Eating].loadFromFile(resPath + "assets/sound/nomnom.wav");
    m_fxSounds[AteJelly].loadFromFile(resPath + "assets/sound/jelly_eat.wav");
    m_fxSounds[Spawned].loadFromFile(resPath + "assets/sound/player_spawn.wav");
}
Beispiel #24
0
void Texture::load(){
    std::string path = resourcePath() + "image\\shoot.png";
    
    HERO.loadFromFile(path, sf::IntRect(0, 99, 102, 126));
    
    ENEMY.loadFromFile(path, sf::IntRect(534, 612, 57, 43));
    ENEMY_DOWN_1.loadFromFile(path, sf::IntRect(267, 347, 57, 51));
    ENEMY_DOWN_2.loadFromFile(path, sf::IntRect(873, 697, 57, 51));
    ENEMY_DOWN_3.loadFromFile(path, sf::IntRect(267, 296, 57, 51));
    ENEMY_DOWN_4.loadFromFile(path, sf::IntRect(930, 697, 57, 51));
    
    BULLET.loadFromFile(path, sf::IntRect(1004, 987, 9, 21));
    
    SKY.loadFromFile(resourcePath() + "image\\background.png");
	OVER.loadFromFile(resourcePath() + "image\\gameover.png");
}
Beispiel #25
0
int main(int, char const**) {
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    // Set the Icon
    sf::Image icon;
    if (!icon.loadFromFile(resourcePath() + "icon.png")) {
        return EXIT_FAILURE;
    }
    window.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());

    // Create a graphical text to display
    sf::Font font;
    if (!font.loadFromFile(resourcePath() + "sansation.ttf")) {
        return EXIT_FAILURE;
    }
	
	Textbox textbox(window, font);
	textbox.setDimensons(100, 100, 400, 50);
	textbox.setFocus(true);

    // Start the game loop
    while (window.isOpen()) {
        // Process events
        sf::Event event;
        while (window.pollEvent(event)) {
            // Close window: exit
            if(event.type == sf::Event::Closed) {
                window.close();
            }
			bool didHitReturn = textbox.pollEvent(event);
			if(didHitReturn) {
				// do stuff here using textbox.getString()
			}
        }

        // Clear screen
        window.clear();
		
		textbox.draw();

        // Update the window
        window.display();
    }

    return EXIT_SUCCESS;
}
Beispiel #26
0
static void loadTextureImage() {
	BitmapImage * image = NULL;
	
	if (texture != NULL) {
		texture->dispose(texture);
		texture = NULL;
	}
	
	if (jsonPath != NULL) {
		JSONDeserializationContext * context;
		
		context = JSONDeserializationContext_createWithFile(jsonPath);
		texture = GLTexture_deserialize(context);
		if (texture == NULL) {
			fprintf(stderr, "Error: Couldn't load %s as gltexture.json file: %d\n", jsonPath, context->status);
			
		} else {
			char imagePath[PATH_MAX];
			
			if (jsonImagePath == NULL) {
				size_t charIndex;
				
				strncpy(imagePath, jsonPath, PATH_MAX);
				for (charIndex = strlen(imagePath) - 1; charIndex > 0; charIndex--) {
					if (imagePath[charIndex] == '/') {
						charIndex++;
						break;
					}
				}
				strncpy(imagePath + charIndex, texture->imageName, PATH_MAX - charIndex);
				
			} else {
				snprintf(imagePath, PATH_MAX, "%s/%s", jsonImagePath, texture->imageName);
			}
			image = PNGImageIO_loadPNGFile(imagePath, PNG_PIXEL_FORMAT_AUTOMATIC, true);
			if (image == NULL) {
				fprintf(stderr, "Error: Couldn't load %s as gltexture.json file\n", imagePath);
				texture->dispose(texture);
				texture = NULL;
			}
		}
	}
	
	if (texture == NULL) {
		image = PNGImageIO_loadPNGFile(resourcePath(textureImages[textureIndex].fileName), PNG_PIXEL_FORMAT_AUTOMATIC, true);
		texture = GLTexture_create(textureImages[textureIndex].dataFormat,
		                           GL_UNSIGNED_BYTE,
		                           minFilters[minFilterIndex],
		                           magFilters[magFilterIndex],
		                           wrapModes[wrapSModeIndex],
		                           wrapModes[wrapTModeIndex],
		                           autoBlendModes[autoBlendModeIndex],
		                           autoMipmap,
		                           anisotropicFilter);
	}
	
	texture->setImage(texture, 0, image->width, image->height, image->bytesPerRow, image->pixels);
	image->dispose(image);
}
QImage & StatusBarItemInputUrl::image()
{
    if (images_.isEmpty())
    {
        images_.insert(0, QImage(resourcePath()));
    }
    return images_[0];
}
Beispiel #28
0
Platform::Platform()
{
    m_small.loadFromFile(resourcePath() + "data/cloud_s.png");
    m_medium.loadFromFile(resourcePath() + "data/cloud_m.png");
    m_large.loadFromFile(resourcePath() + "data/cloud_l.png");

    m_Ssmall.loadFromFile(resourcePath() + "data/spike_s.png");
    m_Smedium.loadFromFile(resourcePath() + "data/spike_m.png");
    std::srand((unsigned)time(0));

    int tempNum = 700;
    for(int i = 0; i < 500; ++i)
    {
        this->createPlatform(tempNum);
        tempNum -= 150;
    }
}
QImage & StatusBarItemRefreshScreen::image()
{
    if (images_.isEmpty())
    {
        images_.insert(0, QImage(resourcePath()));
    }
    return images_[0];
}
Beispiel #30
0
ball::ball(Score* score1, Score* score2, paddle* player1, paddle* player2)
{
    this->Load("ball.png");
    this->score1 = score1;
    this->score2 = score2;
    this->player1 = player1;
    this->player2 = player2;
    
    this->buffer = new sf::SoundBuffer();
    this->buffer->loadFromFile(resourcePath() + "bounce.wav");
    this->sound = new sf::Sound(*this->buffer);
    
    this->bufferOut = new sf::SoundBuffer();
    this->bufferOut->loadFromFile(resourcePath() + "gametinywarp.wav");
    this->soundOut = new sf::Sound(*this->bufferOut);

}