16
General / Collision detection sfml 2.0
« on: December 13, 2012, 03:48:20 am »
How would i perform a simple box collision detection in sfml?
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.
// SFMLWindow.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow Screen(sf::VideoMode(1024, 768, 32), "SFML-Window");
while(Screen.IsOpened())
{
sf::Image image;
if(!image.LoadFromFile("sprite.png"))
return EXIT_FAILURE;
sf::Sprite sprite(image);
Screen.Draw(sprite);
Screen.Clear(sf::Color(0,255,255));
Screen.Display();
sf::Event Event;
while (Screen.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
Screen.Close();
}
}
return EXIT_SUCCESS;
}