The hard work is going on. Here is the list of what you will see in the new video:
- Enemy firing
I have a dummy object (no geometry associated to it) with the camera locked on it that moves forward in the level. When an enemy is close enough (in the "X" direction) to this dummy object, it starts firing. The weapons properties (fire rate, delay between bursts, burst number of shots, ammo...) can be used to limit the time of the attack. In the video, I put the second spaceship in front of a enemy to get it destroyed.
A key can be associated to the auto-fire action. When enabled, every weapon will fire as soon as their properties allow it. In general, it is a good idea to activate it but in some places, it can be preferred to disengage it: some powerful weapons will take some time to reload and it can be necessary to control when they are used. Here, I activate it at the beginning, cut it and re-activate it near the end of the video.
I added the pick-ups. For now, I have energy and weapons activation pick-ups. The energy pick-up restores a fixed amount of energy to the player. The weapons activation pick-ups are used to enable more powerful weapons. I added one of each type in the level. The first one is the energy restoration one, then each pick-up activates a different weapon in the order they will be available through the game. For now, there are 8 weapons groups (see https://www.gamedev.net/blog/635/entry-2261780-collisions-and-weapons/). The pick-ups geometries are not finished. The shot geometries are far from final and some are not of the correct type ("classic" missiles instead of laser or homing missiles).
I added a laser weapon. It needed nearly no additional code. It is very simple: a sphere and a long cylinder with small thingies around it (again, I will work on the geometries later). The laser is an object defined with a very short life time, a high rotation speed around the X axis and a really large amount of energy (it will not be destroyed when colliding with an object, only when its "life time" will be exhausted). The weapon has a big fire rate. I added the cylinder bounding type and added the collision code for it. The Blender script to export the geometries has been updated to allow the definition of the cylinder bounding volume. The only "problem" with that is that the laser goes through objects and can destroy more than one enemy at a time. I think I will make the one in the video not very powerful. It is not visible in the video, but the last weapon will be a very big and powerful laser with a medium reloading speed.
A little word on the pick-ups. I added a Bonus class. In the level definition file, a bonus is defined by its type and an object instance (defined like any other in the level). At first, the associated object instances were added as any other in the vector of dynamic objects. I had the "clipping", the update and the collision for free. But I had this problem: I was able to destroy the pick-ups by shooting at them. I could have added a "type" property to the object instance but I was not happy with this as this property may only be used to distinguish a pick-up from any other object. So, what I did is this: the small amount of pick-ups that will be present allows me to add the "Bonus"es in the level class and go through them all to check for collision with the player. The associated objects on the other hand are added in a specific vector of the level sectors, to avoid sending them all to the rendering part.
I think that's all for now. In the next update: something like homing missiles, particles or the "HUD" who knows ?