Thread: structure suggestions

  1. #1
    Registered User
    Join Date
    Jun 2009
    Location
    Adeliade, AU
    Posts
    128

    structure suggestions

    I am currently making a basic game, which essentially is stand alone single player MUD game.

    Basically you will set up you player which is a class, and then choose a difficulty.

    Now, each story and its difficulties have the same base rooms, but with each difficulty the story extends.

    e.g. The player starts at the crossroads, can go in 3 directions and so forth and puzzles and stuff will be solved to move onto the next area until the end ( In this case rescuing a princess, ORIGINAL! ;] ).

    Being new to cpp I have set up the basics but I don't really know how to go about structuring this game.

    Do I put each room into its own class with its info and so forth. Do I make a function for each story and each level in functions such as storyOneL1() and call it as an entire function with lots of little functions inside?

    any suggestions would be great, I have been thinking about it for a while now and do not know how best to attack it.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Player should definitely be a class.
    So should a Room.
    Then you will probably want a linked list of rooms. Each object in the list contains a direction - up, down, left, right, linking to the next room in that direction.
    Fill up the room object with relevant info about the room.

    Then you can have the main function loop which basically polls some information such as name from the room and moves the character and does the actions in the room, etc.
    How this stuff affects everything is dependent on the room object, in other words, the room object's implementation will act as the room "code".

    Don't forget that due to the differences in the rooms, you will have to make a base class and derive specific rooms from it, and use polymorphism to manipulate the objects from the loop.
    This is one approach. Perhaps it will further you on your way.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Location
    Adeliade, AU
    Posts
    128
    Quote Originally Posted by Elysia View Post
    Player should definitely be a class.
    So should a Room.
    Then you will probably want a linked list of rooms. Each object in the list contains a direction - up, down, left, right, linking to the next room in that direction.
    Fill up the room object with relevant info about the room.

    Then you can have the main function loop which basically polls some information such as name from the room and moves the character and does the actions in the room, etc.
    How this stuff affects everything is dependent on the room object, in other words, the room object's implementation will act as the room "code".

    Don't forget that due to the differences in the rooms, you will have to make a base class and derive specific rooms from it, and use polymorphism to manipulate the objects from the loop.
    This is one approach. Perhaps it will further you on your way.
    Well I have not read much into polymorphism but I do have a chapter on it.

    I have read into mud programming but it was more focused on the ports and so fourth and did not have many examples of how to make lots of rooms or how to string them together.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The basic knowledge you would need is polymorphism and inheritance. This is C++ programming - what your game code would consist of.
    Then there's the mud programming which would be the communication with the client and that.

    I would suggest you first make a working test of C++ code to lay the ground for the game and make sure it works. You can make it work in text-mode in a console. Easy stuff.
    Then adapt it to your mud.

    But your first goal should be to read about inheritance and polymorphism and be sure to understand those. After you've done that, we should see if you can grasp the layout I gave, or if you need further understanding. We'd be happy to help with questions you have then.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Then you will probably want a linked list of rooms. Each object in the list contains a direction - up, down, left, right, linking to the next room in that direction.
    Or you can use a two-dimensional array instead of the linked "web" (which may be quite hard to set up).
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  6. #6
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    Quote Originally Posted by anon View Post
    Or you can use a two-dimensional array instead of the linked "web" (which may be quite hard to set up).
    Or you could be absurd and use the boost graph library :-D

  7. #7
    Registered User
    Join Date
    Jun 2009
    Location
    Adeliade, AU
    Posts
    128
    Well all I am doing is running it in CMD and dont need to adapt it for MUD, it was just saying it will be that style of playing.

    Ok I have gone through inheritence and polymorphism, I see how it works, but do not see how I can use this... Like, I could just make a class for the environment and then make each room.. and call the functions of that class?



    I think I will try and find a example of a room and use that to build on.

    //
    //

    What is that library?
    Last edited by Aliaks; 07-07-2009 at 02:23 AM.

  8. #8
    Registered User
    Join Date
    Jun 2009
    Location
    Adeliade, AU
    Posts
    128
    Would anyone be able to give me an example of a room, or how to implent moving between rooms? Im guessing it will be some form of array?
    Last edited by Aliaks; 07-09-2009 at 06:24 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem referencing structure elements by pointer
    By trillianjedi in forum C Programming
    Replies: 19
    Last Post: 06-13-2008, 05:46 PM
  2. Replies: 5
    Last Post: 02-14-2006, 09:04 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM
  5. C structure within structure problem, need help
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-30-2001, 05:48 PM