# frazchaudhry

Member

50

1220 Excellent

• Rank
Member

• Interests
Programming
1. ## MonoGame and bugs/incomplete features?

If you want to use XNA using Visual Studio 2013, you can follow this tutorial at http://rbwhitaker.wikidot.com/setting-up-xna . This should give you XNA project templates inside VS 2013.
2. ## Gamestate Manager Tutorial

Implementing it into your own projects and then making minor modifications to it is the best way to learn what's going on with this sample in my opinion.
3. ## Better way to write this code

Thanks Nypren, but yeah I'm sticking with that code. I found this link http://stackoverflow.com/questions/275073/why-do-c-sharp-multidimensional-arrays-not-implement-ienumerablet that basically explains why 2D arrays can't use linq for anyone that is interested.   Thanks to everyone that helped. Cheers.
4. ## Better way to write this code

Apparently its not working. "nodes" is a 2d array and the linq methods First and FirstOrDefault are not available for this array. However, I have checked that these methods are available for 1D arrays. Although I am able to traverse my 2D array using a foreach loop, I am not sure if the 2D arrays are part of Linq.Enumerable. I checked the msdn documentation but couldn't find anything specific relating to multidimensional arrays and these methods.   I have settled on this code though public Coordinates? GetNodeCoordinates(int number) { Coordinates? coords = null; foreach(Node node in nodes) { if (node.Number == number) { coords = node.Coordinates; break; } } return coords; } I have enclosed the code that calls this function in a try block and if a null value is received, an exception is thrown and the situation is handled.
5. ## Better way to write this code

well I could have it return a null value, in C# you can make even primitive values take on the null value, e.g int? nullableInt = null; and do something like this with my code public Coordinates GetNodeCoordinates(int number) { Coordinates? coords = null; foreach(Node node in nodes) { if (node.Number == number) { return node.Coordinates; } } return (Coordinates)coords; } But it looks just as ugly as my original method. Your improved way looks much better so I am going with that for now. Thanks Boogyman
6. ## Better way to write this code

no you can't do that. Its a non-nullable value type. Also that instance construction must be there otherwise, the compiler will give an error on the second return statement complaining that I am using unassigned local variable. The compiler isn't sure whether my code will actually go inside the if statement or not. The reason I care is because maybe somebody more experienced than I am might have a better way of going about this. Maybe I'll get to learn something.
7. ## Better way to write this code

Hi,    I wanted to know if there is a better way to write the code for this method that I am using in my project. public Coordinates GetNodeCoordinates(int number) { Coordinates coords = new Coordinates(); foreach(Node node in nodes) { if (node.Number == number) { coords = node.Coordinates; return coords; } } return coords; } It basically goes through a 2 dimensional array and if the value in the array object matches the other value it returns a coordinate object. The way I have made my program is that it is impossible for the value being searched for to not be in the array. I do not want to have the second return statement after the foreach loop because I know it will never be called. But the compiler complains if I remove it. Can somebody tell me if there is any way to write this method so I don't have to write the second return statement.
8. ## ? operator

Thanks. In the code they do assign a null value to this variable, and I was wondering how they did that since the values allowed by the PlayerIndex are One, Two, Three, and Four. The link that you provided was very useful, much appreciated.
9. ## ? operator

Hello,         I am trying to understand the the XNA gamestate sample. Everything looks good except for one strange C# syntax that I have not seen before. It has to do with the ? operator. I am familiar with the conditional ? operator which can be used like this (condition) ? statement if true : statement if false; The code in the sample is public PlayerIndex? ControllingPlayer { get { return controllingPlayer; } internal set { controllingPlayer = value; } } PlayerIndex? controllingPlayer; where the PlayerIndex is an enum. The rest of the code also uses the PlayerIndex with a "?" at the end. What does the "?" operator do in this case?

In the "Reduce Processing Load" section on page 171, please add the code to actually remove the element from the list in the UiElements class. its in the source but missing in the book.

A couple of lines of code that you need to fix in the book. The book differs from the code you have provided in the source and that makes the game not run properly. 1. On page 150 Vector2 size = Access.ImageSize(element.Image); should be Vector2 size = element.Size; 2. For the Access class the screen size in the book is 640x480 it should be 800x480, like in the source These two cause the ship to stop before it reaches the end of the screen, so just thought I'd let you know.   So far I am up to "Adding the star field" chapter and enjoying this book a lot. Its a great effort by you for which I am grateful. Although I think you need to really have this book proofread a bit more as I found a lot of grammatical and spelling errors. Other than that I think so far this book has been really good.

Wanted something exactly like this for learning gamedev using XNA or monogame. The fact that its free is totally awesome. I'll be sure to get back to you with some feedback as soon as I go through this. Is there a specific way how you want us to give you feedback or just replying here is good enough?

14. ## need help to learn game programming

sardar sab. enj kuj nai labna. Chadd deo
15. ## Help a Newbie Choose a Program Language

I am aware of that, but you should read his question more carefully, he's asking "how much will C# cost me? Where can I get it for the best price? I don't have to buy that ridiculously priced Microsoft Visual Studio do I?" He's already made his decision regarding the programming language and wants an option that will allow him to code in it cheaply. And for C# Visual C# Express is an excellent choice that won't cost him anything.