Beispiel #1
0
screen_1::screen_1(void)
{
    // Loads in spritesheet
    texture1.loadFromFile( resourcePath() + "spritesheet.png");
    texture2.loadFromFile( resourcePath() + "vehicles.png");
    texture3.loadFromFile( resourcePath() + "timer.png" );
    hearts.loadFromFile( resourcePath() + "hearts.png");
    
    // *******************************************************************
    // Sets texture to sprites, scale, and pos
    //
    // Create(sf::Sprite &sprite, sf::IntRect &rect, sf::Texture &texture, int left, int top, int width,
    //          int height, double sizeX, double sizeY, double posX, double posY)
    // *******************************************************************
    Create t1(truck, rectSourceSprite, texture2, 0, 24, 130, 73, 1.5, 1.5, 130, 420);
    Create t2(truck2, rectSourceSprite, texture2, 148, 0, 120, 159, 1.5, 1.5, 550, 290);
    Create c1(car, rectSourceSprite, texture2, 310, 0, 146, 149, 1.7, 1.7, -230, 420);
    Create c2(car2, rectSourceSprite, texture2, 460, 0, 146, 149, 1.7, 1.7, 280, 289);
    Create c3(car3, rectSourceSprite, texture2, 460, 0, 146, 149, 1.7, 1.7, 0, 289);
    Create s1(shortLog, rectSourceSprite, texture1, 289, 0, 146, 196, 1, 1, 0, 129);
    Create s2(shortLog2, rectSourceSprite, texture1, 435, 0, 141, 196, 1, 1, 200, 65);
    Create s3(shortLog3, rectSourceSprite, texture1, 289, 0, 146, 196, 1, 1, 300, 8);
    Create l1(longLog, rectSourceSprite, texture1, 577, 0, 205, 196, 1, 1, 799, 8.3);
    Create l2(longLog2, rectSourceSprite, texture1, 577, 0, 205, 196, 1, 1, 500, 138);
    Create leaf(lillypad, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 0, -32);
    Create leaf2(lillypad2, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 167.5, -32);
    Create leaf3(lillypad3, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 335, -32);
    Create leaf4(lillypad4, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 502.5, -32);
    Create leaf5(lillypad5, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 670, -32);

    Create hearts123(life, rectSource, hearts, 0, 0, 116, 30, 1, 1, 10, 600);
    
    //Player ( aka stats )
    mainPlayer.setNumLives(3);
    mainPlayer.setIsHit(false);
    
    // Frogger Sprite
    Create grogger(frogger, rectSourceSprite, texture1, 0, 70, 75, 70, 1, 1, 320, 605);

    // Sets texture to frogs that will go on occupied lilypads
    occupied1.setTexture(texture1);
    occupied1.setTextureRect(rectSourceSprite);
    occupied2.setTexture(texture1);
    occupied2.setTextureRect(rectSourceSprite);
    occupied3.setTexture(texture1);
    occupied3.setTextureRect(rectSourceSprite);
    occupied4.setTexture(texture1);
    occupied4.setTextureRect(rectSourceSprite);
    occupied5.setTexture(texture1);
    occupied5.setTextureRect(rectSourceSprite);
    
    // Sets pos of above frogs
    occupied1.setPosition(-100, -100);
    occupied2.setPosition(-100, -100);
    occupied3.setPosition(-100, -100);
    occupied4.setPosition(-100, -100);
    occupied5.setPosition(-100, -100);
    death.setPosition(-100, -100);
    
    // Timer Rect
    timeRect.left = 297;
    timeRect.top = 43;
    timeRect.width = 143;
    timeRect.height = 14;
    timer.setScale(1.5, 1.5);
    timer.setTexture(texture3, true);
    timer.setTextureRect(timeRect);
    timer.setPosition(10, 648);
    
    // Loads Background Pic
    bg.loadFromFile( resourcePath() + "background.jpg" );
    background.setTexture(bg, true);
    
    // Log Checking
    isOnLog = false;
    isOnLog2 = false;
    isOnLog3 = false;
    isOnLog4 = false;
    isOnLog5 = false;
    
    // Lily Checking
    isOnLily = false;
    isOnLily2 = false;
    isOnLily3 = false;
    isOnLily4 = false;
    isOnLily5 = false;
    
    froggerLanded = false;
    
    // Frogger Theme
    if (!froggerTheme.openFromFile(resourcePath() + "froggerLeche_Remix.ogg"))
        return -1; // error
    froggerTheme.setLoop(true);
    
    // Hop Sound
    if (!hopFile.loadFromFile(resourcePath() + "froggerHop.ogg"))
        return -1;
    
    // Coin Sound
    if (!intro.openFromFile(resourcePath() + "froggerCoin.ogg"))
        return -1;
    
    // Trucked
    if (!truckedFile.loadFromFile(resourcePath() + "froggerTrucked.ogg"))
        return -1;
    
    // Dunked
    if (!dunkedFile.loadFromFile(resourcePath() + "froggerDunked.ogg"))
        return -1;
}
void mid3() { leaf3(); }