Thread: mafia game

  1. #1

    mafia game

    Guys tell me how this game i made
    it is not finished
    please tell me how it is so far

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379
    Well it's not really a game is it?
    But I suppose apart from disgusting use of indentation, it's fine.
    There isn't really much of a program to even comment on.

  3. #3
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Well, hehe, you have context, but, try to think more object oriented...

    Right now your code is procedural, meaning, you do everything 1 line at a time...

    Try making a "context" class, a class that determines what is said when, etc etc... all this class does is handle strings..

    now think, you have, conversation.... make a class that inherits context and holds all the data for the conversational strings..

    now think again, context also has questions, make a class that holds all question strings...

    Now, questions have answers! Answers is a class that will inherit context AND questions, make sure you "virtualize" the constructors to all these classes, so none are repeated and redeclared...


    now that, my friend, is object oriented, and its much faster in the long run


    btw, i picked the baseball bat... 4tw
    Last edited by Shamino; 11-05-2005 at 11:49 PM.

  4. #4
    thxs i am going to try that

  5. #5
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Quote Originally Posted by Shamino
    Well, hehe, you have context, but, try to think more object oriented...

    Right now your code is procedural, meaning, you do everything 1 line at a time...

    Try making a "context" class, a class that determines what is said when, etc etc... all this class does is handle strings..

    now think, you have, conversation.... make a class that inherits context and holds all the data for the conversational strings..

    now think again, context also has questions, make a class that holds all question strings...

    Now, questions have answers! Answers is a class that will inherit context AND questions, make sure you "virtualize" the constructors to all these classes, so none are repeated and redeclared...


    now that, my friend, is object oriented, and its much faster in the long run


    btw, i picked the baseball bat... 4tw
    Eh, the class structure illustrated here is quite ackward.
    Try working from the bottom up instead of top down.
    IE:

    The most basic structure you have - a sentence.
    A sentence is simply a string.
    A sentence could be a:
    Question, Answer, or Statement.
    A sentence might be the same as another sentence.
    A sentence might need to be tailored for "listener";
    A sentence has to be "said".

    We will ned a sentence class.

    Questions generally require an answer. IE: What's your favorite color?

    Answers usualy require a context to make sense but basically can be said matter of factly. IE: My favorite color is blue.

    Statements don't necessarily require contexts to make sense. They can always be stated mater of factly.

    So, we can draw the conclusion we will probably need to make a class for questions, but not for answers or statements.

    A conversation consists of Questions, Answers, or Statements.
    We will need a convesation class.

    So, some psuedo code
    Code:
    class sentence:
         string Words;
         function equals(strcompare);
         function parse();
         funciton display();
    end;
    
    class Question extends sentence:
         sentence Question;
         sentence[n] PossibleAnswers;
         sentence Answer;
         sentence ResponseCorrect;
         sentence ResponseIncorrect;
         setAnswer(sentence);
         addOptions(sentence);
         setCorrect(sentence);
         setWrong(sentence);
    end;
    
    class Conversation:
         sentence[n] Dialog;
         function append(sentence);
         function display();
    end;
    With that class structure we can create a conversation for any designated Non-Player-Character by setting up an instance, and assigning it the NPC.

    Code:
    // set up our variables
    conversation Greeting = new Conversation(); // create conversation
    sentence hello = new sentence("Hello there <name>.");
    question statecheck = new Question("How Are you today?");
    statecheck.addOption(new sentence("Great!"));
    statecheck.addOption(new sentence("Horrible!"));
    statecheck.addOption(new sentence("Meh."));
    statecheck.setAnswer(new sentence("Great!"));
    statecheck.setCorrect(new sentence("Wonderful, glad to hear it."));
    statecheck.setWrong(new sentence("Well poo on you then!"));
    
    // gather it into a conversation
    Greeting.append(hello);
    Greeting.append(statecheck);
    
    // assign conversation to some NPC
    SomeNpc.conversation = Greeting;
    
    // player targets our set up npc during the game
    PlayerTarget = SomeNpc;
    
    // have a conversation with some one
    if(playerTarget.hasConversation())
       playerTarget.display(); // calls Greeting.display();
    And then, the end result might be something like this in game:
    Code:
    You see some npc standing in front of you. 
    Action? 
    -> talk to
    Some Npc: Hello there Jeremy!
    Some Npc: How are you today?
       1) Great!
       2) Horrible!
       3) Meh.
    -> 3
    Some Npc: Well poo on you then!
    
    You see some npc standing in front of you.
    Action?
    -> talk to
    Some Npc: Hello there Jeremy!
    Some Npc: How are you today?
        1) Great!
        2) Horrible!
        3) Meh.
    -> 1
    Some Npc: Wonderful, Glad to here it!
    Of course, with that structure you can make some pretty complex conversations. By simply making responseCorrect and responseIncorrect also questions.
    Last edited by Jeremy G; 11-06-2005 at 09:00 PM.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  6. #6
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    It's spelled sentence

    Sorry but that was bugging me
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  7. #7
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Quote Originally Posted by JaWiB
    It's spelled sentence

    Sorry but that was bugging me

    Yeah, what do you mean? Thats how I spelled it.





    J/k. There use to be a time when I could spell correctly on the first attempt but then I was introduced to spell check and I just got lazy.

    Honestly, about 1/4 of the way through my post I had this exact thought
    Quote Originally Posted by my brain
    Isn't sentance spelled with an 'e'? Hrm, yeah I think it is.. Wait, it's an 'a'. No, wait..Well I could check it on dictionary.com. Bah, just leave it.
    Oh well.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  8. #8
    ---
    Join Date
    May 2004
    Posts
    1,379
    Nice work Jeremy G!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM