User input and classes

I only have basic understanding of c++. I was wondering if someone could help me figure out how to get the user to input the velocity values themselves and then have the animation play when enter is pushed. I have set velocity values of 0.025 and 0.02, but I want the user to input values between 0.01 - 1.0.

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
 #include "stdafx.h"

//Point Position
float xpos = 0;
float ypos = 0;

//Point Velocity
float xvel = 0.025;
float yvel = 0.02;

//Class
class cPointVelocity


//RenderScene
void renderScene()
{
	// clear the back buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	//Create Point
	glBegin(GL_POINTS);
        glPointSize(20);
	
	glColor3f( 1.0f, 1.0f, 1.0f );
	glVertex2f( xpos, ypos );

		//Point Bounce (x,y axis)
		xpos = xpos + xvel;
		ypos = ypos + yvel;

		if(xpos >= 500)
		{
			xvel = -xvel;
		}
		if(xpos <= -500)
		{
			xvel = -xvel;
		}
		if(ypos >= 500)
		{
			yvel = -yvel;
		}
		if(ypos <= -500)
		{
			yvel = -yvel;
		}

	glEnd();
	
	// swap the buffers of the current window
	glutSwapBuffers();
}



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
// _tmain() - program entry point

int _tmain(int argc, _TCHAR* argv[])
{	
	// initialise the glut library
	glutInit(&argc, argv);

	// set up the initial display mode
	// need both double buffering and z-buffering
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

	// set the initial window position
	glutInitWindowPosition(100, 100);

	// set the initial window size
	glutInitWindowSize(500, 500);

	// create and name the window
	glutCreateWindow("Motion Blur Swipe Trails!");

	// reshape callback for current window
	glutReshapeFunc(winReshapeFunc);

	// set display callback for current window
	glutDisplayFunc(renderScene);	

	// set up the global idle callback
	glutIdleFunc(update);

	// enter the glut event processing loop
	glutMainLoop();	

	return 0;
}
http://www.cplusplus.com/doc/tutorial/basic_io/

You simply get input and update the xvel/yvel before the action starts.
Topic archived. No new replies allowed.