Thread: Using databases in program

  1. #1
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140

    Using databases in program

    How can I implement a database into my text-rpg game?
    I want all the rooms to be in the database, and have the program access certain ones when i want to.

    Can anyone help me get started? I tried using the fstream stuff, but doesn't seem too friendly.

    I'm hoping to use Microsoft Acess for the db creator -- is this possible??

  2. #2
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    Or do you think it would be easier and better to create a room class, and just make a bunch of room objects for each of the rooms? Same with the monsters?

    Thanks for helping =))

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    94
    Do the latter.

  4. #4
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    aye, i was thinking that would be easier.

    i am, however, planning to create a couple hundred rooms and about 50 different monsters. will this make the file 39,325 mb big? and use up half my RAM ?

  5. #5
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    i am, however, planning to create a couple hundred rooms and about 50 different monsters. will this make the file 39,325 mb big? and use up half my RAM ?
    So then get a bigger harddrive and more RAM.

    Well, it's up to you which is more important: size, speed

    Although I'm not sure what speed differences there'll be.

  6. #6
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    thankyou, classes it is.

    by the way, i want my code to be semi-readable by other people, so is there a way to hook-up (not the right term) and access class members across different translation-units?

    like have a source code in the project deticated only for declaring and initializing class objects?

    something tells me this isn't going to be easy, because of the limitations of the public: thingymagig

    any help with this would be great =))

  7. #7
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    >> like have a source code in the project deticated only for declaring and initializing class objects?

    When you create a class, you write a constructor for the class which would initialize all instances declared.

  8. #8
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    true, but i am going to have alot of class variable initializers (i probably got my vocabulary wrong)

    what i mean is, i am going to have alot of these:
    roomClass(1, "The Big Room", 0, 1, 1, 0, monster3);

    i think it would be best to put all of those, and the class declaration, in its own source-file. i am wondering how to access these roomClass objects from a different source-file.

    i don't explain things very well, but i hope you get what i mean *shrug*

  9. #9
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    >> i don't explain things very well, but i hope you get what i mean

    I understand now.

    Try declaring the objects as extern in the seperate source file. Then see if they are accessible in the main file.

  10. #10
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    i'll play around with that extern keyword, thankyou

  11. #11
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    Thankyou all. I got the 'database' working by using a bunch of Room objects (classes).

    If any of you are wondering how to do this, check out my projects (its not even close to done).

    Don't let the .exe file fool you, it does alot more than what it seems. open the project file (USES DEV-C++)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM