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 - Captain Lightning

Pages: [1]
1
General discussions / Re: A new logo for SFML
« on: February 03, 2013, 08:38:44 pm »
Hello everyone, I'm IRC Guy, and I made the sports looking clean blue logo.  Semi-professional freelance web designer AKA "Silly" in IRC.

Not a fan of the "Swoosh", or "Cylon Raider" as someone called it, but it seemed to be a recurring theme so I put it in. Was just a 15 minute logo after exploiter showed me this thread, so no big deal. The Swoosh an old and over established logo trend that only a handful of brands on Earth can (or should) get away with. I would have personally preferred to keep it out, and for my next version I will do so.

The main thing that comes to mind when I look at the logo we have now is "Why is it so complicated?"
For a library that claims to be simple and fast, we sure aren't conveying that message very clearly. For the release of SFML 2.0, I feel we should move to something cleaner and more aesthetic to reflect the new features of the update. (Would be neat-o to get some more detailed info from Laurent about what he'd like to see if possible.)

Anywho, I promised I'd make a better one than I did before, and I suppose now I'll have to deliver. See you fellows soon.

2
Graphics / Sprite.GetSubRect().Intersects() constantly returns true
« on: September 23, 2011, 02:38:21 am »
D:
All of my hopes for easy collision detection are smushed.
Thanks for the link, pyro.

3
Graphics / Sprite.GetSubRect().Intersects() constantly returns true
« on: September 22, 2011, 02:27:32 am »
After trying to use sf::Sprite.GetSubrect().Intersects() I've come to find that no matter what, it always returns true. This can be tested with the following code:

Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include "games.h"

struct Square
{
    sf::Sprite Sprite;
    sf::Image Image;
    sf::String String;
    Square();
};

Square::Square()
{
    Image.Create(100, 100, sf::Color(255,255,255));
    Sprite.SetImage(Image);
    String.SetFont(sf::Font::GetDefaultFont());
}

int Collision_Test(sf::RenderWindow &App)
{
    Square S1, S2, S3;
    S1.Image.Create(100, 100, sf::Color(255,0,0)); // Red Square
    S2.Image.Create(100, 100, sf::Color(0,255,0)); // Green Square
    S3.Image.Create(100, 100, sf::Color(0,0,255)); // Blue Square
    S1.Sprite.SetPosition(250, 250); // Left Bottom
    S2.Sprite.SetPosition(375, 250); // Right Bottom
    S3.Sprite.SetPosition(300, 300); // Center Top
    S1.String.SetPosition(App.GetWidth()/2, App.GetHeight()/8);
    S2.String.SetPosition(App.GetWidth()/2, App.GetHeight()/6);
    bool Switched = false;
    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
            {
                App.Close();
            }

            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
            {
                App.Close();
            }
        }

        const sf::Input& Input = App.GetInput();
        bool Space_Down = Input.IsKeyDown(sf::Key::Space);
        if (Space_Down)
        {
            if (Switched)
            {
                S1.Sprite.SetPosition(250, 250); // Left Bottom
                S2.Sprite.SetPosition(375, 250); // Right Bottom
                S3.Sprite.SetPosition(300, 300); // Center Top
                Switched = false;
            }
            else
            {
                S1.Sprite.SetPosition(100, 250); // Left Bottom
                S2.Sprite.SetPosition(500, 250); // Right Bottom
                S3.Sprite.SetPosition(300, 500); // Center Top
                Switched = true;
            }
        }

        // Collision Logic
        if (S1.Sprite.GetSubRect().Intersects(S2.Sprite.GetSubRect()))
        {
            S1.String.SetText("Red is currently touching Green.");
        }
        else
        {
            S1.String.SetText("Red is not touching Green.");
        }
        if (S2.Sprite.GetSubRect().Intersects(S1.Sprite.GetSubRect()))
        {
            S2.String.SetText("Blue is currently touching Red.");
        }
        else
        {
            S2.String.SetText("Blue is not touching Red.");
        }



        App.Clear();
        App.Draw(S1.Sprite);
        App.Draw(S2.Sprite);
        App.Draw(S3.Sprite);
        App.Draw(S1.String);
        App.Draw(S2.String);
        App.Display();
    }
}

4
Audio / sf::soundbuffer plays no sound
« on: September 16, 2011, 01:56:11 am »
Wow. That one change from '&&' to '||' fixed my issue. Thanks Laurent! :D

5
Audio / sf::soundbuffer plays no sound
« on: September 15, 2011, 01:29:38 am »
The entire source:
Code: [Select]


#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <sstream>

struct player
{
    sf::Image image_player;
    sf::Font font_visitor;
    sf::Sprite sprite;
    sf::String score_string;
    int score_int;
    std::stringstream ss;
    player();
    void update_score(int);
};

player::player()
{
    // Init player sprite and score string.
    image_player.Create(15, 100, sf::Color(255,255,255));
    font_visitor.LoadFromFile("visitor1.ttf", 72);
    sprite.SetImage(image_player);
    score_string.SetText("0");
    score_string.SetFont(font_visitor);
    score_string.SetSize(72);
    score_int = 0;
}

void player::update_score(int x)
{
    score_int += x;
    ss << score_int;
    score_string.SetText(ss.str());
    ss.str("");
}

bool fps_enabled = true, in_menu = true;

int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(1280, 800), "Monotone", sf::Style::Fullscreen);
    App.UseVerticalSync(true);

    // Load font
    sf::Font font_visitor;
    if (!font_visitor.LoadFromFile("visitor1.ttf", 16))
    {
        return EXIT_FAILURE;
    }

    // Create the players, set positions
    player p1, p2;
    p1.sprite.SetPosition(0, floor(App.GetHeight()/2));
    p2.sprite.SetPosition(floor(App.GetWidth()-15), floor(App.GetHeight())/2);
    p1.score_string.SetPosition(floor((App.GetWidth()/2)-100), 10);
    p2.score_string.SetPosition(floor((App.GetWidth()/2)+100), 10);

    // Create fps counter
    std::string framerate_string;
    sf::String fps(framerate_string, font_visitor, 16);
    fps.SetPosition(floor(App.GetWidth())-150,floor(App.GetHeight())-25);

    // Initiate clock
    sf::Clock Clock;
    Clock.Reset();

    // Init music
    sf::Music title_music;
    if (!title_music.OpenFromFile("audio/Feryl - Beakortolaris - Cerror.ogg"))
    {
        return EXIT_FAILURE;
    }

    // Init sounds
    sf::SoundBuffer hit_sb, step_sb;
    if (!hit_sb.LoadFromFile("audio/hit.wav") && !step_sb.LoadFromFile("audio/step.wav"))
    {
        return EXIT_FAILURE;
    }
    sf::Sound step(step_sb);

    // Create menu
    sf::Sprite logo_sprite;
    sf::Image logo_image;
    if (!logo_image.LoadFromFile("monotone.png"))
    {
        return EXIT_FAILURE;
    }
    logo_image.SetSmooth(false);
    logo_sprite.SetImage(logo_image);
    logo_sprite.SetPosition(App.GetWidth()/2-(logo_sprite.GetSize().x/2), (App.GetHeight()/10)*4);

    // Start the game loop
    while (App.IsOpened())
    {
        // Have fps counter update only every second, rather than several times a second
        float Time = Clock.GetElapsedTime();
        if (Time > 1 && fps_enabled)
        {
            // Framerate value
            float framerate_float = floor(1.f / App.GetFrameTime());
            std::stringstream ss;
            ss << framerate_float;
            framerate_string = ss.str();
            fps.SetText(framerate_string + " FPS");
            Clock.Reset();
        }

        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
            {
                App.Close();
            }

            // Escape key pressed : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
            {
                App.Close();
            }

            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::F))
            {
                fps_enabled = !fps_enabled;
            }
        }

        // Create an input event handler for keyboard presses
        const sf::Input& Input = App.GetInput();
        bool a_down = Input.IsKeyDown(sf::Key::A);
        bool z_down = Input.IsKeyDown(sf::Key::Z);
        bool slash_down = Input.IsKeyDown(sf::Key::Slash);
        bool quote_down = Input.IsKeyDown(sf::Key::Quote);
        bool space_down = Input.IsKeyDown(sf::Key::Space);
        int mouse_x = Input.GetMouseX();
        int mouse_y = Input.GetMouseY();

        //Draw menu if that's where we are.
        if (in_menu)
        {
            if (!title_music.GetLoop())
            {
                title_music.SetLoop(true);
                title_music.Play();
            }
            App.Clear(sf::Color(255, 255, 255));
            App.Draw(logo_sprite);
            App.Display();
            if ((Input.IsKeyDown(sf::Key::Space) || (Input.IsMouseButtonDown(sf::Mouse::Left))) && in_menu)
            {
                step.Play();
                in_menu = false;
            }

        }
        else
        {
            // Player 1 controls

            if (space_down) //Meant to be used for testing.
            {
                std::cout << "Duration: " << step_sb.GetDuration() << "Status: " << step.GetStatus();
                p1.update_score(1);
                std::cout << "Space Pressed.\n";
                step.Play();
            }
            if (a_down)
            {
                if (p1.sprite.GetPosition().y != 0)
                {
                    p1.sprite.Move(0, -20);
                }
            }

            if (z_down)
            {
                if (p1.sprite.GetPosition().y != App.GetHeight()-p1.sprite.GetSize().y)
                {
                    p1.sprite.Move(0, 20);
                }
            }

            // Player 2 controls
            if (quote_down)
            {
                if (p2.sprite.GetPosition().y != 0)
                {
                    p2.sprite.Move(0, -20);
                }
            }

            if (slash_down)
            {
                if (p2.sprite.GetPosition().y != App.GetHeight()-p2.sprite.GetSize().y)
                {
                    p2.sprite.Move(0, 20);
                }
            }

            // Clear screen
            App.Clear();

            // Draw entities
            App.Draw(p1.score_string);
            App.Draw(p2.score_string);
            App.Draw(p1.sprite);
            App.Draw(p2.sprite);
            if (fps_enabled)
            {
                App.Draw(fps);
            }

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

    return EXIT_SUCCESS;
}

6
Audio / sf::soundbuffer plays no sound
« on: September 15, 2011, 12:02:04 am »
Oho! You're right, actually. I fixed the '!', but I still have the same issue. No sound plays :(

7
Audio / sf::soundbuffer plays no sound
« on: September 14, 2011, 10:34:18 pm »
sf::music works just fine for me, but for some reason playing a sound using sf::soundbuffer creates no response.

My code:
Code: [Select]

    // Init sounds
    sf::SoundBuffer hit_sb, step_sb;
    if (!hit_sb.LoadFromFile("audio/hit.wav") && step_sb.LoadFromFile("audio/step.wav"))
    {
        return EXIT_FAILURE;
    }
    sf::Sound step(step_sb);
    std::cout << "Duration: " << step_sb.GetDuration() << " Status: " << step.GetStatus();


It returns:
Code: [Select]
Duration: 0 Status: 0

Pages: [1]
anything