I've written this code to practice console programming and for using it as a library for the programs that may need it. I included three files. CG.cpp, its header and a tester program that uses CG functions. I am reading a beginners tutorial that told me to create this application but it used gtoxy() that was out of my reach. If you remember, I came to forum and asked about it. Forum led me to adrianxw tutorial. I learned many new functions from it. So I decided to change the whole code of CG.cpp to use windows console functions. I tried to use all Windows console capabilities to create a more efficient program, so added color support and a new delay function that could use Sleep() function in order to make delays smaller than one second in windows if needed, while keeping the compatibility with other environments. I also used events in order to get characters from user without showing them on screen. The color function will get two arguments, for foreground and background colors. The range is 0-14, if you give the fg argument greater than 14, it will not change the fg color. The tester program manual is below:
'J'=Up ; 'M'=Down ; ','=Right ; 'N'=Left
Numbers: select the color of foreground and background
'B'=Switch to bg colors ; 'F'=Switch to fg colors
'E'=Erase ; 'D'=Draw
'P'=Clear screen ; 'I '=Fill screen
How to use:
Use directional keys to draw what you want. You can change foreground and background color by pressing num keys. The program is easy to work with, I think easier than reading my text.
Please inform me about mistakes, or any idea you had.
i think everything looks really good
We should trust The Brain.
I updated the program, take a look at this one. Some error checking and manual resizing added.