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

Pages: [1]
1
Graphics / Re: Problem using intersects
« on: September 19, 2017, 07:26:47 pm »
Fixed it! I did not move the nextX box properly and its y was always at 0, thanks for your help!  ;D

2
Graphics / Re: Problem using intersects
« on: September 19, 2017, 04:53:45 pm »
Welp, I fixed it. Running the move code outside the block render worked :/. Silly mistake!

I still have problem using globalBounds though, I intersect if I every enter the same axis, meaning I can't stand besides an levelblock.

Illustrated:

player = p
block = x
can't enter = d
empty = -

xxddd
xp---
d----
d----
d----

Any idea?

3
Graphics / Re: Problem using intersects
« on: September 18, 2017, 08:08:28 pm »
This is superwierd, the debugger says that move bool is set correctly but player still moves.

Whole game loop:

while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                //Setup for calc collision
                sf::Vector2f playerPos = player.getPosition();
                playerNextX.left = playerPos.x;
                playerNextY.top = playerPos.y;
                moveX = false;
                moveY = false;

                //Handle input
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
                {
                        playerNextX.left -= playerSpeed;
                        moveX = true;
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
                {
                        playerNextX.left += playerSpeed;
                        moveX = true;
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
                {
                        playerNextY.top -= playerSpeed;
                        moveY = true;
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
                {
                        playerNextY.top += playerSpeed;
                        moveY = true;
                }

                //Start graphics process
                window.clear();
                //Handle level logic
                for (int i = 0; i < levelBlocks.size(); i++) {
                       
                        sf::FloatRect blockRect = levelBlocks[i].getGlobalBounds();

                        //Handle x axis collision
                        if(blockRect.intersects(playerNextX) == 1){
                                std::cout << "Intersects X!" << std::endl;
                                moveX = false;
                        }
                        //Handle y axis
                        if(blockRect.intersects(playerNextY) == 1) {
                                std::cout << "Intersects Y!" << std::endl;
                                moveY = false;
                        }

                        if (moveX) {
                                std::cout << "MOVING X!" << std::endl;
                                player.setPosition(playerNextX.left, player.getPosition().y);
                        }
                        if (moveY) {
                                player.setPosition(player.getPosition().x, playerNextY.top);
                        }

                        //Add to draw queue
                        window.draw(levelBlocks[i]);
                }
                window.draw(player);

                //Display level
                window.display();
                window.setFramerateLimit(30);
        }

        return 0;
}
Moving is also printed, despite debugger saying it does not enter if statement. Did I break C++?
Also, im noticing that blockrect.intersects is true as long as player is on the same "level", it does not actually intersect. Any ideas? Or should I try to compile on another computer maybe

4
Graphics / Problem using intersects
« on: September 17, 2017, 04:04:56 pm »
Hello!

Got an weird problem where my booleans are not being set.

                        sf::FloatRect blockRect = levelBlocks[i].getGlobalBounds();

                        //Handle x axis collision
                        if(blockRect.intersects(playerNextX) == 1){
                                std::cout << "Intersects!" << std::endl;
                                moveX = false;
                        }
                        //Handle y axis
                        if(blockRect.intersects(playerNextY) == 1) {
                                moveY = false;
                        }

                        if (moveX) {
                                player.setPosition(playerNextX.left, player.getPosition().y);
                        }
                        if (moveY) {
                                player.setPosition(player.getPosition().x, playerNextY.top);
                        }
 
Im trying to use the code above for collison checking. The problem is that even if the code enters the intersects statement and print, thus making move false, the character moves. When printing after the intersect statement the boolean is indead always true. This is very weird as I can set the move variables just fine when listening for keyboard events.

Hopefully someone know something!

5
General / Re: SFML library link problem
« on: August 28, 2013, 10:45:37 am »
ha... okey this is akward,

So I checked the version and realised i had downloaded the wrong one, replaced the sfml folder with a newly downloaded one and now it works with no problem. So, yea. Thanks for the help anyhow, and sorry for wasting your time :s


-Tobbe

6
General / Re: SFML library link problem
« on: August 27, 2013, 03:08:30 pm »
Aha, meaning i have to correctly build to create any files? Well that explains that atleast

7
General / Re: SFML library link problem
« on: August 27, 2013, 12:00:41 pm »
Hmm, first of all I'm not sure that I'm at the right place, though it seems I've found some sort of error,

the output in release is pointing towards a folder thats dosen't exist, and they both (release and debug) point towards an .exe that dosen't exist either


some pictures:



8
General / Re: SFML library link problem
« on: August 26, 2013, 08:13:51 pm »
They do, both the .exe and opening the file in codeblocks and running works

9
General / Re: SFML library link problem
« on: August 25, 2013, 06:18:12 pm »

-------------- Clean: Debug in Test (compiler: GNU GCC Compiler)---------------

Cleaned "Test - Debug"

-------------- Build: Debug in Test (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -DSFML_STATIC  -g    -IC:\SFML-2.1\include  -c C:\SpelProgram\Test\Test\Untitled2.cpp -o obj\Debug\Untitled2.o
mingw32-g++.exe -LC:\SFML-2.1\lib  -o bin\Debug\Test.exe obj\Debug\Untitled2.o    -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d
obj\Debug\Untitled2.o: In function `main':
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:6: undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
C:/SpelProgram/Test/Test/Untitled2.cpp:7: undefined reference to `sf::Color::Green'
C:/SpelProgram/Test/Test/Untitled2.cpp:7: undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:15: undefined reference to `sf::Window::close()'
C:/SpelProgram/Test/Test/Untitled2.cpp:12: undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:18: undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
C:/SpelProgram/Test/Test/Untitled2.cpp:18: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:19: undefined reference to `sf::RenderStates::Default'
C:/SpelProgram/Test/Test/Untitled2.cpp:19: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:20: undefined reference to `sf::Window::display()'
C:/SpelProgram/Test/Test/Untitled2.cpp:9: undefined reference to `sf::Window::isOpen() const'
C:/SpelProgram/Test/Test/Untitled2.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/SpelProgram/Test/Test/Untitled2.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
obj\Debug\Untitled2.o: In function `ZN2sf11CircleShapeD1Ev':
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `sf::Shape::~Shape()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 6 seconds)
20 errors, 0 warnings (0 minutes, 6 seconds)
 
looks pretty much the same to me

10
General / Re: SFML library link problem
« on: August 23, 2013, 06:24:21 pm »
Ah, sorry, Here you go:



-------------- Build: Debug in Test (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -LC:\SFML-2.1\lib  -o bin\Debug\Test.exe obj\Debug\Untitled2.o    -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d
obj\Debug\Untitled2.o: In function `main':
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:6: undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
C:/SpelProgram/Test/Test/Untitled2.cpp:7: undefined reference to `sf::Color::Green'
C:/SpelProgram/Test/Test/Untitled2.cpp:7: undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:15: undefined reference to `sf::Window::close()'
C:/SpelProgram/Test/Test/Untitled2.cpp:12: undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:18: undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
C:/SpelProgram/Test/Test/Untitled2.cpp:18: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:19: undefined reference to `sf::RenderStates::Default'
C:/SpelProgram/Test/Test/Untitled2.cpp:19: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:20: undefined reference to `sf::Window::display()'
C:/SpelProgram/Test/Test/Untitled2.cpp:9: undefined reference to `sf::Window::isOpen() const'
C:/SpelProgram/Test/Test/Untitled2.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/SpelProgram/Test/Test/Untitled2.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
obj\Debug\Untitled2.o: In function `ZN2sf11CircleShapeD1Ev':
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `sf::Shape::~Shape()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
20 errors, 0 warnings (0 minutes, 1 seconds)
 

11
General / Re: SFML library link problem
« on: August 21, 2013, 02:51:24 pm »
Thanks for the reply but I have already done what you describe, it's in the first post :S

12
General / SFML library link problem
« on: August 18, 2013, 11:56:25 am »
Hi, first time posting

Recently downloaded SFML but haven't gotten it to work, whenever i'm using the code found in the toturial i'm getting errors:

obj\Debug\Untitled2.o||In function `main':|
C:\SpelProgram\Test\Test\Untitled2.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|7|undefined reference to `sf::Color::Green'|
C:\SpelProgram\Test\Test\Untitled2.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|15|undefined reference to `sf::Window::close()'|
C:\SpelProgram\Test\Test\Untitled2.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|19|undefined reference to `sf::RenderStates::Default'|
C:\SpelProgram\Test\Test\Untitled2.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|20|undefined reference to `sf::Window::display()'|
C:\SpelProgram\Test\Test\Untitled2.cpp|9|undefined reference to `sf::Window::isOpen() const'|
C:\SpelProgram\Test\Test\Untitled2.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\SpelProgram\Test\Test\Untitled2.cpp|5|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\SpelProgram\Test\Test\Untitled2.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\Untitled2.o||In function `ZN2sf11CircleShapeD1Ev':|
C:\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `sf::Shape::~Shape()'|
||=== Build finished: 20 errors, 0 warnings (0 minutes, 0 seconds) ===|

After lurking around i've come to the conclusion I'm linking the library wrong somehow, however I've already tried doing the installation all over again following the toturiol as close as I can with no result.

I'm using the static libraries

Any help/or insight would be appreciated

-tobbe

Pages: [1]
anything