c++ noob making a game

This is a discussion on c++ noob making a game within the Game Programming forums, part of the General Programming Boards category; I decided to teach myself c++ yesterday (being sick tends to give you some free time). After reading through a ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    9

    Talking c++ noob making a game

    I decided to teach myself c++ yesterday (being sick tends to give you some free time). After reading through a lot of tutorials I decided to apply my knowledge to somthing lol.

    My plan is to make a nice console rpg, even perhaps make it multiplayer once i learn how...
    The first step i decided to take was to create a combat system, its 326 lines long (a lot longer then i expected...) and written in about 4 hours.

    The whole point of this demo is to er kill a monster standing in front of you.

    The zip file has the source code and the exe for whoever cares, what i'm looking for is perhaps pointers and tips as well as any suggestions for the final game.

    The source is a bit messy in places, and it doesn't have too many comments, so good luck

    Thanks for anyone who care to have a look
    Attached Files Attached Files

  2. #2
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    if you want to add some rudimentary (IE, ASCII) graphics to it, you can check out this:
    Attached Files Attached Files
    I came up with a cool phrase to put down here, but i forgot it...

  3. #3
    Spaced Cadet
    Join Date
    Aug 2003
    Posts
    110
    Wow, thats actually pretty good considering.
    I sugest displaying the maximum HP for both people during the battle, make make it look cleaner (remove linebreaks, or add linbreaks) and maybe give more choices of things to do, like use a healing potion, cast a spell, etc...
    Also, it shouldn't be much harder to have a 1v5 battle, or even a 3v5 (you and CPUs vs CPUs or you vs CPUs). Good luck, really.

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    Hey thanks, I don't want any graphics yet, if this works out I'm going to try and make a top down windows version, but thats going to be far in the future.

    Spells and potions should be quite easy to add in, I'll probably just add that now lol. Next things i want to add is a save feature for the room your in etc etc, i just need to learn the best way how.

    1 way I've thought about doing this is to save a .txt file and have arrays in that text file for items, health, room layout etc. Though i have no idea how to actually implement this, I know how to save a .txt file, but i don't know how i would save an array to it, nor how i would load this information out of the array once it loaded again.

    If I get anything done today I'll post an update.
    Thanks for replies!

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    195
    for saving it is easy, just use teh fstream library

    declare
    ofstream myout;

    myout.open("c:\...\yourtxt.txt");

    and lets say you have a map of rooms and you are in map[4][5]

    just myout<<mapx<<endl;
    then myout<<mapy<<endl;

  6. #6
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    would i need a seperate output for say monster in the room, what the room is like, what items you currently have etc etc? or can that be combined into one txt file? lol i would experiment but i'm adding spells

  7. #7
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    You should use
    #include <iostream> //Correct header
    using namespace std;
    instead of
    #include <iostream.h> //Deprecated header
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  8. #8
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    when i do that the program won't compile...

    [edit] huh well it did for once...

  9. #9
    Registered User jr2007's Avatar
    Join Date
    Oct 2003
    Posts
    16

    Thumbs up WOW

    That is amazing. Im trying to learn c++ since this morning and the best i can do is write code for the classic hello world by heart! How did u do it???

    Also, can i use sum of ur code to create a similar game but with a different genre???

  10. #10
    Registered User
    Join Date
    Oct 2003
    Posts
    9

    Re: WOW

    Originally posted by jr2007
    That is amazing. Im trying to learn c++ since this morning and the best i can do is write code for the classic hello world by heart! How did u do it???

    Also, can i use sum of ur code to create a similar game but with a different genre???
    er, sure i guess you can use some of the code, but a little comment about where it came from would be nice

    I'd have an update, however i'm having problems problems linking two er (noob alert lol) "source" file together, I have the other .cpp file all in place with the header and everything but when i compile, it gets to the new .cpp file (the one i'm trying to get the function from) and says function so and so undefined, probably a simple error, mis-spelled word somewhere.

  11. #11
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    I've been getting away from even using "using namespace std" because that sorta kills the purpose of it being in a namespace.

    Pretty good work. Just keep taking it step by step, from simple to complex, and you'll be using OpenGL or (I dare say) DirectX and making full 3D games, or maybe even 2D games with 3D effects applied, or full 2D games, or whatever.

    Oh, and just say no to mode 13h!

  12. #12
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Location
    Mt. Prospect, IL
    Posts
    2,572
    Some good work there...sorry for bing pessimistic but I don't believe you've done it just after a few hours of learning c++. If you did...my hats off to you friend.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  13. #13
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    Originally posted by axon
    Some good work there...sorry for bing pessimistic but I don't believe you've done it just after a few hours of learning c++. If you did...my hats off to you friend.
    thanks though

    int fewhours=8;

    or so hours

    I finally have a little free time and i'm starting to make some more progress on my game, I do have a few questions though:

    #1

    How do you get the program to read varibles from a file and then put them in the right spots in the program?

    #2

    How do you create a new file type (ie somthing that can't be edited in notepad)?

    #3

    Whats better for storing item/spell data, structs or arrays?

    Thanks for all the comments and any/all help!

  14. #14
    Spaced Cadet
    Join Date
    Aug 2003
    Posts
    110
    1. read about file I/O
    3. Structs IMO

    Code:
    ifstream read("he.ini");
    read >> player.race;
    read >> player.hp;
    ...
    read.close();
    This way it reads the file one word at a time, loading it into a variable.

    he.ini:
    Code:
    RaceName
    HP
    Edit: error in code, read ofstream, should be ifstream, fixed now.
    Last edited by Dark Nemesis; 10-31-2003 at 08:20 PM.

  15. #15
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    Thank you very much, I've started writing the rest of the game, it starting to come along and now that I know how to get the game to read saved data I can really start making some progress, thanks again!

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 20q game problems
    By Nexus-ZERO in forum C Programming
    Replies: 24
    Last Post: 12-17-2008, 04:48 PM
  2. beach bar (sims type game)
    By DrKillPatient in forum Game Programming
    Replies: 1
    Last Post: 03-06-2006, 12:32 PM
  3. PC Game project requires c++ programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 02-21-2006, 11:23 PM
  4. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-25-2006, 11:14 PM
  5. Lets Play Money Making Game
    By ggs in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-04-2001, 08:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21