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.


Topics - easy

Pages: [1]
1
General / On Screen Display
« on: July 26, 2014, 02:15:45 pm »
Dear people!

I'm looking for a solution to draw texts or images as an omnipresent borderless, full screen window on the top of every window in Windows 7. I'd need to pass every event to the windows underneath, as if wasn't even there. The user should be able to see every windows beneath, as normally.

I'm wondering if it is possible to do this with SFML?

Thanks for your answers in advance!

Cheers,
easy

Edited to make it more clear what I'd like to achieve.

2
Feature requests / SFML on IndieDB?
« on: September 23, 2011, 10:25:49 am »
Hi!

This is - again - not an engine-related feature request from me. I've registered my game on IndieDB, and I've seen that SFML is not listed there as a game engine (yes, I know SFML is not only for games).

IndieDB + ModDB + Desura has about 500,000 memebers, so it might worth registering the engine there.

I also can do it for you, if you'd like me to do it, but it would be even better if you could do it, since SFML is your baby. :)

Cheers,
easy

3
Audio / Free music resources?
« on: September 22, 2011, 01:13:41 pm »
This is probably not the best forum to post this question, but I'm curious if you can point me to a website where I could find quality free musics for my game?

I'm going to use them non-commercially, and credit all the authors.

I'm currently registered on Freesounds.org, but you might have better ideas! Thanks!

4
Audio / Problems on Windows XP with SFML2 audio
« on: September 22, 2011, 11:08:05 am »
Hi!

I've got some Windows XP related problems.

The same version of SFML2 was compiled and installed on Windows XP and on Linux with no problems.

I have compiled my game on Windows, and added the neccessary .dlls: libsndfile-1.dll and openal32.dll, along with the sfml dlls.


A) First of all, it did not load any of my .ogg files (so I have later converted them to .wav). The output of the console was:



Here's a 'corrupt' sound file:

https://legacy.sfmluploads.org/file/65

This only happens on Windows, on Linux it's just fine.
Note that this particular problem was on VirtulaBox!


B) Still on VirtulaBox, sounds are converted to .wav, works both on Windows and on Linux, but on Windows, exiting the program throws this:




C) On a real (non-VirtualBox) Windows XP, starts up fine, but there's no sound. Console output: "Failed to open the audio device". It does not crash on exit as in B).


The most important part for me is part C) the audio not playing on Windows.
Can you help me?

Thanks in advance,
easy

5
General / How to link SFML2 statically on Linux
« on: September 19, 2011, 11:29:55 am »
The title sums it up. I've tried to link SFML2 statically, but there are errors.

I've compiled the static libraries, they're at "/usr/local/lib/", the includes are at "/usr/local/include/SFML", the project settings are configured to use "/usr/local/lib/libsfml-audio-s.a; /usr/local/lib/libsfml-graphics-s.a; /usr/local/lib/libsfml-window-s.a; /usr/local/lib/libsfml-system-s.a", and I've even added "SFML-STATIC" flag to #defines.

I'm using Code::Blocks, on Linux Mint Debian.

Build log: https://legacy.sfmluploads.org/code/104

Bild messages: https://legacy.sfmluploads.org/code/105

What am I missing?

6
SFML projects / Pacaman [Demo]
« on: September 04, 2011, 11:05:47 pm »
Hello fellas!

Here's what I'm working on since I've joined the SFML community (copied from readme.txt):


Pacaman is a free, open source Pac-Man like game-and-tutorial project in one that uses SFML (Simple and Fast Media Library). "Paca" means splotch in Hungarian.


Project goal:

The goal is to make a proof-of-concept game with educational purposes, that has a more complex source code than the standard pong example that comes with the SFML libraries. The source code was created in a (relatively) nice coding style with a lot of comments to ease understanding.


Screenshots:

Single player mode:


Cooperative mode:



More info & downloads:

Download the game from Pacaman website and leave a comment! Thanks! :)

Cheers,
easy

7
General / How to code nicely with SFML?
« on: August 24, 2011, 05:46:35 pm »
Hello!

I've got concerns about the my current game code. It's going to be a simple game but with educative code inside, a proof-of-concept. It's more advanced than the provided pong example, so I needed to separate objects.

Currently I've got a bunch of .h and .cpp files:
    CAnimator - an animator class for animating sprites,
    CCamera - manages cameras for one or two players,
    CEntity - handles the players, monsters,
    CInterface - all the GUI stuff is in here,
    CLevel - manages the level related stuff,
    CGame - groups all these togther, [/list]

    It all works fine, and shaping up really nicely, but there are some things I don't like about it:
      - It's half this and half that: SFML has references all around, and my classes use pointers (the actual example below does not actually show the pointers)
      - Due to the SFML design, I'm not passing pointers but references to the constructors, which enforces me to initalize them on startup... which is exxxtremely restrictive
      - I like the clean design of SFML but I seem to not understand some basic concepts here... I'm a pointer-user guy


    For example, look at the following piece of code. You can see the animator  and the entity class constructors. Since the entity has 2 animators, I have to initiate them in the constructor. And the dependencies would grow from class to class.

    Code: [Select]
    //! Constructor
    CAnimator(sf::RenderWindow& Window, sf::Texture& Texture, int TileSize, sf::Sprite& Sprite,
              const SAnimation& Animation = SAnimation())
    : window(Window), texture(Texture), tileSize(TileSize), sprite(Sprite), animation(Animation)
    {
    /* ...*/
    }

    //! Constructor
    CEntity::CEntity(sf::RenderWindow& Window, sf::Texture& Texture, int TileSize, CLevel& Level,
                     CInterface& Interface, const sf::Vector2i& TilePos, int Direction)
        : window(Window), texture(Texture), tileSize(TileSize), level(Level), interface(Interface),
          tilePos(TilePos), direction(Direction),
          bodyAnimator(window, texture, tileSize, body), faceAnimator(window, texture, tileSize, face)
    {
      /* ... */
    }


    So, basically, I'd like advises on: How to code nicely with SFML?

    Thanks in advance,
    easy

    8
    Graphics / Line and Rectangle does not show up
    « on: August 22, 2011, 10:23:55 am »
    Hi!

    As the title states, sf::Line and sf::Rectangle does not work for me. I'm using SFML2 snapshot "LaurentGomila-SFML-9cda5d0" which was downloaded on 2011-08-19.

    Here's the minimal code:

    Code: [Select]
    #include <SFML/Graphics.hpp>


    int main()
    {

        // Create the main window
        sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML Test");

        sf::Color red(255, 0, 0, 255);

        sf::Shape line;
        line.Line(0, 0, window.GetWidth(), window.GetHeight(), 5, red);

        sf::Shape rectangle;
        rectangle.Rectangle(100, 100, window.GetWidth() - 200, window.GetHeight() - 200, red);

        sf::Shape polygon;
        float cx = window.GetWidth() * 0.5f;
        polygon.AddPoint(cx - 1, 0, red);
        polygon.AddPoint(cx + 1, 0, red);
        polygon.AddPoint(cx + 1, window.GetHeight() * 1, red);
        polygon.AddPoint(cx - 1, window.GetHeight() * 1, red);

        while (window.IsOpened())
        {
            // Process events
            sf::Event Event;
            while (window.PollEvent(Event))
            {
                // Close window
                if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Keyboard::Escape) window.Close();
                if (Event.Type == sf::Event::Closed) window.Close();
            }

            // Clear screen
            window.Clear();

            window.Draw(line);
            window.Draw(rectangle);
            window.Draw(polygon);

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

        return 0;
    }


    And the result:



    As you can see, neither the diagonal line nor the rectangle in the center shows up, only the polygon-line in the middle.

    Am I missing something obvious, or is it a bug?

    Cheers,
    easy

    9
    General / [SOLVED] SFML 2 Window resize & view resize
    « on: August 20, 2011, 01:06:05 pm »
    Hi!

    I've got an issue. When I resize the game window, and all the views including the default view, the text I draw on the default view changes it's position, no matter if I reposition it with "SetPosition(20.f, 20.f);", or not.

    The truncated code is:

    Code: [Select]
           // Process events
            sf::Event Event;
            while (window.PollEvent(Event))
            {
                if (Event.Type == sf::Event::Resized)
                {
                    defaultCamera.SetSize(Event.Size.Width, Event.Size.Height);
                    window.SetView(defaultCamera); // ... Just trying to make it work
                    FPSText.SetPosition(20.f, 20.f); // ... Here too
                }
            }


    See two screenshots of the resize:





    Am I missing something?

    Thanks for your answers,
    easy

    10
    Graphics / Graphical glicth: horizontal lines in SFML2
    « on: August 19, 2011, 01:38:43 pm »
    Hello!

    The level is made of 32x32 sprites, and they all share a texture (a tileset). I use no smoothing on the texture, but a camera (a view) to adjust where to render the tilemap.

    Sometimes it renders with a horizontal lines under the tiles (see the screenshot), and this glitch remains while moving the camera horizontally.



    I guess it's related to the floating-point rendering, how can I avoid it?

    Thanks in advance,
    easy

    P.S. My operating system is Linux Mint Debian.

    11
    Feature requests / SFML 2 Pong game update proposal
    « on: August 16, 2011, 09:12:07 am »
    Hello!

    This might not be the ideal forum section so please move my topic if it's misplaced here. Also I don't know if you're open to such modifications or not.

    I've modified a little bit the SFML 2 Pong example to slightly enhance the gameplay, that is:
      - there is a 1 second delay before a round starts (shows how to use an sf::Clock),
      - the game restarts when a player scores a point (encourages to play),
      - the scores are printed on the screen instead of the end text (show how to print variables with sf::Text),
      - fixes AITime to sf::Uint32,
      - added comments.


    Just an idea: a new sound (a whistle) could be played on every new round.

    I think along with these enhancement the example is still encouraging the new users to modify it but also to play with it.
    What do you think?

    The code:

    Code: [Select]
    ////////////////////////////////////////////////////////////
    // Headers
    ////////////////////////////////////////////////////////////
    #include <SFML/Graphics.hpp>
    #include <SFML/Audio.hpp>
    //#include <cmath>
    //#include <ctime>
    //#include <cstdlib>
    #include <sstream>


    ////////////////////////////////////////////////////////////
    /// Entry point of application
    ///
    /// \return Application exit code
    ///
    ////////////////////////////////////////////////////////////
    int main()
    {
        std::srand(static_cast<unsigned int>(std::time(NULL)));

        // Defines PI
        const float PI = 3.14159f;

        // Create the window of the application
        sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML Pong");

        // Load the sounds used in the game
        sf::SoundBuffer ballSoundBuffer;
        if (!ballSoundBuffer.LoadFromFile("resources/ball.wav"))
        {
            return EXIT_FAILURE;
        }
        sf::Sound ballSound(ballSoundBuffer);

        // Load the textures used in the game
        sf::Texture backgroundTexture, leftPaddleTexture, rightPaddleTexture, ballTexture;
        if (!backgroundTexture.LoadFromFile("resources/background.jpg")    ||
            !leftPaddleTexture.LoadFromFile("resources/paddle_left.png")   ||
            !rightPaddleTexture.LoadFromFile("resources/paddle_right.png") ||
            !ballTexture.LoadFromFile("resources/ball.png"))
        {
            return EXIT_FAILURE;
        }

        // Load the text font
        sf::Font font;
        if (!font.LoadFromFile("resources/sansation.ttf"))
            return EXIT_FAILURE;

        // Initialize the score text
        sf::Text scoreText;
        scoreText.SetFont(font);
        scoreText.SetCharacterSize(60);
        scoreText.SetColor(sf::Color(50, 50, 250));

        // Create the sprites of the background, the paddles and the ball
        sf::Sprite background(backgroundTexture);
        sf::Sprite leftPaddle(leftPaddleTexture);
        sf::Sprite rightPaddle(rightPaddleTexture);
        sf::Sprite ball(ballTexture);

        leftPaddle.Move(10, (window.GetView().GetSize().y - leftPaddle.GetSize().y) / 2);
        rightPaddle.Move(window.GetView().GetSize().x - rightPaddle.GetSize().x - 10, (window.GetView().GetSize().y - rightPaddle.GetSize().y) / 2);

        // Define the paddles properties
        sf::Clock AITimer;
        sf::Uint32 AITime      = 200;
        float leftPaddleSpeed  = 400.f;
        float rightPaddleSpeed = 400.f;

        // Define the ball properties
        float ballSpeed = 400.f;
        float ballAngle;

        // Main loop
        int leftScore = 0, rightScore = 0;
        sf::Clock start;
        bool restart = true;
        while (window.IsOpened())
        {
            // Handle events
            sf::Event event;
            while (window.PollEvent(event))
            {
                // Window closed or escape key pressed : exit
                if ((event.Type == sf::Event::Closed) ||
                   ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape)))
                {
                    window.Close();
                    break;
                }
            }

            // Restart the game
            if (restart)
            {
                // Make sure the ball initial angle is not too much vertical
                do
                {
                    ballAngle = std::rand() * 2 * PI / RAND_MAX;
                }
                while (std::abs(std::cos(ballAngle)) < 0.7f);

                ball.SetPosition((window.GetView().GetSize().x - ball.GetSize().x) / 2, (window.GetView().GetSize().y - ball.GetSize().y) / 2);

                // Update score
                std::ostringstream oss;
                oss << leftScore << " : " << rightScore;
                scoreText.SetString(oss.str());
                scoreText.SetPosition((window.GetView().GetSize().x / 2) - (scoreText.GetRect().Width / 2), 20.f);

                // Reset
                start.Reset();
                restart = false;
            }

            if (!restart)
            {
                // Move the player's paddle
                if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Up) && (leftPaddle.GetPosition().y > 5.f))
                    leftPaddle.Move(0.f, -leftPaddleSpeed * window.GetFrameTime() / 1000.f);
                if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Down) && (leftPaddle.GetPosition().y < window.GetView().GetSize().y - leftPaddle.GetSize().y - 5.f))
                    leftPaddle.Move(0.f, leftPaddleSpeed * window.GetFrameTime() / 1000.f);

                // Move the computer's paddle
                if (((rightPaddleSpeed < 0.f) && (rightPaddle.GetPosition().y > 5.f)) ||
                    ((rightPaddleSpeed > 0.f) && (rightPaddle.GetPosition().y < window.GetView().GetSize().y - rightPaddle.GetSize().y - 5.f)))
                {
                    rightPaddle.Move(0.f, rightPaddleSpeed * window.GetFrameTime() / 1000.f);
                }

                // Update the computer's paddle direction according to the ball position
                if (AITimer.GetElapsedTime() > AITime)
                {
                    AITimer.Reset();
                    if ((rightPaddleSpeed < 0) && (ball.GetPosition().y + ball.GetSize().y > rightPaddle.GetPosition().y + rightPaddle.GetSize().y))
                        rightPaddleSpeed = -rightPaddleSpeed;
                    if ((rightPaddleSpeed > 0) && (ball.GetPosition().y < rightPaddle.GetPosition().y))
                        rightPaddleSpeed = -rightPaddleSpeed;
                }

                // Wait a second before the ball starts moving
                if (start.GetElapsedTime() > 1000)
                {
                    // Move the ball
                    float factor = ballSpeed * window.GetFrameTime() / 1000.f;
                    ball.Move(std::cos(ballAngle) * factor, std::sin(ballAngle) * factor);
                }

                // Check collisions between the ball and the screen
                if (ball.GetPosition().x < 0.f)
                {
                    restart = true;
                    ++rightScore;
                }
                if (ball.GetPosition().x + ball.GetSize().x > window.GetView().GetSize().x)
                {
                    restart = true;
                    ++leftScore;
                }
                if (ball.GetPosition().y < 0.f)
                {
                    ballSound.Play();
                    ballAngle = -ballAngle;
                    ball.SetY(0.1f);
                }
                if (ball.GetPosition().y + ball.GetSize().y > window.GetView().GetSize().y)
                {
                    ballSound.Play();
                    ballAngle = -ballAngle;
                    ball.SetY(window.GetView().GetSize().y - ball.GetSize().y - 0.1f);
                }

                // Check the collisions between the ball and the paddles
                // Left Paddle
                if (ball.GetPosition().x < leftPaddle.GetPosition().x + leftPaddle.GetSize().x &&
                    ball.GetPosition().x > leftPaddle.GetPosition().x + (leftPaddle.GetSize().x / 2.0f) &&
                    ball.GetPosition().y + ball.GetSize().y >= leftPaddle.GetPosition().y &&
                    ball.GetPosition().y <= leftPaddle.GetPosition().y + leftPaddle.GetSize().y)
                {
                    ballSound.Play();
                    ballAngle = PI - ballAngle;
                    ball.SetX(leftPaddle.GetPosition().x + leftPaddle.GetSize().x + 0.1f);
                }

                // Right Paddle
                if (ball.GetPosition().x + ball.GetSize().x > rightPaddle.GetPosition().x &&
                    ball.GetPosition().x + ball.GetSize().x < rightPaddle.GetPosition().x + (rightPaddle.GetSize().x / 2.0f) &&
                    ball.GetPosition().y + ball.GetSize().y >= rightPaddle.GetPosition().y &&
                    ball.GetPosition().y <= rightPaddle.GetPosition().y + rightPaddle.GetSize().y)
                {
                    ballSound.Play();
                    ballAngle = PI - ballAngle;
                    ball.SetX(rightPaddle.GetPosition().x - ball.GetSize().x - 0.1f);
                }
            }

            // Clear the window
            window.Clear();

            // Draw the background, paddles and ball sprites
            window.Draw(background);
            window.Draw(leftPaddle);
            window.Draw(rightPaddle);
            window.Draw(ball);
            window.Draw(scoreText);

            // Display things on screen
            window.Display();
        }

        return EXIT_SUCCESS;
    }


    Cheers,
    easy

    12
    General / Creating CMake files of SFML 2 on Linux Mint Debian
    « on: August 15, 2011, 07:37:34 pm »
    Bonjour! :D

    This is my first post here.

    I've installed SFML 1.6 without problems on my system but I'd like try out the upcoming version 2. So I've followed the instructions and this is how far I've made it:



    And the directory where SMFL 2 is:



    The complete error message from CMake is:
    Code: [Select]
    Could NOT find SNDFILE (missing:  SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
    CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
    Please set them or make sure they are set and tested correctly in the CMake files:
    SNDFILE_INCLUDE_DIR (ADVANCED)
       used as include directory in directory /home/easy/Dokumentumok/Programozas/SFML-2/src/SFML/Audio

    Configuring incomplete, errors occurred!


    That is, CMake s complaining about not founding SNDFILE.


    Did this happen before? How can I fix it?

    Thanks in advance,
    easy

    Pages: [1]