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

Pages: [1] 2
1
Graphics / Re: Drawing a click and drag rectangle?
« on: August 25, 2014, 04:49:33 pm »
Thanks for the help. sf::Event::MouseMoved is what I needed it seems. My code works perfectly now, and I think I can simplify it later, too.  :)

#include <SFML/Graphics.hpp>

int main(int argc , char * argv[] )
{
    const int SCREEN_WIDTH = 640;
    const int SCREEN_HEIGHT = 480;
    const int BITS_PER_PIXEL = 32;

    sf::VideoMode VMode( SCREEN_WIDTH , SCREEN_HEIGHT , BITS_PER_PIXEL );
    sf::RenderWindow window( VMode , "SFML!" , sf::Style::Titlebar | sf::Style::Close );

    sf::Vector2i starting_position;
    starting_position = sf::Mouse::getPosition( window );
    sf::Vector2f current_position;
    sf::RectangleShape box;


    while( window.isOpen() )
    {
        sf::Event event;
        while( window.pollEvent( event ) )
        {
            if( event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape ) window.close();

            if( event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left )
            {
                starting_position.x = event.mouseButton.x;
                starting_position.y = event.mouseButton.y;
            }

            if( event.type == sf::Event::MouseMoved && sf::Mouse::isButtonPressed(sf::Mouse::Left) )
            {
                current_position.x = event.mouseMove.x - starting_position.x;
                current_position.y = event.mouseMove.y - starting_position.y;
                box.setSize( current_position );
                box.setPosition( starting_position.x , starting_position.y );
                box.setFillColor( sf::Color::White );
            }
        }

        window.clear();
        window.draw( box );
        window.display();
    }
    return 0;
}

@BaneTrapper Haha, don't worry mate, I never just copy/paste code anyway. Thanks for the example.  ;D

2
Graphics / Re: Drawing a click and drag rectangle?
« on: August 25, 2014, 01:13:08 pm »
That's exactly what I'm trying to do though.  :-\
Problem is, I can only set x, y and size, instead of x1, x2, y1 and y2.
The only thing I could think of is

box.setSize( sf::Vector2f( sf::Mouse::getPosition().x - mouse_position.x , sf::Mouse::getPosition().y - mouse_position.y ) );

...Where mouse_position is the x and y, but apparently I'm doing something wrong because it does not work at all as intended.

3
Graphics / Re: Drawing a click and drag rectangle?
« on: August 25, 2014, 12:54:26 pm »
Hi, I'm trying to do the same thing in SFML 2.1, but I'm having some trouble. I only get a square that disappears when I move the mouse.

This is my current code (based on model76's code):

#include <SFML/Graphics.hpp>

int main(int argc , char * argv[] )
{
    const int SCREEN_WIDTH = 640;
    const int SCREEN_HEIGHT = 480;
    const int BITS_PER_PIXEL = 32;

    sf::VideoMode VMode( SCREEN_WIDTH , SCREEN_HEIGHT , BITS_PER_PIXEL );
    sf::RenderWindow window( VMode , "SFML!" , sf::Style::Titlebar | sf::Style::Close );

    sf::Vector2i mouse_position;
    mouse_position = sf::Mouse::getPosition( window );

    while( window.isOpen() )
    {
        sf::Event event;
        while( window.pollEvent( event ) )
        {
            if( event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape ) window.close();

            if( event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left )
            {
                mouse_position.x = event.mouseButton.x;
                mouse_position.y = event.mouseButton.y;
            }
        }

        window.clear();

        if( event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left )
        {
            sf::RectangleShape box;
            box.setPosition( mouse_position.x , mouse_position.y );
            box.setSize( sf::Vector2f( sf::Mouse::getPosition().x - mouse_position.x , sf::Mouse::getPosition().y - mouse_position.y ) );
            box.setFillColor( sf::Color::White );
            window.draw( box );
        }

        window.display();
    }
    return 0;
}

Thank you in advance. :-)

4
General / Re: Undefined references - SFML 2.1 - Code::Blocks
« on: November 20, 2013, 05:06:42 pm »
Sure. Here you go:
libsfml-system-s.a

It would be weird if you found anything different, though. The whole folder is just what I downloaded from HERE.




EDIT: OK, this is extremely weird. I re-downloaded it, and now it works fine. Sorry for all of your time that I wasted, I really don't know what happened there.  ;D

5
General / Re: Undefined references - SFML 2.1 - Code::Blocks
« on: November 20, 2013, 04:45:08 pm »
I know it sounds crazy but what happens if you remove C:\SFML-2.1\lib from your linker settings? Post the output of the build if possible.

This happens:
-------------- Build: Release in Pooman of Poopooland! (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -ansi -DSFML_STATIC  -O2    -IC:\SFML-2.1\include -IC:\SDL-1.2.15\include  -c "C:\Documents and Settings\Kain\&#917;&#960;&#953;&#966;&#940;&#957;&#949;&#953;&#945; &#949;&#961;&#947;&#945;&#963;&#943;&#945;&#962;\Pooman\Pooman of Poopooland!\main.cpp" -o obj\Release\main.o
mingw32-g++.exe -LC:\SDL-1.2.15\lib  -o "bin\Release\Pooman of Poopooland!.exe" obj\Release\main.o   -s -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_mixer  -lsfml-graphics-s -lsfml-audio-s -lsfml-window-s -lsfml-system-s
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-graphics-s
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-audio-s
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-window-s
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-system-s
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
4 errors, 0 warnings (0 minutes, 0 seconds)

6
General / Re: Undefined references - SFML 2.1 - Code::Blocks
« on: November 20, 2013, 03:14:47 pm »
Yes. "codeblocks-12.11mingw-setup.exe" freshly installed.
I have also tried "GCC 4.7 MinGW (DW2) - 32 bits" just in case, and it gives me other sorts of undefined references:

-------------- Build: Release in Pooman of Poopooland! (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -ansi -DSFML_STATIC  -O2    -IC:\SFML-2.1\include -IC:\SDL-1.2.15\include  -c "C:\Documents and Settings\Kain\&#917;&#960;&#953;&#966;&#940;&#957;&#949;&#953;&#945; &#949;&#961;&#947;&#945;&#963;&#943;&#945;&#962;\Pooman\Pooman of Poopooland!\main.cpp" -o obj\Release\main.o
mingw32-g++.exe -LC:\SFML-2.1\lib -LC:\SDL-1.2.15\lib  -o "bin\Release\Pooman of Poopooland!.exe" obj\Release\main.o   -s -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_mixer  -lsfml-graphics-s -lsfml-audio-s -lsfml-window-s -lsfml-system-s
C:\SFML-2.1\lib/libsfml-graphics-s.a(CircleShape.cpp.obj):CircleShape.cpp:(.text+0xdd): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(CircleShape.cpp.obj):CircleShape.cpp:(.eh_frame+0x63): undefined reference to `__gxx_personality_v0'

C:\SFML-2.1\lib/libsfml-graphics-s.a(Shape.cpp.obj):Shape.cpp:(.text+0x104): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Shape.cpp.obj):Shape.cpp:(.text+0x194): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(Shape.cpp.obj):Shape.cpp:(.text+0x41a): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Shape.cpp.obj):Shape.cpp:(.eh_frame+0x63): undefined reference to `__gxx_personality_v0'

C:\SFML-2.1\lib/libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp:(.text+0x89): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp:(.text+0xd6): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp:(.text+0x118): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp:(.text+0x187): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp:(.text+0x1eb): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp:(.text+0x334): more undefined references to `_Unwind_Resume'
follow
C:\SFML-2.1\lib/libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp:(.eh_frame+0xbb): undefined reference to `__gxx_personality_v0'
C:\SFML-2.1\lib/libsfml-graphics-s.a(VertexArray.cpp.obj):VertexArray.cpp:(.text+0x122): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(VertexArray.cpp.obj):VertexArray.cpp:(.eh_frame+0x67): undefined reference to `__gxx_personality_v0'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Texture.cpp.obj):Texture.cpp:(.text+0x105): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(Texture.cpp.obj):Texture.cpp:(.text+0x15b): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Texture.cpp.obj):Texture.cpp:(.text+0x5a3): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(Texture.cpp.obj):Texture.cpp:(.text+0x889): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Texture.cpp.obj):Texture.cpp:(.text+0x9eb): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(Texture.cpp.obj):Texture.cpp:(.text+0xb33): more undefined references to `_Unwind_Resume' follow
C:\SFML-2.1\lib/libsfml-graphics-s.a(Texture.cpp.obj):Texture.cpp:(.eh_frame+0x5f): undefined reference to `__gxx_personality_v0'

C:\SFML-2.1\lib/libsfml-graphics-s.a(GLCheck.cpp.obj):GLCheck.cpp:(.text+0x47f): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(GLCheck.cpp.obj):GLCheck.cpp:(.eh_frame+0x6b): undefined reference to `__gxx_personality_v0'

C:\SFML-2.1\lib/libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp:(.text+0x7e5): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp:(.text+0xaf9): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp:(.text+0xb0e): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp:(.text+0xb23): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp:(.text+0xd73): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp:(.text+0xec8): more undefined references to `_Unwind_Resume'
follow
C:\SFML-2.1\lib/libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp:(.eh_frame+0x303): undefined reference to `__gxx_personality_v0'
C:\SFML-2.1\lib/libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp:(.eh_frame$_ZNSt8_Rb_treeISsSt4pairIKSsiESt10_Select1stIS2_ESt4lessISsESaIS2_EE10_M_insert_EPKSt18_Rb_tree_node_baseSB_RKS2_+0x13): undefined reference to `__gxx_personality_v0'

C:\SFML-2.1\lib/libsfml-graphics-s.a(ImageLoader.cpp.obj):ImageLoader.cpp:(.text+0x1027b): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-graphics-s.a(ImageLoader.cpp.obj):ImageLoader.cpp:(.text+0x10577): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-graphics-s.a(ImageLoader.cpp.obj):ImageLoader.cpp:(.eh_frame+0x1a73): undefined reference to `__gxx_personality_v0'
C:\SFML-2.1\lib/libsfml-window-s.a(VideoMode.cpp.obj):VideoMode.cpp:(.text+0x318): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-window-s.a(VideoMode.cpp.obj):VideoMode.cpp:(.eh_frame+0x103): undefined reference to `__gxx_personality_v0'
C:\SFML-2.1\lib/libsfml-window-s.a(Window.cpp.obj):Window.cpp:(.text+0x91): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-window-s.a(Window.cpp.obj):Window.cpp:(.text+0x103): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-window-s.a(Window.cpp.obj):Window.cpp:(.text+0x2fa): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-window-s.a(Window.cpp.obj):Window.cpp:(.text+0x52f): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-window-s.a(Window.cpp.obj):Window.cpp:(.text+0x611): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-window-s.a(Window.cpp.obj):Window.cpp:(.eh_frame+0x73): undefined reference to `__gxx_personality_v0'
C:\SFML-2.1\lib/libsfml-window-s.a(GlResource.cpp.obj):GlResource.cpp:(.text+0x5c): undefined reference to `_Unwind_Resume'

C:\SFML-2.1\lib/libsfml-window-s.a(GlResource.cpp.obj):GlResource.cpp:(.text+0x9f): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-window-s.a(GlResource.cpp.obj):GlResource.cpp:(.eh_frame+0x3f): undefined reference to `__gxx_personality_v0'

C:\SFML-2.1\lib/libsfml-window-s.a(VideoModeImpl.cpp.obj):VideoModeImpl.cpp:(.text+0x179): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-window-s.a(VideoModeImpl.cpp.obj):VideoModeImpl.cpp:(.eh_frame+0x53): undefined reference to `__gxx_personality_v0'

C:\SFML-2.1\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x22d): undefined reference to `_Unwind_Resume'
C:\SFML-2.1\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x23e): undefined reference to `_Unwind_Resume'

Process terminated with status 1 (0 minutes, 3 seconds)
50 errors, 0 warnings (0 minutes, 3 seconds)

7
General / Re: Undefined references - SFML 2.1 - Code::Blocks
« on: November 20, 2013, 03:01:18 pm »
Following the guide, the "GCC 4.7 TDM (SJLJ) - 32 bits" one.

8
General / Re: Undefined references - SFML 2.1 - Code::Blocks
« on: November 20, 2013, 02:07:50 pm »
Quote
You should never do that.
Noted.  :)

Here's the new Log:

-------------- Build: Release in Pooman of Poopooland! (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -ansi -DSFML_STATIC  -O2    -IC:\SFML-2.1\include -IC:\SDL-1.2.15\include  -c "C:\Documents and Settings\Kain\&#917;&#960;&#953;&#966;&#940;&#957;&#949;&#953;&#945; &#949;&#961;&#947;&#945;&#963;&#943;&#945;&#962;\Pooman\Pooman of Poopooland!\main.cpp" -o obj\Release\main.o
mingw32-g++.exe -LC:\SFML-2.1\lib -LC:\SDL-1.2.15\lib  -o "bin\Release\Pooman of Poopooland!.exe" obj\Release\main.o   -s -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_mixer  -lsfml-graphics-s -lsfml-audio-s -lsfml-window-s -lsfml-system-s
obj\Release\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x2): undefined reference to `vtable for sf::CircleShape'
obj\Release\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x9): undefined reference to `vtable for sf::CircleShape'

obj\Release\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0xe): undefined reference to `sf::Shape::~Shape()'
obj\Release\main.o:main.cpp:(.text.startup+0xb5): undefined reference to `sf::String::String(char const*, std::locale const&)'

obj\Release\main.o:main.cpp:(.text.startup+0xec): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
obj\Release\main.o:main.cpp:(.text.startup+0x125): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'

obj\Release\main.o:main.cpp:(.text.startup+0x18e): undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
obj\Release\main.o:main.cpp:(.text.startup+0x198): undefined reference to `sf::Color::Green'

obj\Release\main.o:main.cpp:(.text.startup+0x1ad): undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
obj\Release\main.o:main.cpp:(.text.startup+0x1c5): undefined reference to `sf::Window::isOpen() const'

obj\Release\main.o:main.cpp:(.text.startup+0x1ee): undefined reference to `sf::Window::pollEvent(sf::Event&)'
obj\Release\main.o:main.cpp:(.text.startup+0x212): undefined reference to `sf::Window::close()'

obj\Release\main.o:main.cpp:(.text.startup+0x23e): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
obj\Release\main.o:main.cpp:(.text.startup+0x255): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'

obj\Release\main.o:main.cpp:(.text.startup+0x25e): undefined reference to `sf::RenderStates::Default'
obj\Release\main.o:main.cpp:(.text.startup+0x272): undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'

obj\Release\main.o:main.cpp:(.text.startup+0x280): undefined reference to `sf::Window::display()'
obj\Release\main.o:main.cpp:(.text.startup+0x2af): undefined reference to `sf::RenderWindow::~RenderWindow()'

obj\Release\main.o:main.cpp:(.text.startup+0x3bf): undefined reference to `sf::RenderWindow::~RenderWindow()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
19 errors, 0 warnings (0 minutes, 1 seconds)
 

9
General / Re: Undefined references - SFML 2.1 - Code::Blocks
« on: November 20, 2013, 02:01:28 pm »
That's because when I copied the log I defined them both globally and in "Release", since that configuration works fine with SFML 2.0 for me so far.

I also tried defining them EXACTLY like in the guide, but it made no difference at all.

10
General / [SOLVED] Undefined references - SFML 2.1 - Code::Blocks
« on: November 20, 2013, 01:38:56 pm »
SFML 2.0 works absolutely fine with Code::Blocks, but I'm having trouble setting up SFML 2.1. I have followed THIS guide perfectly many times, but when I try to compile the example project, it gives me a long list of undifined references to all sf:: commands. Example:

obj\Release\main.o:main.cpp:(.text.startup+0x125)||undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|

I have followed the guide PERFECTLY, and tried compiling and re-compiling my project several times, but the problem persists.

Here is my build log:

-------------- Build: Release in Pooman of Poopooland! (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -std=c++11 -std=c++0x -std=c++98 -Wall -ansi -DSFML_STATIC  -O2 -DSFML_STATIC    -IC:\SFML-2.1\include -IC:\SFML-2.1\include -IC:\SDL-1.2.15\include  -c "C:\Documents and Settings\Kain\&#917;&#960;&#953;&#966;&#940;&#957;&#949;&#953;&#945; &#949;&#961;&#947;&#945;&#963;&#943;&#945;&#962;\Pooman\Pooman of Poopooland!\main.cpp" -o obj\Release\main.o
mingw32-g++.exe -LC:\SFML-2.1\lib -LC:\SFML-2.1\lib -LC:\SDL-1.2.15\lib  -o "bin\Release\Pooman of Poopooland!.exe" obj\Release\main.o   -s -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_mixer  -lsfml-graphics-s -lsfml-audio-s -lsfml-window-s -lsfml-system-s -lsfml-graphics-s -lsfml-audio-s -lsfml-window-s -lsfml-system-s
obj\Release\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x2): undefined reference to `vtable for sf::CircleShape'
obj\Release\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x9): undefined reference to `vtable for sf::CircleShape'

obj\Release\main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0xe): undefined reference to `sf::Shape::~Shape()'
obj\Release\main.o:main.cpp:(.text.startup+0xb5): undefined reference to `sf::String::String(char const*, std::locale const&)'

obj\Release\main.o:main.cpp:(.text.startup+0xec): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
obj\Release\main.o:main.cpp:(.text.startup+0x125): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'

obj\Release\main.o:main.cpp:(.text.startup+0x18e): undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
obj\Release\main.o:main.cpp:(.text.startup+0x198): undefined reference to `sf::Color::Green'

obj\Release\main.o:main.cpp:(.text.startup+0x1ad): undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
obj\Release\main.o:main.cpp:(.text.startup+0x1c5): undefined reference to `sf::Window::isOpen() const'

obj\Release\main.o:main.cpp:(.text.startup+0x1ee): undefined reference to `sf::Window::pollEvent(sf::Event&)'
obj\Release\main.o:main.cpp:(.text.startup+0x212): undefined reference to `sf::Window::close()'

obj\Release\main.o:main.cpp:(.text.startup+0x23e): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
obj\Release\main.o:main.cpp:(.text.startup+0x255): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'

obj\Release\main.o:main.cpp:(.text.startup+0x25e): undefined reference to `sf::RenderStates::Default'
obj\Release\main.o:main.cpp:(.text.startup+0x272): undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'

obj\Release\main.o:main.cpp:(.text.startup+0x280): undefined reference to `sf::Window::display()'
obj\Release\main.o:main.cpp:(.text.startup+0x2af): undefined reference to `sf::RenderWindow::~RenderWindow()'

obj\Release\main.o:main.cpp:(.text.startup+0x3bf): undefined reference to `sf::RenderWindow::~RenderWindow()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
19 errors, 0 warnings (0 minutes, 1 seconds)

What am I doing wrong?

11
General / Re: Small jitter on slope tiles.
« on: September 25, 2013, 12:04:37 pm »
I almost figured it out. :)

Code: [Select]
//position.x, position.y, width and height are the sprite's coordinates and size.
//float time_step = delta_time->asSeconds() * 32.f;

void entity::slope_collision_detection( tile * Tile )
{
     if( position.y >= Tile->y + ( tile_size - ( position.x + width - Tile->x ) ) - height + 1 )
     {
          position.y = Tile->y + ( tile_size - ( position.x + width - Tile->x ) ) - height + 1 - time_step;
     }
     else if( position.y + height < Tile->y + 1 ) position.y = Tile->y - height + 1;
}

I had to add 1 and subtract the time_step variable because it's the exact distance that I use to check for collisions. It's a bit complicated how I do that, but it works great.

The sprite still jitters, but only when its y position is exactly inside (not above or below) the top pixel of the slope tile.

But I think I can figure this one out.

Thanks for the help. :)

12
General / Re: Small jitter on slope tiles.
« on: September 25, 2013, 12:25:28 am »
I have tried many variations of both with no luck. I subtracted and added varying values, changed the comparison at the if statement to everything I could think of, but the jittering persists.  :(

13
General / Re: Small jitter on slope tiles.
« on: September 24, 2013, 08:55:49 am »
That's what I think, too. But I just don't know how to stabilize the sprite's position.

All the code does is calculating and setting the sprite's y position based on its x position on the slope.
This is the new code, with some redundant parts removed:

Code: [Select]
//position.x, position.y, width and height are the sprite's coordinates and size.

void entity::slope_collision_detection( tile * Tile )
{
     if( position.y >= Tile->y + ( tile_size - ( position.x + width - Tile->x ) ) - height )
     {
          position.y = Tile->y + ( tile_size - ( position.x + width - Tile->x ) ) - height;
     }

      if( position.y + height <= Tile->y ) position.y = Tile->y - height;
}

14
General / Small jitter on slope tiles.
« on: September 23, 2013, 09:57:38 pm »
I'm trying to implement 45 degrees slopes in my platform game, and I came up with the following code:

Code: [Select]
//position.x, position.y, width and height are the sprite's coordinates and size.

void entity::slope_collision_detection( tile * Tile )
{
    if( position.x + width > Tile->x )
    {
        if( position.y + height > Tile->y )
        {
            if( position.y >= Tile->y + ( tile_size - ( position.x + width - Tile->x ) ) - height )
            {
                position.y = Tile->y + ( tile_size - ( position.x + width - Tile->x ) ) - height;
            }

            if( position.y + height <= Tile->y ) position.y = Tile->y - height;
        }
    }
}

This code is for the left-pointing slope, btw.

It works great, but the player sprite jitters just a little bit when it's standing still on the slope.
It's not very noticeable, but it's really annoying.

I have tried many things to get rid of it, like changing the order of the collision, moving and displaying functions, or tinkering with the equations, but nothing seems to work.

Can anyone more experienced point me to what I am doing wrong here?

Thank you in advance.  :)

15
Graphics / Choppy movement with VSync.
« on: August 30, 2013, 07:38:27 pm »
I have noticed a peculiar problem in my project.
Without VSync, everything seems to work fine.
But when I enable VSync, the movement gets very choppy for some reason.

This is the code I use:

Code: [Select]
void entity::entity_move( sf::Time * delta )
{
    speed = 0.1 * delta->asMicroseconds()/500;

    if( moving_left ) position.x -= speed;
    if( moving_right ) position.x += speed;
}

void entity::entity_show( sf::RenderWindow * window )
{
    entityImage.setPosition( position );
    window->draw( entityImage );
}

int main( int argc , char * argv[] )
{
   
    [...]

    sf::Clock clock;
    sf::Time time;

    while( startup::screen_control.window.isOpen() )
    {
        sf::Event event;
        while( startup::screen_control.window.pollEvent( event ) )
        {
            if( event.type == sf::Event::Closed ) startup::screen_control.window_close();

            [...]

        }

        time = clock.restart();

        sprite_1.entity_move( &time );

        startup::screen_control.window_clear( sf::Color::Cyan );

        sprite_1.entity_show( &startup::screen_control.window );

        startup::screen_control.window_display();
    }

    return 0;
}

What am I doing wrong?  ???

Pages: [1] 2