Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tutorial] - Data file vs Hard Code
Index -> Programming, Turing -> Turing Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
McKenzie




PostPosted: Sat Jun 04, 2005 10:11 am   Post subject: [Tutorial] - Data file vs Hard Code

I've seen a number of students trying to make fighters over the years and everone ALLWAYS hard-codes all of the moves. To go from hard coding to using a data file all you need to do is look at whatever it is and generalize it. So, for a fighter it seems the key thing that seperates one fighter from another is his/her moves. Ask yourself What does it mean to be a move? In other words what general terms can I use to describe all moves. It would look something like:
- keys to activate move
- number of frames of animation in the move
- pictures for frames
- delays between frames
- damage of move
- where the move damages (how far away from me does my fist land,
and how big of an area is affected)
You would then make this into your record that describes your move and associates a list of moves with each of your fighters. A start to this would look something like:
code:
type moveType :
    record
        name : string
        numFrame : int
        pics : array 1 .. 10 of int
        numWays : int
        combos : array 1 .. 10 of string
    end record

Now that you have the moves described in general terms you can just describe each move in your data file and load it up. This will make adding new moves and even new characters a piece of cake. The hard part of course is developing your program that allows you to use these moves. This process is made much easier however because you don't need to be changing data details in the code. I've attached an example of how you could do this. Make no mistake this is not a complete final project that you can just hand in but it should give you an idea.



oliver.zip
 Description:

Download
 Filename:  oliver.zip
 Filesize:  37.75 KB
 Downloaded:  476 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Sat Jun 04, 2005 1:33 pm   Post subject: (No subject)

Very well done. This is helpful to a lot of people because a lot of people don't understand how to move someone around without using a delay, and slowing down everything else in their program.

You just have your lefts/right mixed up on your filenames, but oh well, good job. Smile


+ 20 Bits.
McKenzie




PostPosted: Sat Jun 04, 2005 1:39 pm   Post subject: (No subject)

No, Left means that he is on the left hand side of the fight, but obviously they are more placeholders than anything else.
Hatake_Kakashi




PostPosted: Mon Jun 06, 2005 9:04 am   Post subject: (No subject)

Thanks a lot Mr. McKenzie. I see you named it so I could find it easily....
Bacchus




PostPosted: Mon Jun 06, 2005 3:15 pm   Post subject: (No subject)

Student I'm guessing? If you are: with a teacher like him, you should progress quite well.
Delos




PostPosted: Mon Jun 06, 2005 4:26 pm   Post subject: (No subject)

Oh good grief! Have you seen their 'join date'? Can that be correct?
Wow...or perhaps he's just used Mangekyou on some of the admin...
Bacchus




PostPosted: Mon Jun 06, 2005 6:31 pm   Post subject: (No subject)

Wow, never saw that. 1 Post in the last 2 years..
bored_hacker




PostPosted: Wed Jun 08, 2005 9:07 pm   Post subject: (No subject)

Mr. McKenzie is a great teacher although he doesn't like to teach how to use GUI in class. I had to learn it on my own. You know who I am, sir.
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Thu Jun 09, 2005 3:44 pm   Post subject: (No subject)

Maybe he just reccomends his students to this site, they join, then forget.

There's a bunch of people like that.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: