Computer Science Canada Need help w/ organizing my program... |
Author: | marsbarz [ Fri Jun 24, 2005 2:33 am ] |
Post subject: | Need help w/ organizing my program... |
Hey guys, compsci class is over and I handed an pre-pre-pre alpha version of my rpg to my teacher, just for the sake of marks. Now this thing has become a labour of love so I want to spend time polishing it. In fact I might create a website for it later to track my progress, who knows. Right now, though, I'm encountering a problem! I'm trying to organize my program and split the one long, long file I have that contains all the code into a neater and more efficient group of files that run more closely related procedures. How do I declare variables that don't have to be re-declared for every single module I include into my primary code file? I am actually really confused as to what I really am trying to ask, so if you need any other details just ask; thanks in advance! |
Author: | vagyb [ Fri Jun 24, 2005 6:33 am ] | ||||
Post subject: | |||||
what u need are arrays and procedures. Type those in the turing help and u'll understand. here is an example of a procedure. for example if before using a procedure ur program looks like this
but with procedures u can make this into
you can see that the program is much neater, each portion of it is a small procedure that u call in a certain order at the bottom (question, calculations) |
Author: | Delos [ Fri Jun 24, 2005 8:39 am ] |
Post subject: | |
What you're going to want to look into is parameter passing between procedures. For example, instead of having a declaration like "procedure levelUp", have something like "proc levelUp (heroName: string, points : int)" etc etc. Also, you may not know this off-hand, but variables can be exported from within a module. It's definitely not recommended - you're better off creating and exporting a fcn/proc to do this for you. |
Author: | AsianSensation [ Sun Jun 26, 2005 10:19 am ] |
Post subject: | |
If you REALLY REALLY want to organize everything, the best would be write everything in Classes (or Modules), and then save all your classes as a separate file and include it in the beginning. Since you handed it in already, then I assume you are doing this purely out of your own will, in that case, why not learn how to do a little bit of Object Oriented Programming at the same time? We have adequate tutorials in for both classes and Modules, and even one on OOP, check it out. |