# Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

### Dark GDK / DarkGDK help

Message
Posted: 26th Mar 2014 03:45
So I'm working on a menu program for a class I'm taking, and I'm stuck. There are 4 choices on the menu (no prob), 1 will prompt the user for coordinates and draw a square, 2 a circle, 3 and ellipse, and 4 exits.

I'm stuck on getting the square to draw, I have tried several different things but each time I can only get 1 line of the square drawn. Any insight?

Here's the code up through the square
#include "DarkGDK.h"

//Function prototype
void drawSquare(int, int);

//DarkGDK function
void DarkGDK()
{
//Constant for time delay
const int TWO_SECONDS = 2000;
const int WIDTH = 50;
const int HEIGHT = 50;

//Variable to hold the user's selection
int selection = 0;
int x1;
int y1;
int x2;
int y2;

//Let the user make selections from the menu, a selection of 4 ends the program
while (selection != 4)
{

//Get their selection
selection = atoi( (dbInput() ));

//Process that selection
switch (selection)
{
case 1:
dbPrint("What is the first X coordinate of your square?");
x1 = atoi( (dbInput() ));
dbPrint("What is the first Y coordinate of your square?");
y1 = atoi( (dbInput() ));
dbPrint("What is the second X coordinate of your square?");
x2 = atoi( (dbInput() ));
dbPrint("What is the second Y coordinate of your square?");
y2 = atoi( (dbInput() ));

//Drawing the square
dbLine(x1, y1, x2, y1); // Top
dbLine(x2, y1, x2, y2); // Right
dbLine(x2, y2, x1, y2); // Bottom
dbLine(x1, y2, x1, y1); // Left
break;
Posted: 26th Mar 2014 18:22
what part is not working?

Can you enter the information into your program?

There are many answers but just one question&quot; ~ Jerilith the Mad
Posted: 26th Mar 2014 22:16
Here's the full program as-so-far to the extent it will run. When selecting the "Square" option and I give it the coordinates, it only seems to do the top line, so I'm guessing my problem lays with getting the information to the remaining 3 dbLine functions.

#include "DarkGDK.h"

//Function prototype
void drawSquare(int, int);

//DarkGDK function
void DarkGDK()
{
//Constant for time delay
const int TWO_SECONDS = 2000;
const int WIDTH = 50;
const int HEIGHT = 50;

//Variable to hold the user's selection
int selection = 0;
int x1;
int y1;
int x2;
int y2;

//Let the user make selections from the menu, a selection of 4 ends the program
while (selection != 4)
{

//Get their selection
selection = atoi( (dbInput() ));

//Process that selection
switch (selection)
{
case 1:
dbPrint("What is the first X coordinate of your square?");
x1 = atoi( (dbInput() ));
dbPrint("What is the first Y coordinate of your square?");
y1 = atoi( (dbInput() ));
dbPrint("What is the second X coordinate of your square?");
x2 = atoi( (dbInput() ));
dbPrint("What is the second Y coordinate of your square?");
y2 = atoi( (dbInput() ));

//Drawing the square
dbLine(x1, y1, x2, y1); // Top
dbLine(x2, y1, x2, y2); // Right
dbLine(x2, y2, x1, y2); // Bottom
dbLine(x1, y2, x1, y1); // Left
break;

case 2:
//Will be a circle
break;

case 3:
//Will be an Ellipse
break;

case 4:
dbPrint("Goodbye!");
dbWaitKey();
}
}
}

//The display menu function displays the menu choices the user can select from
{
dbPrint();
dbPrint("Make a selection: ");
dbPrint("1 = Square");
dbPrint("2 = Circle");
dbPrint("3 = Ellipse");
dbPrint("4 = Exit Program");
}
Posted: 26th Mar 2014 23:25
Never mind, I did have it right. I just pulled a total space cadet and got the y2 coordinate wrong.

...been a long week so far. lol
Posted: 28th Mar 2014 00:58 Edited at: 28th Mar 2014 01:30
Well sometimes just posting and reviewing the code helps. Good luck. Oh and welcome to the forums.

There are many answers but just one question&quot; ~ Jerilith the Mad