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

Author
Message
Citokre
10
Years of Service
User Offline
Joined: 26th Mar 2014
Location: Centreville, VA
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 displayMenu();
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)
{
//Display the menu
displayMenu();

//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;
Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
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" ~ Jerilith the Mad
Citokre
10
Years of Service
User Offline
Joined: 26th Mar 2014
Location: Centreville, VA
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 displayMenu();
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)
{
//Display the menu
displayMenu();

//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
void displayMenu()
{
dbPrint();
dbPrint("Make a selection: ");
dbPrint("1 = Square");
dbPrint("2 = Circle");
dbPrint("3 = Ellipse");
dbPrint("4 = Exit Program");
}
Citokre
10
Years of Service
User Offline
Joined: 26th Mar 2014
Location: Centreville, VA
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
Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
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" ~ Jerilith the Mad

Login to post a reply

Server time is: 2024-11-18 21:28:06
Your offset time is: 2024-11-18 21:28:06