Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within C / C++
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide
this week in the
Programmer Certification
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
C / C++
Beginner in C++ Graphics programming(Simple Checkers Game)
kamal lamgade
Greenhorn
Posts: 16
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
So far I have able to draw one square from origin as attached in pic below. However I tried to make a grid for checker but couldn't I know it's using for loop and array but no idea where to start from?
#include "ccc_win.h" // GameDemo.cpp // Shows how to place a piece accurately on a grid after a mouse click. #include "ccc_win.h" // for graphics classes and functions using namespace std; int ccc_win_main(void) // main function for graphics program { double x, y; // mouse click position double px, py; // position of centre of circle // define window coordinate range from (0, 7) to (7, 0) cwin.coord(0, 8, 8, 0); cwin.clear(); // clear the window // draw a blue board rectangle with thick black border cwin << BrushColour(255, 0, 0) << PenColour(0, 0, 0) << PenWidth(3) << Rectangle(Point(0, 0), Point(8, 8)); // draw white circle at (1.5, 2.5) radius 0.4 and thin black border // this represents an unused position on the board cwin << BrushColour(255, 255, 255) << PenColour(0, 0, 0) << PenWidth(1) << Circle(Point(1.5, 2.5), 0.4); cwin<< BrushColour(255,255,0) << PenColour(0,0,0) << PenWidth(2) << Rectangle(Point(0,0) , Point(1,1)) ; do { // get the user’s next move, wait for mouse click Point p = cwin.get_mouse("You are RED, make a move"); // get exact x and y coordinates of mouse click x = p.get_x(); y = p.get_y(); // calculate required (rounded) position of user circle at px, py px = 0.5 + int(x); py = 0.5 + int(y); // draw yellow circle at exact clicked point p with radius 0.4 cwin << BrushColour(255, 255, 0) << PenColour(0, 0, 0) << PenWidth(1) << Circle(p, 0.4); // draw red circle at rounded position (px, py) with radius 0.4 cwin << BrushColour(255, 0, 0) << PenColour(0, 0, 0) << PenWidth(1) << Circle(Point(px, py), 0.4); } while (1); // loop forever! return 0; }
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Calling draw method (Graphics parameter)
Have a chess board, need help assigning values so GUI can update
addActionListener to the point
Need help on two compile errors
Mouse events
More...