To say I’ve learned a lot about scripting over the past several weeks is an understatement. I’ve gone from struggling to create basic character movement to creating functions that can “think” on their own. But most of all, I’ve learned that programming is not just about working hard, but more importantly, about working smart.
One of my recent tasks has been to design and implement a level select map. After plotting the levels on the map, my first instinct was to script the individual events for each level.
So, for example, if level 3 was just completed, the spotlight for the next level would need to go on the level 4 marker. If Chip is on the raft between levels 3 and 4, he can go to the right for level 4, get back on the raft and go left for the bonus level, or get on the raft and go up to get back to level 3. But he would not be able to go past level 4.
As you can imagine, the list of conditionals and events needed for each spot quickly grew quite lengthy. The solution? Work smart.
I stepped back and analyzed the commonalities amongst the different stopping points on the map. Chip would need to stop at level markers, but also rafts and corners as well. But he would only be able to launch into a level while currently standing on a level marker.
As the patterns started to emerge, I was able to formulate functions and algorithms so the code would work for me, rather than the other way around. It didn’t come without tough moments and tricky spots, but in the end, the code is much cleaner and ready for additional functionality as needed.
So even though working smart may be riskier in the short run and you may spend more time feeling stumped, ultimately, the payoff can be well worth it.