Post Mortem Part 2
(This is part two of the Post Mortem. If you haven't read the first part, please do so before continuing.)
Now, every object that can be hit by the bullet has a method that calculates its position at any moment in time (provided as a parameter).
Cars have their 'spawn moment' (the exact time when they materialize inside the tunnel on the left), they have their 'lane number' (indicating the lane of the road on which they travel), and speed. The above mentioned method checks whether the time parameter is before the 'spawn moment' (in which case the function returns a special value saying "I'm not here!"), or not. If the car is already 'in play', then the next critical moment is when the bullet gets fired.
Buildings have their 'shatter moment' -- this is either '999 seconds', if the building is never hit by a bullet, or something smaller.
Building fragments have their 'spawn moment', which is the same as the 'shatter moment' of the building from which they spawn.
Upon firing the bullet, EVERY collidable object will check if it will be hit by the bullet. This is calculated immediately when the bullet is fired, and the outcome of that calculation is stored for each object in its variables.
Couple of things I've learned specifically from this game jam:
- Sound is really important. Through some inexplicable glitch, I've received 2.5 points out of 10 for sound and music, despite not having any sound and music in the game at all :-) If I had gotten a score of 6 or 7, I would have possibly won the jam.
- Replacing a 'x += xspd * delta_time/1000000' approach to movement with 'x = CalcMyPositionAtTime(time_moment)' is a must for games with time control, bullet time etc. mechanics.
- Precalculating when things will happen and storing that information gives an opportunity for some cool effects (such as the building smoothly shattering/gluing back together as you move time forward and backward).
- The tunnel entrances with the shadow being cast by their edges is a surprisingly effective way of communicating height/depth. I think I will employ shadows more in my future projects.