SFML community forums

Bindings - other languages => DotNet => Topic started by: Dejan Geci on August 05, 2014, 03:06:19 pm

Title: SFML Game Development Book - C# Port
Post 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
Title: Re: SFML Game Development C# Port
Post by: zsbzsb on August 05, 2014, 03:45:33 pm
FYI

Quote
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

Quote
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.
Title: Re: SFML Game Development C# Port
Post by: Dejan Geci on August 05, 2014, 05:20:37 pm
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.
Title: Re: SFML Game Development C# Port
Post by: Nexus on August 06, 2014, 12:43:12 am
Nice to see somebody port the code to C#, thanks! :)

Title: Re: SFML Game Development C# Port
Post by: eyeliner on August 07, 2014, 03:13:24 pm
Cool stuff! Thanks for the hard work! I, personally, appreciate it.  :)
Title: Re: SFML Game Development C# Port
Post by: Dejan Geci on March 18, 2015, 01:08:51 pm
Codebase updated to SFML 2.2.
- Using Clock and Time instead of Stopwatch and TimeSpan
- Indentation converted to 2-space
Title: Re: SFML Game Development C# Port
Post by: SpeCter on March 18, 2015, 02:21:31 pm
Only nitpicking but,I would say that uint maps better to size_t because size_t is unsigned by definition.
Title: Re: SFML Game Development C# Port
Post by: zsbzsb on March 18, 2015, 02:44:06 pm
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
Title: Re: SFML Game Development Book - C# Port
Post by: headkase on May 24, 2015, 08:50:19 pm
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.  :)