Drowning in code When working on WeaponManager
|
So as you can see above I have been working on the WeaponManager for this past week. I have drew my thought the first day thinking I have nailed it it looked something like this:
thinking I NAILED it! Then after a good nights sleep I realized I was SO wrong in how I thought and how I began to code, removing everything and starting from scratch was inevitable. SO I started working on paper again and the pattern you see above was spread to 4 A4 pieces of paper and scribbled on and off again over and over. Then after 1 hour of thinking and scribbling I started to program. Yes now I surely would make it. Yet again fate was not with me, as off today I noticed that my code would not work. Not at all. After learning how to use a library called YAML (https://code.google.com/p/yaml-cpp/) I used it to my advantage and now I know how use it for beginners. Now I have rambled about my problems so maybe you should know what I have been looking into. I have a Player, WeaponManager and BulletManager class and have to make WeaponManager work with Player and BulletManager making a ”conversation” between them and making sure that information such as Weapon: Damage, spread, delay, recoil, ammo and such would come in use when you pressed shoot. But after several trials I ended up making this: void WeaponManager::equipWeapon(int value){ if (value == 1){ bullet_speed = 50; } bullet_speed = 100; weapon->setWeight(weight); } I bet some of you can see the error right away but I sure as hell did not. This is still new to me and I after asking our Lead Programmer I got to know what was wrong with the code. I should store it in a std::map and faster than you can say: Brain Freeze! I lost it all, I went home that day thinking dark thoughts about how programming should always work how I wanted it so that I could get on with my life. Now you are with me today. I have worked to make my former code work better before I gave up and now have to learn about std::map if you ever ask my lead programmer what it is he will say (Like a vector but tailor-made for this!) and I am still baffled how it works. So my goal for the moment is to make this work the way I like it with std::map. void Config::configure(AnimationManager *animationManager) animation->m_texture = animation->frame_duration = it->second[“frame_duration”].as(); animation->m_frames.clear(); Still in bafflement but I will make it work before tomorrow morning! even If I have to stay awake all night! Alpha presentation is tomorrow and I will blog a short response on how I made it with the code and how it went when I get the time but it will be before next Thursday. |
