
Retro-Progress-9 – Pickups and UI
So having started to kill some enemies my guy felt very disappointed. No matter how hard he search the warm remains of the slain monsters, no magical helmet, no flaming weapons was there to be found… not even a little rusty coin. What is the point in killing without looting.
Always be kind to your main character they say. So I have obeyed, and I have programmed a pickup class that will be fit for all the loots to come. I have also draw the health bar… not much to say there.
You can find many tutorials that will bring you half the way to a proper pickup object. As always, the other half is the hardest part. My advice would be: yes you can watch some of those if you need to learn the concepts but then pause for a time. Plan your code thoroughly and think all your design before starting programming.
It is likely your pickup will need state machine or phases to specify its behavior while appearing, disappearing or being collected. You will need this at least for animation purpose, your object moving from a state to another. You may also need it because you want movements to differ while appearing and once it’s there. Build properly your class/parent and then you can define a lot of different pickups variations.
Pickup is a good exercice to practice design as it is not too complex. Also pickups are always usefull and you will be able to re-use it in many projects. It also easily comply to separation of concern as it only interacts with the player(s) picking it and your collision/movement system. So you can work on this early on your project even if you are still learning programming.