Forge War - Arrays of All Dimensions

July 26, 2013

So coding has been moving along. I've moved into the quest phase of the game and working in C# has provided one continued annoyance for me.

All right, in AS3, when I want to grab a variable dynamically (as in do I want to grab "Player1Quest" or "Player2Quest" depending on if some other variable "i" is 1 or 2), then that is totally easy. I set up a construction: this, and I can grab the variable by constructing the string of its name. If I'm grabbing a movie clip object or something it gets a little more complicated, but there's still a simple way to do it.

No so in C# my friends! Well, there may be a way, but I have yet to find it, and I've done some looking. So instead of doing something like:
I have 2 options - the smart way and the stupid way. Of course, up until this point, I've been using the stupid way. The stupid way being a series of "if" statements that add a much of needless lines to your code:
This is dumb.

The other way is to not have a different variables for all this player quest business and instead just have an array called "PlayerQuest." Oh, holy crap, I'm a genius. Or at least not a moron. Then you can just be, like:
So much better! And I was doing this for some things, but I think I got hung up if the variable was already an array and for some reason I was apprehensive about making a 2D array. Or if it was a 2D array and I had to make a 3D array. Because I'm afraid of brackets I guess?

I don't know, but I decided I needed to go back and condense all my variables into arrays before the stupidity got too much out of hand, so that was exciting, and now I can get on with my life.

Leave a comment

Comments will be approved before showing up.

Also in Blog

Forge War Kickstarter: A Retrospective

November 29, 2020

Read More

One crazy month
One crazy month

April 30, 2020

I’m sure I’m not alone in the fact that this last month and a half as been quite crazy. I remember about mid-March when the pandemic really started getting serious in the US, and I decided to still go to Piranha Pig Con (pictured above), and then visit my wife’s family out in Virginia.

Read More

The launch has shifted, and that's okay
The launch has shifted, and that's okay

March 20, 2020

I don’t have to explain to you how chaotic this last week has been, and I’m sure you don’t need any more statistics at this point. What I’d like to do, though, is briefly explain how Cephalofair Games has been affected by recent events, and what we will be doing moving forward.

Read More