Im not interested in what u are arguing about now. I just want to know why my collision is not working and so far it seems no one knows. I give you all my code, so if here is somebody who can explain me why it is not working I would be very, very grateful.
#include <SFML/Graphics.hpp>
#include "collision.h"
#include <iostream>
using namespace sf;
int main()
{
RenderWindow App(VideoMode(800, 600, 32), "Game");
App.ShowMouseCursor(false);
sf::Image IMGBackground, IMGLudzik, IMGKursor;
if(!IMGBackground.LoadFromFile("back.tga"))
return 1;
if(!IMGLudzik.LoadFromFile("lud.tga"))
return 1;
if(!IMGKursor.LoadFromFile("kursor.tga"))
return 1;
IMGKursor.CreateMaskFromColor(Color(255,0,253), 0);
IMGLudzik.CreateMaskFromColor(Color(0,0,0), 0); //przezroczystosc na czarny
Sprite Background(IMGBackground);
Sprite Ludzik(IMGLudzik);
Sprite Przesz(IMGLudzik);
Sprite Kursor(IMGKursor);
Background.SetPosition(0.f, 0.f);
Background.Resize(800, 600);
Ludzik.SetPosition(400.f, 350.f);
Ludzik.SetScale(0.5f, 0.5f);
Przesz.SetPosition(300.f, 300.f);
Kursor.SetPosition(500.f, 500.f);
Event evt;
if(Collision::BoundingBoxTest(Ludzik, Przesz)==true)
{
std::cout<<"Ble";
return 0;
}
while(App.IsOpened())
{
while(App.GetEvent(evt))
{
if(evt.Type == Event::Closed)
App.Close();
if(evt.Type == Event::KeyPressed && evt.Key.Code == Key::Escape)
App.Close();
if (evt.Key.Code == sf::Key::F1)
{
sf::Image Screen = App.Capture();
Screen.SaveToFile("screenshot.jpg");
}
}
float time = App.GetFrameTime();
if(App.GetInput().IsKeyDown(Key::Up))
Ludzik.Move(0, -100 * time);
if(App.GetInput().IsKeyDown(Key::Down))
Ludzik.Move(0, 100 * time);
if(App.GetInput().IsKeyDown(Key::Left))
Ludzik.Move(-100 * time, 0);
if(App.GetInput().IsKeyDown(Key::Right))
Ludzik.Move(100 * time, 0);
App.Clear();
App.Draw(Background);
App.Draw(Ludzik);
App.Draw(Przesz);
sf::Vector2f CursorPos = App.ConvertCoords(App.GetInput().GetMouseX(), App.GetInput().GetMouseY());
Kursor.SetPosition(CursorPos);
App.Draw(Kursor);
App.Display();
}
}
Kind Regards
Fuv