SFML community forums
Bindings - other languages => DotNet => Topic started by: Dejan Geci on August 05, 2014, 03:06:19 pm
-
Recently I decided to port the "SFML Game Development" book to C# in order to learn more about SFML. The code almost maps 1:1 with the C++ until the 7th chapter, which is where I decided to stop. It still might prove useful for someone, so here it is:
https://github.com/dejangeci/WarfareUnleashed
You will need Visual Studio 2010 Express to compile.
Cheers
-
FYI
sf::Clock -> System.Diagnostics.Stopwatch
sf::Time -> System.TimeSpan
sf::Time.asSeconds() -> TimeSpan.Milliseconds / 1000f
https://github.com/SFML/SFML.Net/commit/f7aeeb196d64b3924391f513f31b03c3336a9d27
http://en.sfml-dev.org/forums/index.php?topic=15003.msg110059#msg110059
std::size_t -> int
This isn't a missing feature, if you really want 1:1 mapping the C# equivalent would be IntPtr. However assuming you are using the type for indexing containers then an int fits the bill just fine.
-
I decided to use 2.1, and Clock and Time classes were added after that. As for the std::size_t, wasn't really sure what it is, so I used int.
-
Nice to see somebody port the code to C#, thanks! :)
-
Cool stuff! Thanks for the hard work! I, personally, appreciate it. :)
-
Codebase updated to SFML 2.2.
- Using Clock and Time instead of Stopwatch and TimeSpan
- Indentation converted to 2-space
-
Only nitpicking but,I would say that uint maps better to size_t because size_t is unsigned by definition.
-
Only nitpicking but,I would say that uint maps better to size_t because size_t is unsigned by definition.
Yes, that would map better... but in the CLI all index types use a signed int as the type. In C++ the STD uses size_t for container indexing and such.
Also using an unsigned int would require casts. You can't implicitly cast an uint to an int.
https://msdn.microsoft.com/en-us/library/0ebtbkkc%28v=vs.110%29.aspx
-
Thank you for taking the time to do this. I'm new to SFML and with the book your source code will no doubt save me a lot of hair pulling. :)