YMTD work continues

Managed to get a fair bit of time to work on Yet More Tower Defense this weekend so I was able to make a good bit of progress. I cleaned up some of the stub functionality I’d put in for loading levels from file and put in the functionality to choose your level from the menu. There’s also a nice dynamically generated preview of the level that comes with it, thanks to experimenting with RenderTargets and basically rendering to a texture.

Today I put in one of the key components of the in-game hud: the tower pane! This is where the details of the currently selected tower (for upgrades/selling) are displayed, as well as the details of the tower type selected when building new towers. It’s working pretty well already, and save for some better art and shifting around the position of its elements, I’m pretty happy with it. How ’bout a picture?

Tower Pane (wip)

Tower Pane (wip)

Not much to look at, but all of the data gets updated as it should. It also goes a long way to bridging the gap between “prototype” and “functional game”. Not sure how I feel about the font though. Leave a comment if you have an opinion about it.

The more I work on the HUD, the more I want to add features and functionality. I’m restraining myself from getting too carried away, but I think I will implement a way for this pane to transition away when not in use. Tower defense is often about watching events unfold, so why clutter the action?

Next up: gamepad input. I think. Maybe sound. 🙂

Scale and retain aspect ratio

After doing a bit of work on my level select menu, I came across the need to resize a texture to fit inside the a preview pane I’d created. However, not all of my preview images are going to be the same size or aspect ratio, nor do I want to enforce that restriction. I do, however, want to scale the images (up or down) to fit the pane without stretching them.

It’s a relatively simple procedure:

public static Vector2 FixAspectRatio(int imageX, int imageY, Vector2 paneDimensions)
            float imageAspectRatio = (float) imageX / imageY;

            float paneImageAspectRatio = paneDimensions.X / paneDimensions.Y;

            if (imageAspectRatio > paneImageAspectRatio)
                paneDimensions.Y = (paneDimensions.X / imageX) * imageY;
                paneDimensions.X = (paneDimensions.Y / imageY) * imageX;

            return paneDimensions;

So given a restricted pane size (here “paneDimensions”) and the size of the image, you’ll get back a scaled size. The scaled size will have the same aspect ratio as the image dimensions. It will also be no bigger than the given paneDimensions in width or height.

Project Munny revealed

Update: Project Munny is now referred to as Yet More Tower Defense. And there was much rejoicing!

Project Munny is the codename for the tower defense game I am currently working on. It’s codename was inspired by simply looking around my living room and spotting one of these critters. The game’s title hasn’t been finalized yet, so I’ll be referring to it as Project Munny for the time being.

Project Munny is a fairly traditional tower defense game with an emphasis on polish and playability. It’s primary purpose is for me to work my way through a complete game, something I’ve yet to actually do. I’ve made a fair amount of progress so far though and while the graphics are almost all placeholders, the game is actually quite playable. Notably, I’ve got working levels, towers, creeps, pathfinding, wave progression, upgrades/selling and a dozen other little things. Let’s take a look:

Project Munny Revealed!

Project Munny revealed!

You can see a lot of the debug drawing on there, which is actually easily toggled, but since this blog is about development, I thought it would be proper to leave it in there. Again, the sprites and hud are placeholders for the moment.

There are still a few big ticket items before I can really begin the balancing and polishing process though. For instance:

  • Gamepad input (currently keyboard/mouse for development)
  • Numerous effects (lighting, firing/hit effects)
  • Sound!
  • Virtually all of the best practices
  • High scores
  • Few more creep types, towers
  • Proper menus (functional but ugly placeholders at the moment)

And with that, back to work!