Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Nick Gravelyn

Member Since 14 Aug 2005
Offline Last Active Today, 10:54 AM
*****

Posts I've Made

In Topic: xna random number in 2d

26 April 2013 - 11:04 AM

Random r = new Random(DateTime.Now.Millisecond);
Vector2 randomVector = new Vector2(r.Next(0, SCREENWIDTH), r.Next(0, SCREENHEIGHT));

I would make two notes here:

 

1) The default constructor for Random already handles seeding by time; you don't need to do it yourself.

2) Because of #1, you want to reuse the same Random instance as much as possible. For example if you ran this:

 

for (int i = 0; i < 100; i++)
{
   Random r = new Random();
   someVectorList.Add(new Vector2(r.Next(0, ScreenWidth), r.Next(0, ScreenHeight));
}

 

You would find that quite a few (if not all) vectors would have the exact same values. This is because each new random instance would have the same seed and therefore generate the same sequence of numbers.

 

So in general you want to create one Random per method at the least, but most people generally just make one Random instance as a public static member on some type and reuse that everywhere.


In Topic: Finding a cross-platform, easy to use language

12 April 2013 - 01:44 PM

If you don't mind a more ActionScript/JavaScript style syntax, you could look into Haxe: http://haxe.org/. In my limited toying with it, it seems rather nice. They have NME, HaxePunk, and HaxeFlixel for getting going on 2D games. Not sure what 3D support you could find. Haxe is nice in that it cross compiles into other code (C++ for Windows, JavaScript for the web, etc) so there's no runtimes to worry about. Seems like a good idea for someone looking to use the same code across a lot of platforms.


In Topic: C# include?

12 April 2013 - 01:42 PM

You can use #if/#endif in C# for using preprocessor directives.

 

You can also add files as a link, so you keep the file in a common directory and any number of projects can include the file as a link which means they'll all share the same C# file, but it will be compiled into all the projects. As long as the projects don't reference each other you should be fine (if the projects reference each other, you're likely to get an error for having the same type compiled twice).


In Topic: C# for 2D game

20 March 2013 - 10:40 AM

XNA isn't dead. Dead implies it doesn't work, isn't available, and isn't supported by Microsoft. None of that is true. The only truth is that there will be no more updates to XNA. If the current feature set of XNA meets your needs, there is no reason to avoid using it to build your game.

According to an email sent on 31 January 2013, XNA is no longer actively being developed, and it is not supported under the new "Metro interface" layers of Windows 8 nor on the Windows RT platform.

 

Right but it was never supported on WinRT (which is the Windows 8 "metro" environment) so it's not as if they are removing support. XNA is still a supported framework for all platforms on which it was ever supported. If its current feature set (including supported platforms) meet your needs, there is no need to avoid using it. Lack of future updates does not automatically render it useless.


In Topic: C# for 2D game

14 March 2013 - 05:17 PM

XNA isn't dead. Dead implies it doesn't work, isn't available, and isn't supported by Microsoft. None of that is true. The only truth is that there will be no more updates to XNA. If the current feature set of XNA meets your needs, there is no reason to avoid using it to build your game.


PARTNERS