Week 2, GameDev Projectile Manager / Enemy Shooting
|
This will be somewhat of a continuation on my last blog post about projectile management in our game project Datepocalypse. However, as the earlier subject was more focused on Player feedback when shooting this section will be about our game’s projectile making structure. Earlier most code was in handled in our TestScene (or TestGameState if you will) and was rather unorganized and cluttered with poorly chosen variables and hard to read walls of text (of code). As the next step for our project was to get the enemies to shoot some projectiles aswell we decided to try to clean up the code a bit before we continued. To use the actual manager we could simply create a pointer in our (for example) player or enemy class to an instance of the manager class and call it’s CreateProjectile function. This would first check if there was any unused projectiles (stored in the list of the desired projectiles) and if not crate a new one. Next step was to make the enemy’s projectile class which was more or less exactly the same as the player’s projectile class apart from that the projectile were assigned another sprite and of course another direction. Since the similarities was so immense we had a discussion about if these actually should be separate classes or not. We stuck with the latter for the main reason that we’d have a better overview of the code as well as it’d be easier find unexpected bugs in the future.
Moving on to the last part of this blog post, which will be the enemy’s shooting ability, where some unsolved issues still remain. The way we wanted it was to have the enemies aim for the closest player character (yes, there are two player characters as mentioned in the previous blog post) but this has not yet been implemented, mostly due to time restrictions and other priorities in the project. The shots should move in straight lines and we figured that we could use Pythagoras theorem to calculate which player character who was the closest to the shooting enemy. There were also some discussion about if the enemies should fire after a set time or when inside a specific range to a player character (or a combination of both). As for now this is controlled by a timer but will most likely be further looked into in the near future |
