I've got an assignment due very soon that I can't for the life of me figure out.
the basic idea is to create a program that allows the user to paint with large dots.
If the R key is down the dot should be red, if the B key is down the Dot should be blue, etc. The dot (size, color, everything) is defined in a separate header file.
So far I can make it paint the dots but only of a single color and with no key pressed. how would i go about changing the color based on a key press? I've tried storing the color name in a string but i couldn't seem to get that to work
If you're not sure what the goal is, this page has my professors example as a java applet
http://cs.ua.edu/351/S2012/Assignments/P2.htm
Any suggestions would be greatly appreciated.
This is the header file containing the dot class
using namespace System;
using namespace System::Drawing;
public ref class CMyDot {
public:
CMyDot(int x, int y) {
X=x;
Y=y;
}
int getX() { return X; }
void setX(int x) { X=x; }
int getY() { return Y; }
void setY(int y) { X=y; }
Color myColor = Color::White;
double distanceTo(int x, int y) {
return Math::Sqrt((X-x)*(X-x)+(Y-y)*(Y-y));
}
void draw(Graphics^ g) {
g->FillEllipse( gcnew SolidBrush(Color::Red ), X, Y, 50, 50 ); // Draw Color
}
private:
int X;
int Y;
};