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.
For starters the code handling projectile creation along with the reuse of old projectiles was moved to it’s own Projectile Manager. This manager will handle the creation, all the updates aswell as the draw function for each type of projectile not to mention keeping track of associated textures.

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.ProjectileManagerMockup

 

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

Week 2, GameDev Projectile Manager / Enemy Shooting

One thought on “Week 2, GameDev Projectile Manager / Enemy Shooting

  1. Det var smart att börja med att rensa koden lite innan ni började på något nytt så att det blir enklare senare om ni behöver ändra på något.

    Det var väldigt intressant att se hur en annan grupp valde att göra med projektiler. Då vi bara har så att spelaren kan skjuta för att göra det lite lättare då det redan är en typ av challenge att överleva. Vi har ju flera olika skott men dem hanteras bara i en klass.

    Du förklarar på ett väldigt pedagogiskt sätt vilket gör att man lätt kan följa med och veta exakt vad du gör. Det var smart att återanvända skotten då vi tar bort dem varje gång och sen gör nya. Ni valde nog det bättre alternativet med att göra en varsin klass för projektilerna. Önskade bara att man kunde få se lite hur det ser ut i spelet så att man förstår hur projektil färg och design gör att den inte smälter in i bakgrunden.

    Sen hur gjorde ni med att fienden ska sikta på den närmsta karaktären? Om ni kan utveckla det då man undrar hur det blir om en fiende kommer i mitten och karaktärerna har samma avstånd till båda två. Då dem skjuter rakt så hur funkar det med att dem siktar? Då måste ju fienden flytta sig till närmaste karaktär och sen skjuta. Vilket kan då göra att man kan undvika lite lättare beroende på hur lång det tar för fienden att ladda om eller om den inte laddar om utan kan skjuta utan begränsningar. Om den kan skjuta utan begränsningar så skulle ju spelet bli väldigt svårt då fienden skulle spam skjuta hela tiden.

    Annars så är det väldigt bra förklarat som gör att jag vet hur ni tänkte och hur ni utförde det.

    Like

Leave a comment