Mario Kart Item Post 4
Overview
Implementations of triple green shells, fake item boxes, golden mushroom, star and giant mushroom. A bug with triple banana peels was also fixed.
Triple Green Shell
Triple green shells consist of three green shells which when used spin around the player. They can then be fired one at a time with the shells following the normal movement. Also since they’re spinning around the player the player can use them as a form of bumper and drive into other players in order to hit them with a shell.
The implementation for this was very similar to the triple banana peel, 3 green shells spawn when triple green shells are set to spawn and are added to the trailing item vector. The trailing item vector is set to the green shells immune items vector. The triple item bool is also flagged in order for the input scheme to be the same as the triple banana peel and triple mushroom input scheme. When the shells are trailed however they spin around the player. To do this the current active item is checked to be a triple green shell in the player’s trailing item function and then the green shells use orbit code written by another group member to orbit around the player.
Fake Item Box
Fake item box looks like a red version of the regular item box and works the same as the banana peel. The only difference being when a player collides with them their velocity is set to 0 and they flip into the air. The other difference is that if a player is trailing the item box behind them and the box gets hit by another item the item box collides with the trailing player.
The implementation of this is the same as the banana peel except that when a player collides with it the flip animation is used instead of the spin and the player’s velocity is set to 0. In order for the trailing player to be hit by the item box when another item hit it a checker in the collision manager was added to see when items collide if either item is a fake item box. If one of the items is a fake item box then the collide with player function is called and the using player (to which the fake item box holds a pointer to ) is passed in.
Golden Mushroom
Golden Mushroom is similar to a regular mushroom except that it can be used to give a mushroom boost for 7.5 seconds. For the implementation of this, a golden mushroom class was created which when called to spawn in the player class gets used instead which starts a timer in the class. For as long as the timer persists the player can use the golden mushroom which gives them the same boost as the regular mushroom except it lasts less. Once the timer ends the mushroom is flagged to destroy. Also when the golden mushroom is set to spawn it is not removed from the player’s inventory, instead is stays there until the timer ends.
Ground Types
In Mario kart when a player drives over rough terrain instead of track they slow down massively. This system has been implemented by other group members and a use ground type bool was added to the player class so that if true this effect would be active on that player. So when a mushroom boost is used this bool in the using player class is set to false so that players boost over rough terrain easily. Once the boost ended this bool is set to true again.
Star
Star is an item in Mario kart that makes you invincible. Whilst invincible no items affect the player on collision and any other players that collide with them get knocked sideways. The player also gets a speed boost and ignores the ground types mentioned above.
Giant Mushroom
The giant mushroom is an item that causes the using player to grow in size and become invincibles similar to the star. When the player collides with another, however, the other player is flattened. When the giant mushroom is called to spawn it is used and sets the used bool to true (this has been moved to the parent item class). The current size of the player is then stored in a vector in the mushroom class along with a vector holding 2 times the players size. An enum is used to hold the current scale state that the player is either growing, maintaining or shrinking. In the update function when the item is used a switch is done on the current scale state if in the growing state a vector lerp is applied to the player’s current scale with the starting scale vector being the first value in the lerp and the 2 times scale vector being the second. A lerp percentage is then increased by 2 times delta time until it reaches 1. At this point, the scale state is switched to maintain. Whilst in the maintain state a timer of 12 seconds is applied and the player is invincible using the same system as the star. Once the timer is finished the player is no longer invincible and the scale state is set to shrink. When in the shrink state the same lerp is applied to the player’s scale as the growth state except the lerp percent is reduced by 3 timed delta time until it reaches 0. Once at 0 the mushroom is flagged to destroy.
Triple Banana Peel Bug
It was discovered that when a player spawns triple banana peels whilst also getting triple banana peels 6 banana peels spawn instead of 3. To fix this a bool called a pressed was added to the player class. This bool is checked when the a button is pressed and a triple item is trailing. If true then it prevents any more triple items from spawning. This bool is set to true when the use button (a button on the controller) is pressed and false when it is not pressed.