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 - pabloist

Pages: [1] 2
1
Graphics / Strange error when passing a reference to sf::RenderTarget
« on: March 24, 2011, 12:19:34 am »
EDIT: Nevermind! I realized that the objects that I was attempting to call Draw() from (that were stored in a container) were destructed before I managed to draw them. [/b]

2
Graphics / Strange error when passing a reference to sf::RenderTarget
« on: March 23, 2011, 01:39:28 am »
I'm not really sure why I'm getting this error, since I've done this before in other programs. It happens when I attempt to call sf::RenderTarget.Draw(sf::Sprite) - it tells me that I'm attempting to call a pure virtual method.

Code: [Select]
void Draw(sf::RenderTarget& target)
{ target.Draw(sprite_); }


and then in a drawing loop, I'd have
Code: [Select]
// Window declaration
sf::RenderWindow App(/* construction */);

// Drawing loop
for (/* all objects */)
{ iter->Draw(App); }


Is there something wrong with what I'm doing? Or should I try posting more code? Will I be forced to use pointers to make sure the polymorphism kicks in? It's weird, since this has worked before...

3
Graphics / Good way to make sprite sheets? (not really programming)
« on: February 27, 2011, 03:09:46 pm »
I'm wondering if there was a 'best-practice' sort of way to make spritesheets. I'm attempting to make some for myself right now, and I'm pretty bad at it.

4
Graphics / Click and drag sprites?
« on: February 05, 2011, 11:56:36 pm »
Ah, thanks. Comparing against the position instead of the center fixed it.

5
Graphics / Click and drag sprites?
« on: February 02, 2011, 07:22:30 pm »
I'm trying to figure out how I can click on a sprite, then drag it and drop it at a new position. I'm guessing either I shouldn't be using Sprite.SetPosition() like this OR I'm going about calculating a mouseover incorrectly.

Code: [Select]

#include <SFML/Graphics.hpp>

bool isMouseOver(const sf::Sprite& sprite, const sf::Input& input)
{
    const int mousex = input.GetMouseX();
    const int mousey = input.GetMouseY();

    const sf::Vector2f spritesize   = sprite.GetSize();
    const sf::Vector2f spritecenter = sprite.GetCenter();

    // If the distance between the mouse and the sprite's center
    // is less than the length/width of the sprite.
    if (mousex - spritecenter.x < spritesize.x &&
        mousey - spritecenter.y < spritesize.y)
        return true;
    return false;
}


int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");


    // Usually I use a resource manager to do this.
    sf::Image Image;
    Image.LoadFromFile("cb.bmp");
    sf::Sprite Sprite;

    Sprite.SetImage(Image);

    while (App.IsOpened())
    {
        const sf::Input& Input = App.GetInput();

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

            if (Event.Type == sf::Event::Closed)
                App.Close();
            }
        }

        if (Input.IsMouseButtonDown(sf::Mouse::Left))
            if (isMouseOver(Sprite, Input))
                Sprite.SetPosition(Input.GetMouseX(), Input.GetMouseY());

        App.Clear();

        App.Draw(Sprite);

        App.Display();
    }

    return EXIT_SUCCESS;
}


What happens is that the sprite DOES get dragged around.. but only as long as the mouse is on the sprite's original sprite area. So I'm guessing that I should be modifying something else about the sprite or something, or resetting the center. I've tried that, but I'm not sure how to go about doing it correctly.

6
Audio / Problems opening sound files
« on: January 14, 2011, 12:59:46 am »
Ah, I understood about relative vs absolute filepath. For some reason, I managed to get it working now. It might have had something to do with the files.. chimes.wav started working, but other files within the folder wouldn't. /shrug

Thanks to those who tried to help!

7
Audio / Problems opening sound files
« on: January 12, 2011, 11:39:38 pm »
No idea? :/

8
Audio / Problems opening sound files
« on: January 05, 2011, 02:26:01 am »
I can successfully load and use images, but am having problems doing the same for both sound and music.

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

int main()
{
    sf::Music Music;
    if (!Music.OpenFromFile("mus/chimes.wav"))
        return EXIT_FAILURE;

    Music.Play();

    return EXIT_SUCCESS;
}


Gives me "Failed to open "mus/chimes.wav" for reading", and does the same with sf::SoundBuffer. I am certain the file path is correct, because I have correctly loaded images along similar filepaths (I also attempted reading an image from the same folder, which worked.)

I don't believe the .wav file is corrupted, since I can still play it, and I have attempted this with several files already.

Any ideas on what's wrong? I'm using Windows 7, gcc 4.4, sfml1.6, code::blocks.[/quote]

9
Audio / Error with OpenAl32.dll
« on: January 05, 2011, 12:25:30 am »
Thank you, Laurent, found them and got it working :)

10
Audio / Error with OpenAl32.dll
« on: January 04, 2011, 04:31:40 am »
When I attempt to compile, I get this error.
Quote
The procedure entry point alGetSource3f could not be located in the dynamic link library OpenAl32.dll.


I'm using Code::Blocks, gcc 4.4, SFML 1.6, on Windows 7. I've linked the libraries as
Quote
-lsfml-audio-d
-lsfml-graphics-d
-lsfml-window-d
-lsfml-system-d


My program was working before I attempted to add sound.. so what do I do?

11
General / Problems starting openGL
« on: December 24, 2010, 10:53:31 pm »
Okay, I got it working.. for some reason, changing it to -lsfml-graphics-d, etc fixed it, so I guess it's a problem with the way I set up SFML? I dunno. Thanks, though.

12
General / Problems starting openGL
« on: December 24, 2010, 08:49:15 pm »
I'm trying to get the tutorial for openGL with SFML working (http://www.sfml-dev.org/tutorials/1.6/window-opengl.php), but I'm getting errors like
"undefined reference to `gluPerspective@32'" - I think these are linker errors?

Anyway, I've tried
Quote
-lopengl32
-lsfml-graphics-s-d
-lsfml-window-s-d
-lsfml-system-s-d
which gives the 'undefined..' errors, and

Quote
-lglu32
-lopengl32
-lsfml-graphics-s-d
-lsfml-window-s-d
-lsfml-system-s-d
which, when I try to compile, gives me an error that ld.exe has stopped working.


I am a total beginner with openGL, so I appreciate any help you can give me.

(I have Windows 7, using GNU GCC with Code::Blocks.)

13
General / Getting around automatic key-pauses?
« on: October 20, 2010, 05:32:37 am »
Oh, awesome! Thanks :)

14
General / Getting around automatic key-pauses?
« on: October 20, 2010, 04:26:02 am »
Even using sf::Input, I'm getting the key delay. Same with the problem of 2 keypresses - perhaps I'm using it wrong?

(This IS different from first code posted, first code was mixing sf::Event and sf::Input stuff)

Code: [Select]
while (App.IsOpened())
{
    sf::Event Event;

    const sf::Input &Input = App.GetInput();

    if (Game.enemies.empty())
        Game.SpawnEnemies(sf::Randomizer::Random(10,50));

    while (App.GetEvent(Event))
    {
        if (Input.IsKeyDown(sf::Key::Left))
            Game.player->Move("Left");
       
        if (Input.IsKeyDown(sf::Key::Right))
            Game.player->Move("Right");                    
       
        if (Input.IsKeyDown(sf::Key::Space))
            Game.pl_lasers.push_back(Game.player->FireLaser());

        if (Input.IsKeyDown(sf::Key::Escape))
            App.Close();
       
        if (Event.Type == sf::Event::Closed)
            App.Close();
    }
    Game.Update();
    // more stuff....
}

15
General / Getting around automatic key-pauses?
« on: October 20, 2010, 01:47:23 am »
When a key is pressed, if it is held down, it takes a bit for it to continue registering. I'm pretty sure there's a way around this, but I can't figure it out.

Also, how can I handle multiple key inputs at the same time? If say, I'm holding the Right key down, then press space, the Right key is no longer being held down (and I have to press it again).

Code: [Select]
while (App.IsOpened())
        {
            sf::Event Event;

            const sf::Input &Input = App.GetInput();

            while (App.GetEvent(Event))
            {
                if (Event.Type == sf::Event::Closed)
                    App.Close();
                if (Input.IsKeyDown(sf::Key::Left))
                    Game.player->Move("Left");
                else if (Input.IsKeyDown(sf::Key::Right))
                    Game.player->Move("Right");

                if (Event.Type == sf::Event::KeyPressed)
                {
                    if (Event.Key.Code == sf::Key::Escape)
                        App.Close();
                    else if (Event.Key.Code == sf::Key::Space)
                        Game.pl_lasers.push_back(Game.player->FireLaser());
                }
            }


About the Input.IsKeyDown() being mixed up with the Event.Type checking, I think I remember reading something about Input being better for some reason.. tbh, I don't remember why I used it.

Thanks for help!

Pages: [1] 2
anything