I like the money = weight idea, but we'll still need some sort of shop function to allow players to choose what weapons they want.
Of course, some functions will have to perform some error checking. For such functions, the post condition should clearly outline how the function should handle errors. However, it's a good idea to use preconditions and to assume that what is passed into a function is valid as it makes coding the functions easier and promotes a modular approach. There would be other functions which would ensure that such preconditions are met.
For example, imagine 5 functions take in a bearing as a parameter. Without the precondition 0 <= bearing < 360, each function would have to check that the bearing is within this range. With the precondition, we can assume this holds and we wouldn't have to worry about error checking. Later on, we would make one function that would ensure that this pre-condition is met. Pre conditions make life much easier, trust me!
Regards working out what functions we need, we can do a brainstorm. Work out what the main aspects of the game are (a script interpreter, arena rendering, a league table etc.) then work out what sort of things each aspect of the game needs to do in order to function properly.
For example, one of the game's aspects is the league table. For this to work, you'll need functions like SortScores(), DrawScores(), SaveScores(), LoadScores() etc, each function having its parameters and pre & post conditions clearly defined. That way, someone who hasn't been following this project can write code for us by just following a function's specification. For example, anyone could code this just by following the function's specification:
Ryan
Of course, some functions will have to perform some error checking. For such functions, the post condition should clearly outline how the function should handle errors. However, it's a good idea to use preconditions and to assume that what is passed into a function is valid as it makes coding the functions easier and promotes a modular approach. There would be other functions which would ensure that such preconditions are met.
For example, imagine 5 functions take in a bearing as a parameter. Without the precondition 0 <= bearing < 360, each function would have to check that the bearing is within this range. With the precondition, we can assume this holds and we wouldn't have to worry about error checking. Later on, we would make one function that would ensure that this pre-condition is met. Pre conditions make life much easier, trust me!
Regards working out what functions we need, we can do a brainstorm. Work out what the main aspects of the game are (a script interpreter, arena rendering, a league table etc.) then work out what sort of things each aspect of the game needs to do in order to function properly.
For example, one of the game's aspects is the league table. For this to work, you'll need functions like SortScores(), DrawScores(), SaveScores(), LoadScores() etc, each function having its parameters and pre & post conditions clearly defined. That way, someone who hasn't been following this project can write code for us by just following a function's specification. For example, anyone could code this just by following the function's specification:
Function GreatestCommonDivisor( number1, number2 ) ; Pre: number1 > 0 ; number2 > 0 ; ; Post: Returns the greatest common ; divisor of the two numbers End Function
I will, once the number of posts has passed 100...
Oh come on! The sooner the better!Ryan