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

Pages: [1]
1
General / Re: Collision Detection Problems
« on: January 15, 2014, 03:30:04 am »
It looks ok.
Maybe randomPosition() isn't as random as you think, and it gives you the same result as the first time they collides. So it "moves" to the same position.

It's only a guess since you didn't post a complete and minimal code which reproduces the problem. ;)

Oh duh, I'm almost positive that's the problem. I didn't even think of that until you said something. I'm still trying to get used to the new <random> header and how everything works.  I'm seeding the engine with a number that I chose arbitrarily, when I think I'm supposed to be seeding with a random_device? Anyway, I have stuff to do right now, but I think I got it. Thanks.

2
General / Collision Detection Problems
« on: January 15, 2014, 03:12:21 am »
I've made a little toy program that draws a red and white square to the screen. The player controls the red square and when it collides with the white square I pick a random position on the screen to move the white square. It works when I collide with the white square once, but the second time I try to collide with it nothing happens. I think it might have something to do with the square's transformation and its bounding box or something, but I'm not familiar enought with sfml.

Here's the code for the collision:
bool collide(sf::RectangleShape cellOne, sf::RectangleShape cellTwo) {

        return cellOne.getGlobalBounds().intersects(cellTwo.getGlobalBounds());
}
 

Here's where it's called:
if (collide(redCell, whiteCell)) {
                whiteCell.setPosition(randomPosition());
        }
 

3
General discussions / Re: SFML Game Development -- A book on SFML
« on: January 11, 2014, 12:25:10 am »
In Chapter 3 on page 59 it says "The window class internally calls our draw() function. No other classes need access to it, so we can make it private."

I got a little confused by this so I looked at class declaration for sf::Drawable and I noticed that it is friends with sf::RenderTarget. Is this why the window class is allowed to call our private draw() method? I have never used friends before so I'm just trying to make some sense out of this.

e: vvv Okay, thank you.

4
Window / Re: How do I create a window?
« on: June 24, 2012, 04:51:15 am »
Oh crap, I'm an idiot! I went back to look at my previous posts from a year ago that I had forgotten about and I asked the exact same thing! It appears there's a bug with ATI, but SFML 2 works fine, so I'll just do that. Sorry about that.  :-[

5
Window / How do I create a window?
« on: June 24, 2012, 04:48:33 am »
I'm off to a bit of a bumpy start here.  ;D The application compiles and runs fine, but no window is displayed (except for the console). I'm following the "Opening a window" tutorial on this site. My OS is Windows Vista 32bit.

#include <SFML/Window.hpp>

int main()
{
    // Create the main window
    sf::Window app(sf::VideoMode(800, 600, 32), "SFML Window");

    // Start main loop
    bool running = true;
    while (running)
        app.Display();
 

    return EXIT_SUCCESS;
}
 

Is there something wrong with this code? It's the exact same code from the tutorial.

6
General / Tutorial Problem - Opening a Window
« on: November 22, 2011, 01:09:29 pm »
Quote from: "keyforge"
No problem, glad you fixed it, and welcome to the SFML community!


Thanks.  :D

7
General / Tutorial Problem - Opening a Window
« on: November 22, 2011, 02:16:16 am »
Quote from: "thePyro_13"
Do you have an ATI card?

Unfortunately their is a known bug that prevents windows from showing at all on ATI cards when dynamically linking to SFML 1.6.

The two workarounds are to link to SFML statically, or to upgrade to the current version of SFML2(where the bug has been fixed).


Yes I do have an ATI card so that must be the problem. SFML 2.0 appears to be working properly though so that's good.  Thanks to both of you for the help.

8
General / Tutorial Problem - Opening a Window
« on: November 22, 2011, 01:04:56 am »
Downloaded VC++ 2008. Same problem.

9
General / Tutorial Problem - Opening a Window
« on: November 21, 2011, 11:41:51 pm »
Hmm.. Nope. That doesn't seem to work either.

10
General / Tutorial Problem - Opening a Window
« on: November 21, 2011, 11:29:34 pm »
I've decided to give SFML a try so I started with the tutorials but it looks like I'm stuck right off the bat. I can't seem to create a window.

The code:
Code: [Select]

#include <SFML/Window.hpp>

int main()
{
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

while(App.IsOpened())
{
sf::Event e;
while(App.GetEvent(e))
{
// Close window
if(e.Type == sf::Event::Closed)
App.Close();
// Escape key pressed
if((e.Type == sf::Event::KeyPressed) && (e.Key.Code == sf::Key::Escape))
App.Close();
}

App.Display();
}

return EXIT_SUCCESS;
}


The command prompt appears, but no window. Any ideas? I'm using VC++ 2010 on Windows 7.

Pages: [1]
anything