Okay I'll try and explain this best I can, however I struggle getting my thoughts out into writing for some bizarre reason.
For object orientation I would like every aspect of this program put into it's own class, just like the modules and BattleBot. Maybe this is the wrong way to go about it ( Hence the title: How to properly plan a program ) so I'm actually unsure of my next steps. All I know is that so far I can create a BattleBot object, which is no use on it's own.
I was hoping I could have a Map class, Shop class and the like so I could have the program sectioned off into pieces so it's not all the main and get extremely messy ( Like many of my existing programs ). I wanted to encapsulate functions relative to it's variables to make maintenance easier and leave room for expansion without having to change things through hundreds of lines of code.
I hope you are with me so far...
The 'Sensor' is a module that can be added to the BattleBot. In my head I saw this as an invisible circle surrounding the BattleBot with the Sensor::Range being the
diameter radius. It's similar to the functionality of your HeroVision functions, however it detects if another BattleBot is nearby, or perhaps approaching a wall.
The get method for the range of this is basically:
|
BattleBot->bSensor.getRange(); // Returns the range of the Sensor equipped to the BattleBot
|
Module.h
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
class Sensor: public Module
{
public:
Sensor::Sensor();
Sensor::Sensor(string name, int cost, int range, int weight);
Sensor::~Sensor();
int getRange() { return Range; }
int getWeight() { return Weight; }
// Functions need to be added here for Detection
private:
const int Range;
const int Weight;
};
|
So far I do not have an approach nor idea for getting the Sensor module to interact with the game world. I'm hoping someone can give me some ideas.
runCommand was pseudocode. My idea for this game was instead of people taking control of their player directly like most games, I wanted to try something different where the player has to program their Robot before the fight. It would run through that code until the enemy were destroyed or itself was destroyed. The player would have to upgrade it's RAM module as it wins fights to upgrade how much space it has to add more advanced logic.
^ This is possible way out of my scope, but you can't blame a man for trying. I had a simple syntax in mind.
Sense - Get's information about it's surrounding environment
if(Sense.Enemy): Aim, FireWeapon - Faces enemy, fires at it
if(Sense.HitWall): TurnLeft - Turns 90 degrees to it's left
Repeat