Thread: Very Confused about this....

  1. #1
    Master n00b Matty_Alan's Avatar
    Join Date
    Jun 2007
    Location
    Bloody Australia Mate!
    Posts
    96

    Question Very Confused about this....

    Ok basicly what im trying to do is brainstorm the best way to go about loading functions from a file... for example
    Say you load a level file into your game (The game is an RPG by the way ) you talk to a person in that level and they could do a range of differernt actions...

    This is the best idea iv'e had so far in getting this to work
    Code:
    class sprite
    { public:
    
    int function[];
    int string textarguments[]
    int numberarguments[][]
    };
    and then something like...
    Code:
    
    sprite person[10];
    if( user presses action key)
    {
       switch(person[0].function[x])
       {
           case '1':
           a_function(person[0].textarguments[x])
           break;
    
           case '2':
           another_function(person[0].numberrguments[x][y1], person[0]numberarguments[x][y2]);
           break;
    
           }//end of switch
    }//end of if
    however this seems like a very messy, wastefull and confusing way to go about things as there would be alot of unused elements of the arrays

    Is there a better way to go about this? Have I explained this well enough?
    Last edited by Matty_Alan; 03-24-2010 at 12:10 PM.

  2. #2
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    I'd suggest using a scripting language, but hey, that's just me.

    Lua
    Python
    GameMonkey Script
    Consider this post signed

  3. #3
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    Or you can write the functions and assign them some key that you call from the file. And 'switch' through them. But, like bernt, i would go with lua or python.
    -- Will you show me how to c++?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to C++ and confused by boolean and ifs and else
    By jconner in forum C++ Programming
    Replies: 10
    Last Post: 08-02-2006, 03:29 AM
  2. Confused
    By jeev2005 in forum C Programming
    Replies: 5
    Last Post: 06-01-2006, 02:04 PM
  3. why wont this compile?!? :confused:
    By jdude in forum C++ Programming
    Replies: 5
    Last Post: 11-25-2004, 01:13 AM
  4. confused.. in selecting my line of deapth
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-04-2003, 01:21 PM
  5. Extern Question, really confused
    By SourceCode in forum C Programming
    Replies: 10
    Last Post: 03-26-2003, 11:11 PM