SFML community forums

Help => General => Topic started by: Atvus on April 19, 2017, 05:02:30 pm

Title: using #include <Rect.hpp> in C# and Collisition between two Rect´s
Post by: Atvus on April 19, 2017, 05:02:30 pm
Hi Guys,
i have to programm Pong for my university. The challenge is, that it has to been done in c#. Unfortunately, I have my problems to convert the examples from c++ to c#. I found thsi great page:
https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1Rect.php (https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1Rect.php)
I´d like to use them, but i don´t get it, how i could use it in c#
How could i include Rect in c# and how could i use intersects() in c#
I hope my englisch is not soooo bad ^^
Title: Re: using #include <Rect.hpp> in C# and Collisition between two Rect´s
Post by: Tigre Pablito on April 21, 2017, 04:35:26 pm
Hi

C# does not take 'includes', but 'usings' (like using System;)
(And for me is easier than C++)

IntRect rect1, rect2;
rect1 = new IntRect(new Vector2i(100, 100), new Vector2i(300, 150));
rect2 = new IntRect(300, 200, 400, 100);
if (rect1.Intersects(rect2))
{
    // the code here will execute because the condition is true
}
 

Do you know C# and programming? Or you have the project already done in C++ and just need to translate it to C#?