connect the dots

I am working on a program using darkGDK that is to allow the user to click points on the screen and write them to a file. Then it opens the file and uses the points clicked to draw lines between them. I am having trouble getting a straight line, for some reason it is "recording" the entire movement of the mouse instead of just the points that are clicked.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "DarkGDK.h"

//Declare Constants
const int FILE_NUM = 1;
const int REFRESH_RATE = 60;
bool mouseFullClick(int &, int &);

//Function Prototype
void setUp();
void openInputFile();

/***********************************************************
DarkGDK Function
***********************************************************/
void DarkGDK()
{
	//Declare variable for mouses X and Y position.
	int mouseX, mouseY;
	
	//Variable to hold the starting X and Y click.
	int x, y;
	
	//Start and end point holders.
	int startX, startY, endX, endY;
	

	setUp();
	
		while(LoopGDK() && !dbSpaceKey())
			{
				if( mouseFullClick(mouseX, mouseY) );
			{
				mouseX = dbMouseX();
				mouseY = dbMouseY();

				//Write the mouse clicks to file.
				dbWriteFile(FILE_NUM, mouseX);	
				dbWriteFile(FILE_NUM, mouseY);
			}
			dbSync();
			}

			dbSyncOff();
			dbCloseFile(FILE_NUM);
			dbCLS();
			openInputFile();
			
			if(!dbFileEnd(FILE_NUM))
				{
					x = dbReadFile(FILE_NUM);
					y = dbReadFile(FILE_NUM);
				}

			while(!dbFileEnd(FILE_NUM))
				{
					//Set the lines starting and ending line coordinates.
					startX = x;
					startY = y;
					endX = dbReadFile(FILE_NUM);
					endY = dbReadFile(FILE_NUM);
					
			if(endX < 640)
				{
					//Draw the line
					dbLine(startX, startY, endX, endY);

					//Set the next starting coordinates to the ending coordinates of
					//the previous line drawn.
					x = endX;
					y = endY;
				}
			}
			//Close File.
			dbCloseFile(FILE_NUM);

			dbCenterText(319, 440, "Press Any Key To Exit The Program.");

			dbWaitKey();
			}

void setUp()
{
	if(dbFileExist("GameData.dat"))
		{
		//If the MouseCoordinates.dat exists delete it.
		dbDeleteFile("GameData.dat");

		//Open a output file to store mouse clicked
		//X and Y coordinates.
		dbOpenToWrite(FILE_NUM, "GameData.dat");
		}
	else //If the file does not exist open output file
		{
		//Open a output file to store mouse clicked
		//X and Y coordinates.
		dbOpenToWrite(FILE_NUM, "GameData.dat");
		}
		
	//Set the window Title
	dbSetWindowTitle("Connect The Dots");
	
	//Prompt the user to click the mouse anywhere on the screen
	dbCenterText(319, 40, "Click Multiple Points Anywhere On The Screen.");

	//Prompt the user to press the space bar when he is done.
	dbCenterText(319, 449, "Press The Space Bar When You Are Done.");


	dbSyncOn();
	dbSyncRate(REFRESH_RATE);
}


void openInputFile()
{
	//Check if the file exists.
	if(dbFileExist("GameData.dat") )
	{
		//Open the input file.
		dbOpenToRead(FILE_NUM, "GameData.dat");
	}
		else	//the file does not exist 
		{
		//Print an error message.
		dbPrint("Error! The file does not exist.");	
	}
}

	bool mouseFullClick(int &x, int &y)
	{
		bool buttonClick = false;
			if ( dbMouseClick() == 1 )
			{
				x = dbMouseX();
				y = dbMouseY();

				while ( dbMouseClick() == 1)
				{
					//do nothing here
				}
				buttonClick = true;
			}
			return buttonClick;
	}
closed account (zb0S216C)
Posting 144 LOC, paired with a 4 line description, is going to get you ignored. You need to narrow down the scope so that we can home in on the problem.

Wazzak
well i thought that it was fairly specific, the mouse movement is being written to the file and not the mouse clicks. The whole code is there for reference or maybe there's a problem in multiple places. I need the mouse CLICKS to be written to the file and then read and a line drawn between all the points clicked by the user.
Topic archived. No new replies allowed.