the holy grail for newbie programmers...

This is a discussion on the holy grail for newbie programmers... within the C++ Programming forums, part of the General Programming Boards category; well, it may not be the holy grail for ALL newbie programmers, but it was my holy grail when i ...

  1. #1
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465

    the holy grail for newbie programmers...

    well, it may not be the holy grail for ALL newbie programmers, but it was my holy grail when i first started.

    i wanted to be able to make simple graphical games without having to learn a lot of complicated graphics stuff. i would ask about graphics and the veteran programmers would always tell me "you arent ready for that yet".

    in a way, they were right. I wasnt ready for the graphics that the big boys use. DirectX or OpenGL would have made my head explode back then. but i didnt want that. i just wanted to make dinky, interesting little games to show off to my friends. is that too much to ask?

    not anymore. for a couple of days i have been working on a display class and an animation class that allows you to easily handle ASCII console graphics ( in other words, letters and symbols of different colors used to represent things on the screen ). it has no flicker and almost completely does away with having to know all of the complicated stuff just to put some pretty things on the screen and make it move at will. with little more than knowlege of basic C++, you can be writing nifty ( though simple ) programs to show off to your non programmer friends. if youre fairly new to C++ you should check it out.

    all you have to do to use my classes is put Display.h, Display.cpp, Anim.h, and Anim.cpp into your project, then just include Display.h and Anim.h wherever you need access to them and create instances of them in your game.

    some things you WILL have to know are as follows:

    the COORD type. all it is, really, is a simple structure that holds an X and a Y. my classes use it a lot, so if youre going to use them i reccomend getting familiar with this variable type. you create a COORD like this:

    Code:
    COORD coord;
    or to initialize it right off, you do this:

    Code:
    COORD coord = { 0, 0 };
    then, to access its X and Y values, all you have to do is put '.X' or '.Y' after your variable name, like so:

    Code:
    COORD coord = { 0, 0 };
    
    int x = coord.X;
    int y = coord.Y;
    another thing you need to be familiar with is the concept of a buffer. here, its pretty simplified. a buffer is merely what the computer is planning on showing to the screen before it shows it. thats a dumbed down version, but it gets the point across.

    doing calculations takes almost no time for the computer, but it takes a lot longer to constantly draw information to the screen. you use a buffer to figure out what the screen is going to look like by doing all of the behind the scenes transformations, and then when you have the picture like you want it, you output the whole buffer at once to the screen.

    your buffer can also extend beyond the screen, and you can chose which part of the buffer to draw. the Display class handles all of that, but it helps to know a little bit about what its doing before trying to use it.

    the animation class is also fairly simple. you create a frame of animations in a 2D character array, like so:

    Code:
    char * frame1[] =
    {
       "  O  ",
       "--|--",
       " / \\ "
    };
    then you create an instance of the Anim class to hold the frames of the animation you want ( in the order you want them shown ).

    Code:
    Anim man;
    
    // pass in the frame itself, and the size of the frame
    man.addFrame( frame1, sizeof frame1 );
    then, when you want to play through the animation, you put a line of code similar to this in your program:

    Code:
    Display d;
    
    // pass in the animation frame, the color, the size of the frame, 
    // and the position on the buffer.
    d.fgItem( man.animate(), FGWhite, man.getCurrentFrameSize(), position );
    the animation class will send the current frame and then automatically incriment it to the next frame.

    whew, that was a lot of talking, and i realize i havent even gotten a fraction of the way through with explaining my classes.

    if youre still not 100% certain how to get this working, ive included a couple of example games to get you started. feel free to modify them and get comfortable with how they work. the code for the games themselves are probably not the best examples of good programs. they were put together rather hastily and if it werent for the Display and Anim classes, they may as well have been written in C.

    anyway, hope you enjoy the work ive done. let me know of any comments, the classes are still in development. im currently working on giving my display class the ability to display things in 3D (yes, i said 3D in referance to console. I have seen it done before and it will be done again! )

    edit: also, all of the colors are defined at the beginning of Display.h. black is simply 0.
    and another thing, using these classes i can easily push 2000+ frames per second. you may want to put a delay of some sort in your main game loop.
    and another edit:
    disregard the engine.cpp file in my zip. that was my old Display class before i changed the name from engine to Display.
    Attached Files Attached Files
    Last edited by ...; 09-01-2003 at 09:11 AM.
    I came up with a cool phrase to put down here, but i forgot it...

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    Hrmmpf, 102 views and not one reply?

    Any chance we can get instructions on how to compile this stuff?

  3. #3
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    hate to bump from so far back, but this one applies to me...

    what about it wont compile? i forgot to mention that this was written with Visual C++.NET, and while im pretty sure it will work for most previous versions of MSVC, im not sure about other compilers...
    I came up with a cool phrase to put down here, but i forgot it...

  4. #4
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    im going to go ahead and include the most recent version of these classes. im not sure if its a whole lot different ( i think i just added another function for the display class ) but it includes a readme that goes into more depth about how to use the classes.
    Attached Files Attached Files
    I came up with a cool phrase to put down here, but i forgot it...

  5. #5
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    I was messing with the search thingy. Could you do 3d with this?

    ex.
    Code:
    COORD coord = {1, 2, 3};

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cprogra
    By BobMcGee123 in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 05-05-2006, 04:34 PM
  2. PC Game project requires c++ programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 02-22-2006, 12:23 AM
  3. Looking for the Holy Grail...
    By Sebastiani in forum Windows Programming
    Replies: 2
    Last Post: 01-07-2003, 01:37 AM
  4. Programming Puns
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 03-23-2002, 04:38 PM

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