Computer Science Canada battles in an rpg |
Author: | diablo [ Thu Nov 18, 2004 11:15 am ] | ||
Post subject: | battles in an rpg | ||
i am making an RPG an my code is *almost* finished but when i merged all my programs *(i did each individual area(battle,locations, shopping,etc) in their own mini-program)* it ran okay..for the most part. my code is as follows for the problem:
then it will go to the battle procedure(which is before all the areas) and it says (when i make the choice to fight), that the enemy health variable has no value..... can you tell me what i did wrong? |
Author: | Tony [ Thu Nov 18, 2004 12:28 pm ] |
Post subject: | |
my guess is that that variable is decleared localy to some function. You will not be able to access it from other areas unless it is made global (decleared outside of a function, such as beginning of the program) |
Author: | Delos [ Thu Nov 18, 2004 4:16 pm ] | ||||
Post subject: | |||||
Or you could just change the way your 'battle' procedure works to include parameters...
Which would corespond to the relevant pieces of info needed...then during 'battle', you just refer back to them! Something like:
Easy as pi. |
Author: | diablo [ Fri Nov 19, 2004 1:35 pm ] | ||
Post subject: | |||
my code goes as follows:
and when i tried your suggestions,they didnt work at all! dont get me wrong i appreciate them then i tried to declare them all globally, they didnt work then and then i thought: the program has already read "battle" and knows what it does, so here i am in a procedure, calling a procedure......... so how do i go about calling battle ( procedure) from areaX(also a procedure) |
Author: | Delos [ Fri Nov 19, 2004 4:35 pm ] |
Post subject: | |
There's nothing wrong with calling a procedure from within another procedure, just so long as the one being called has previously been declared (this sort of thing is not an issue in more advanced languages). You may want to have a look in the Tutorials section at the ones on Procedures...might be of some help. Procedures Functions Processes by tony |