Fancy Mansion – Picking up items/Power-Ups
|
This week I’ve been working with items that the player should be able to pick up. The items currently implemented in the game are the candle that gives the player a wider vision radius, the armor and coins. The player can only hold one item at a time, except coins that are added to the score instead. When an item have been picked up it can be carried to a drop off zone. Upon dropping it on the drop off zone, score is added and the item disappears from the level. All of the items are the same kind of object, an object of the Pickup-class. When creating a Pickup-object you give it an x- and y-coordinate and what kind of Pickup it is (Coins, Armor, Candle, etc.). It is also given a sprite and how much it is worth, according to what kind of pickup it is. It also has a state, whether it is held by the player or dropped on the floor. It starts out as dropped on the floor. When standing over an item you can press the E key to pick it up. In the following picture you can see the player standing next to a candle. In the next picture the player have walked over the candle and pressed the E key, and thus the player is given wider vision. This, at the moment, works as a power-up and also can be handed in at the the drop off zone for score. We have not definitely decided if it will be able to generate score or only as a power-up. Next we have the coins. When carrying an item, as the player is carrying the candle right now, he can not pick up any other items. Though he can still pick up coins and pressing the E key is not needed. This is shown in the following two pictures. As you can see score is instantly added. When finding other items, in this example an armor, you have to drop the current item by pressing the Q key and then pick up the new item with the E key, as demonstrated in the pictures below. The player loses the wider vision range provided by the candle in exchange of the more valuable armor. In the case of the armor, the sprite of the armor does not follow the player’s position, but instead the player’s sprite change into an armored one. With the knowledge I currently have I feel that this way of handling items is quite optimized. Inside the Pickup-class I can add other items which have other kinds of attributes and easily implement them in the game. |





