Home > adventure materials, Space Mercs > Learning Curve

Learning Curve

Trying to program a roguelike while simultaneously learning C# and the XNA library is not an easy task. One problem (or benefit, depending on how one sees it) is that I am constantly discovering new, more efficient tools and methods with which to accomplish my goals. Unfortunately, this means I am repeatedly going back over code to fix what wasn’t broken, but could be better.

Vector2 Code for Space Mercs

I have to eliminate all of these Vectors for speed gains. Plus, there's a crash somewhere in this morass.

An example is that I have been using a List<Vector2> to store information on rooms/walls that are connected to the maze. I have been using the list because of the ease of access as compared to an Array, but now I realize that the array’s construction means that the computer can access the data from the array much more easily. It just means that I have to take more care in my programming to make sure that I keep within the bounds of the array. When I’m storing map data, LOS data, and AI map data all in arrays vs lists, however, the gain in speed is noticeable, even with these ASCII-graphics.

EDIT: I realize it was that I had “while (UnconnectedOutWallTiles.Count() > 0 ||…” instead of “.Count() > 0 &&“. Oh well. Live and learn, I guess.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: