Showing posts with label armor. Show all posts
Showing posts with label armor. Show all posts

Wielding a Weapon

I added the ability to wield weapons in my roguelike engine. This includes the ability to take off your weapon as well. There is not much tricky about this operation. If you already are wielding a weapon, and you wield another one, the first weapon needs to go back into your inventory.

Weapon wielding was much easier than dealing with armor. Right now I only have one slot for your weapon. You either are holding one weapon or you are not. I don't have to check different armor wielding locations such as your arm (shield) or your feet (boots).

Now that I got the basics of armor and weapons down, I am rethinking how I handle them. Currently I generate a random list of them to represent what is on a dungeon level. Then I change their state when you pick the up and wield them. However the items are still part of the dungeon level. This is fine if you only have one level. But I plan to have multiple levels. I don't want your inventory or equipment to disappear when you climb the stairs down to another level.

A better idea would be to move items from the dungeon to your inventory. Then you could moves items from your inventory to equipment you are wielding. The inventory and equipment list can persist past the dunegon level. This is going to require some refactoring.

Weaponry

Previously I had implemented armor. You could find it in the dungeon and pick it up. Armor showed up in your inventory. You could drop the armor you picked up. Today I implemented weapons.

It turns out that weapons are similar to armor. They have a name. You can pick them up. They show up in your inventory. You can drop them if they are in your inventory. They have a symbol for display purposes.

In programming terms, I found that armor and weapons share properties and functionality. I was able to determine that these are two specific cases of the general idea of items. Once I got the item behavior down, making some weapons that are items was easy.

I hope this mean that other item types such as potions, rings, and amulets are also easy to add. I think I am getting the hang of this.

Inventory Control

I implemented an inventory dialog for my roguelike game engine today. It shows all the items you hold. It also identifies each item by a unique letter. This made it easy to implement a drop dialog as well.

There are some things to think about for my drop dialog. For example, the user must press the letter to identify the item to drop. Fair enough. But I also make the user press the Enter key to complete the choice. I really should make the choice automatic upon the user pressing the letter key.

I have also glossed over the issue of the user dropping an item on top of another item. Right now it will stack the items on top of each other. But I have not implemented what happens when you move over a space that has items stacked on top of each other. Those are small details though.

Currently I only have armor in the dungeon. So the inventory and drop features only work with armor. If I can generalize this to include other items such as weapons, potions, scrolls, and rings, then I should be good.