What would I need to do to place several circles on the screen that would change color (red to green)? Can graphics like this be easily created in C? How about the use of a mouse?
C\C++ do not contain a standard graphics lib. I am assuming that you are coding with VC++ on the win32 platform. You must usually go though some sort of API that is not apart of the C\C++ standard library to perfrom bitmap manipulations,sprite bltting etc...On the win32 platform there are many graphics API's to choose from i.e. DirectDraw,OpenGL etc...But each of these api's diminish your programs device independence to some extent. Another API is the win32 GDI. This is what you can go through to perfrom any kind of grahical effects in windows. Of course this is not the only api to go through, and it certainly has it's downfalls( it's very very slow...), but it's a starting point. The above code just creates a window with the raw api. The user is able to click on the windows client area. With each click a randomly colored circle is drawn to the client area via GDI. I hope this gets you started in the right direction. Just create a win32 app. in VC++,copy and paste, then build. If you get errors during the build, you may need to change the source files .c extension to .cpp.
In case u r using borland c/c++ (any version), still u can do the same. I would suggest u go thru the book Programming in Turbo c/c++ by Robert Lafore. This book covers the basic requirements for graphics programming.
There may be other books which may also cover this topic, only i am not aware of.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.