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.


Topics - MrUnlucky

Pages: [1]
1
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());
        }
 

2
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.

3
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