Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Yemeni Cpluspluser

Pages: [1] 2
1
SFML projects / Re: My proyect: ImageRunner
« on: August 04, 2013, 01:09:07 am »
i was messing with this for atleast an hour. good job

Where did you find the download link, I did not find it in that website.

2
SFML projects / Re: [New project] Uoke's Recovery!
« on: August 04, 2013, 01:08:02 am »
There are several ways to make 1 shooting button instead of left for shooting left and right for shooting right.
use a bool value for that, any way

The other option I was going to take was to use the mouse but I think it plays better with both hands on the keyboard.

Quote
it kind of hard, I could not win level 1 for several attempts.

Where would be the challenge/fun if you could just wizz through each level? ;)

at least make me win lvl 1 so that I can have challenge in 2nd level  :P

3
SFML projects / Re: [New project] Uoke's Recovery!
« on: August 03, 2013, 06:40:56 pm »
There are several ways to make 1 shooting button instead of left for shooting left and right for shooting right.
use a bool value for that, any way it kind of hard, I could not win level 1 for several attempts.

4
General / Re: Changable keys ingame?
« on: August 01, 2013, 11:19:54 pm »
save the key as a variable then tell the user to press the key for example for attack
as you can see each key has a specific value, store that value in your variable


    std::cout << sf::Keyboard::Key::Up;
    int userKeyUp = sf::Keyboard::Key::Up;

   

 
[/s]


its just I am not sure how to know which key pressed to take it to the variable



EDIT : check ahnonay post

5
if (sprite.contains(sf::Mouse::getPosition(mainWindow).x, sf::Mouse::getPosition(mainWindow).y))
{
     std::cout << "Hovered over button!" << std::endl;

     if (sf::Mouse::isButtonPressed(sf::Mouse::Left)
     {
            std::cout << "Button pressed" << std::endl;
     }
}

 :) Thank you for finding it.

6
I got an idea, what if I use a by-pixel checking instead of x and y coordinates .

7
Download link is not working to me.  :-[

That's because the project is dead, heh.

July 18 in the title, is from LAST year, :p

we will be remaking this game, however. Hopefully soon.

 ??? what brought this topic up then lol.
any way you must have now great amount of experience in SFML  ;D.
I hope you upload a project soon.

8
Hello, I am still creating the main game window, I have done creating the click system for new game button, but It does not feels that its a nice method, stick to this method? or there is a better method?

The .exe file with the resource :
http://www.mediafire.com/?bqaskzv951c2bbx 2.6MB

this is the target :
    if( sf::Mouse::isButtonPressed(sf::Mouse::Left)
       && sf::Mouse::getPosition(mainWindow).x >= 12
       && sf::Mouse::getPosition(mainWindow).y >=150
       && sf::Mouse::getPosition(mainWindow).x <= 270
       && sf::Mouse::getPosition(mainWindow).y <= 190
       )

        std::cout << "Clicking on new game";

This is the whole code so far :
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <random>
#include <cstdlib>

int  main()
{
    srand( time(0));
    size_t R, G, B;
    std::cout << "This is the brain of the game, don't think of closing it\nPlease wait the game is loading . . . " << std::endl;
    // declare mainWindow
    sf::RenderWindow mainWindow( sf::VideoMode( 800, 600, 32) , "Hello title" , sf::Style::Close ); // Declare of mainWindow
    mainWindow.setFramerateLimit( 60 );
    std::cout << "Game resolution is : " << mainWindow.getSize().x  << " X " << mainWindow.getSize().y
              << " bits : " << mainWindow.getSettings().depthBits + mainWindow.getSettings().stencilBits << std::endl
              << "Frame per second : 60" << std::endl;
    // declared mainWidow

    // load images into ram
    sf::Image img_SpaceShip;
    if( !img_SpaceShip.loadFromFile( "Resource/img_ship.png" ) )
       std::cout << "Error LFF : Failed to load Resource/img_ship.png" << std::endl;
    else std::cout << "Resource/img_ship.png successfully loaded" << std::endl;

    sf::Texture img_button;
    if ( !img_button.loadFromFile( "Resource/img_button.png" ) )
        std::cout << "Error LFF : Failed to load  Resource/img_button.png" << std::endl;
    else std::cout << "Resource/img_button.png successfully loaded" << std::endl;

    // load sound and music into ram
    sf::Music msnd_intro;
    if( !msnd_intro.openFromFile( "Resource/msnd_intro.ogg") )
        std::cout << "Error OFF : Failed to load Resource/msnd_intro.ogg" << std::endl;
    else std::cout << "Resource/msnd_intro.ogg successfully loaded" << std::endl;
    msnd_intro.setLoop( true );
    msnd_intro.play();

    // loads fonts
    sf::Font font_English;
    if (!font_English.loadFromFile( "Resource/font_English.ttf" ) )
        std::cout << "Error LFF : Failed to load Resource/font_English.ttf" << std::endl;
    else std::cout << "Resource/font_English.ttf successfully loaded" << std::endl;

    // every thing should be loaded

    // declarations

    sf::Text text_MainWindowText ( "SpaceShips 0.01 Alfa", font_English);
    text_MainWindowText.setCharacterSize( 40 );
    text_MainWindowText.setColor( sf::Color::Blue );
    text_MainWindowText.setPosition( 200 , 30 );

    sf::Text text_MainWindowNewGame ( "New Game", font_English);
    text_MainWindowNewGame.setCharacterSize( 30 );
    text_MainWindowNewGame.setColor( sf::Color::Green );
    text_MainWindowNewGame.setPosition( 60 , 150 );

    sf::Text text_MainWindowExit ( "Exit Game", font_English );
    text_MainWindowExit.setCharacterSize( 30 );
    text_MainWindowExit.setColor( sf::Color::Red );
    text_MainWindowExit.setPosition( 60, 200 );

    sf::Sprite spr_ButtonNewGame;
    spr_ButtonNewGame.setTexture( img_button );
    spr_ButtonNewGame.setPosition( 0 , 150 );
    spr_ButtonNewGame.setScale( 1.8 , 1 );

    sf::Sprite spr_ButtonExitGame;
    spr_ButtonExitGame.setTexture( img_button );
    spr_ButtonExitGame.setPosition( 0 , 200 );
    spr_ButtonExitGame.setScale( 1.8 , 1 );

    sf::Sprite spr_SpaceShip;



    // the main game loop
    while ( mainWindow.isOpen() ) // main game loop
    {
        sf::Event mainEvents; // declare of main events checker
        while ( mainWindow.pollEvent( mainEvents ) ); // checking
        {
            switch ( mainEvents.type ) // what event type
            {
            case sf::Event::EventType::Closed: // users clicks X or press Alt-F4
                mainWindow.close(); // close the window
                break;
            }
        }
    // main loop :
    mainWindow.clear( sf::Color( 11,11,11) );
    mainWindow.draw( spr_ButtonNewGame );
    mainWindow.draw( spr_ButtonExitGame );
    mainWindow.draw( text_MainWindowText );

    if( sf::Mouse::isButtonPressed(sf::Mouse::Left)
       && sf::Mouse::getPosition(mainWindow).x >= 12
       && sf::Mouse::getPosition(mainWindow).y >=150
       && sf::Mouse::getPosition(mainWindow).x <= 270
       && sf::Mouse::getPosition(mainWindow).y <= 190
       )

        std::cout << "Clicking on new game";

    R = rand() % 255;
    G = rand() % 255;
    B = rand() % 255;

    text_MainWindowText.setColor( sf::Color ( R, G, B ) );
    mainWindow.draw( text_MainWindowNewGame );
    mainWindow.draw( text_MainWindowExit );
    mainWindow.display();
    //std::cout << sf::Mouse::getPosition(mainWindow).x << " " << sf::Mouse::getPosition(mainWindow).y << std::endl;

    }
    return EXIT_SUCCESS; // returns 0;
}
 

9
Graphics / Re: How to randomly generate sprites
« on: July 31, 2013, 10:59:52 pm »
I am working on my game, trying to do cool stuff lol, here is what I came out with, random color generator

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <random>
#include <cstdlib>

int  main()
{
    srand( time(0));
    size_t R, G, B;
    std::cout << "This is the brain of the game, don't think of closing it\nPlease wait the game is loading . . . " << std::endl;
    // declare mainWindow
    sf::RenderWindow mainWindow( sf::VideoMode( 800, 600, 32) , "Hello title" , sf::Style::Close ); // Declare of mainWindow
    mainWindow.setFramerateLimit( 60 );
    std::cout << "Game resolution is : " << mainWindow.getSize().x  << " X " << mainWindow.getSize().y
              << " bits : " << mainWindow.getSettings().depthBits + mainWindow.getSettings().stencilBits << std::endl
              << "Frame per second : 60" << std::endl;
    // declared mainWidow

    // load images into ram
    sf::Image img_SpaceShip;
    if( !img_SpaceShip.loadFromFile( "Resource/img_ship.png" ) )
       std::cout << "Error LFF : Failed to load Resource/img_ship.png" << std::endl;
    else std::cout << "Resource/img_ship.png successfully loaded" << std::endl;

    sf::Texture img_button;
    if ( !img_button.loadFromFile( "Resource/img_button.png" ) )
        std::cout << "Error LFF : Failed to load  Resource/img_button.png" << std::endl;
    else std::cout << "Resource/img_button.png successfully loaded" << std::endl;

    // load sound and music into ram
    sf::Music msnd_intro;
    if( !msnd_intro.openFromFile( "Resource/msnd_intro.ogg") )
        std::cout << "Error OFF : Failed to load Resource/msnd_intro.ogg" << std::endl;
    else std::cout << "Resource/msnd_intro.ogg successfully loaded" << std::endl;
    msnd_intro.setLoop( true );
    msnd_intro.play();

    // loads fonts
    sf::Font font_English;
    if (!font_English.loadFromFile( "Resource/font_English.ttf" ) )
        std::cout << "Error LFF : Failed to load Resource/font_English.ttf" << std::endl;
    else std::cout << "Resource/font_English.ttf successfully loaded" << std::endl;

    // every thing should be loaded

    // declarations

    sf::Text text_MainWindowText ( "SpaceShips 0.01 Alfa", font_English);
    text_MainWindowText.setCharacterSize( 40 );
    text_MainWindowText.setColor( sf::Color::Blue );
    text_MainWindowText.setPosition( 200 , 30 );

    sf::Text text_MainWindowNewGame ( "New Game", font_English);
    text_MainWindowNewGame.setCharacterSize( 30 );
    text_MainWindowNewGame.setColor( sf::Color::Green );
    text_MainWindowNewGame.setPosition( 60 , 150 );

    sf::Text text_MainWindowExit ( "Exit Game", font_English );
    text_MainWindowExit.setCharacterSize( 30 );
    text_MainWindowExit.setColor( sf::Color::Red );
    text_MainWindowExit.setPosition( 60, 200 );

    sf::Sprite spr_ButtonNewGame;
    spr_ButtonNewGame.setTexture( img_button );
    spr_ButtonNewGame.setPosition( 0 , 150 );
    spr_ButtonNewGame.setScale( 1.8 , 1 );

    sf::Sprite spr_ButtonExitGame;
    spr_ButtonExitGame.setTexture( img_button );
    spr_ButtonExitGame.setPosition( 0 , 200 );
    spr_ButtonExitGame.setScale( 1.8 , 1 );

    sf::Sprite spr_SpaceShip;



    // the main game loop
    while ( mainWindow.isOpen() ) // main game loop
    {
        sf::Event mainEvents; // declare of main events checker
        while ( mainWindow.pollEvent( mainEvents ) ); // checking
        {
            switch ( mainEvents.type ) // what event type
            {
            case sf::Event::EventType::Closed: // users clicks X or press Alt-F4
                mainWindow.close(); // close the window
                break;
            }
        }
    // main loop :
    mainWindow.clear( sf::Color( 11,11,11) );
    mainWindow.draw( spr_ButtonNewGame );
    mainWindow.draw( spr_ButtonExitGame );
    mainWindow.draw( text_MainWindowText );

    R = rand() % 255;
    G = rand() % 255;
    B = rand() % 255;

    text_MainWindowText.setColor( sf::Color ( R, G, B ) );
    mainWindow.draw( text_MainWindowNewGame );
    mainWindow.draw( text_MainWindowExit );
    mainWindow.display();
    }
    return EXIT_SUCCESS; // returns 0;
}
 

Quote
1) All sprites are generated randomly but they all appear at once. They should appear one after the other with a fixed time interval. How do I set that condition?

I would recommend using different variables for each different object for random sprite, as you can see I used 3 sprites, R,G and B;

10
Graphics / Re: sf::Texture texture;
« on: July 31, 2013, 10:55:55 pm »
I thank your eagle eyes  :)
Lesson #1 from SFML users : Don't copy paste. OK!


11
Graphics / [Solved]sf::Texture texture;
« on: July 31, 2013, 10:20:11 pm »
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>

int  main()
{
    std::cout << "This is the brain of the game, don't think of closing it\nPlease wait the game is loading . . . " << std::endl;
    // declare mainWindow
    sf::RenderWindow mainWindow( sf::VideoMode( 800, 600, 32) , "Hello title" , sf::Style::Close ); // Declare of mainWindow
    std::cout << "Game resolution is : " << mainWindow.getSize().x  << " X " << mainWindow.getSize().y
              << " bits : " << mainWindow.getSettings().depthBits + mainWindow.getSettings().stencilBits << std::endl;
    // declared mainWidow

    // load images into ram
    sf::Image img_SpaceShip;
    if( !img_SpaceShip.loadFromFile( "Resource/img_ship.png" ) )
       std::cout << "Error LFF : Failed to load Resource/img_ship.png" << std::endl;
    else std::cout << "Resource/img_ship.png successfully loaded" << std::endl;

    sf::Texture img_button;
    if ( !img_button.loadFromFile( "Resource/img_button.png" ) )
        std::cout << "Error LFF : Failed to load  Resource/img_button.png" << std::endl;
    else std::cout << "Resource/img_button.png successfully loaded" << std::endl;

    sf::Texture img_button2;
    if ( !img_button2.loadFromFile( "Resource/img_button2.png" ) )
        std::cout << "Error LFF : Failed to load  Resource/img_button2.png" << std::endl;
    else std::cout << "Resource/img_button2.png successfully loaded" << std::endl;

    // load sound and music into ram
    sf::Music msnd_intro;
    if( !msnd_intro.openFromFile( "Resource/msnd_intro.ogg") )
        std::cout << "Error OFF : Failed to load Resource/msnd_intro.ogg" << std::endl;
    else std::cout << "Resource/msnd_intro.ogg successfully loaded" << std::endl;
    msnd_intro.setLoop( true );
    msnd_intro.play();

    // loads fonts
    sf::Font font_English;
    if (!font_English.loadFromFile( "Resource/font_English.ttf" ) )
        std::cout << "Error LFF : Failed to load Resource/font_English.ttf" << std::endl;
    else std::cout << "Resource/font_English.ttf successfully loaded" << std::endl;

    // every thing should be loaded

    // declarations

    sf::Text text_MainWindowText ( "SpaceShips 0.01 Alfa", font_English);
    text_MainWindowText.setCharacterSize( 40 );
    text_MainWindowText.setColor( sf::Color::Blue );
    text_MainWindowText.setPosition( 200 , 30 );

    sf::Text text_MainWindowNewGame ( "New Game", font_English);
    text_MainWindowNewGame.setCharacterSize( 30 );
    text_MainWindowNewGame.setColor( sf::Color::Green );
    text_MainWindowNewGame.setPosition( 60 , 150 );

    sf::Text text_MainWindowExit ( "Exit Game", font_English );
    text_MainWindowExit.setCharacterSize( 30 );
    text_MainWindowExit.setColor( sf::Color::Red );
    text_MainWindowExit.setPosition( 60, 200 );

    sf::Sprite spr_ButtonNewGame;
    spr_ButtonNewGame.setTexture( img_button );
    spr_ButtonNewGame.setPosition( 0 , 150 );
    spr_ButtonNewGame.setScale( 1.8 , 1 );

    sf::Sprite spr_buttonExitGame;
    spr_ButtonNewGame.setTexture( img_button2 );
    spr_ButtonNewGame.setPosition( 0 , 200 );
    spr_ButtonNewGame.setScale( 1.8 , 1 );



    // the main game loop
    while ( mainWindow.isOpen() ) // main game loop
    {
        sf::Event mainEvents; // declare of main events checker
        while ( mainWindow.pollEvent( mainEvents ) ); // checking
        {
            switch ( mainEvents.type ) // what event type
            {
            case sf::Event::EventType::Closed: // users clicks X or press Alt-F4
                mainWindow.close(); // close the window
                break;
            }
        }
    // main loop :
    mainWindow.clear( sf::Color( 11,11,11) );
    mainWindow.draw( spr_ButtonNewGame );
    mainWindow.draw( spr_buttonExitGame );
    mainWindow.draw( text_MainWindowText );
    mainWindow.draw( text_MainWindowNewGame );
    mainWindow.draw( text_MainWindowExit );
    mainWindow.display();
    }
    return EXIT_SUCCESS; // returns 0;
}
 

I tried making one texture for 2 sprites failed
then made 2 textures for 2 sprites failed

the problem is that it can only display one sprite at a time, I don't know why.


the difference from sf::Image and sf::Texture it says that that for memory and that for graphics card
so is it because I use sf::texture instead of sf::Image?



don't be hard on me, this is my first project  :P .

12
Graphics / Re: Window.Draw error LNK2001
« on: July 31, 2013, 09:47:13 pm »
Something not related to the question,
I would recommend that you use inline function because you are now calling function each frame that way.  ::)

13
Download link is not working to me.  :-[

14
SFML projects / Re: Linavalanche
« on: July 30, 2013, 10:21:50 pm »
Nice game, I got rank 16 after several attempts :).

15
SFML projects / Re: [Minigame] GoPlanets
« on: July 30, 2013, 07:24:54 pm »
Very fun and exciting, I played it for 16 minutes ^_^

Pages: [1] 2
anything