Increasing/Decreasing Variable

Ok so I made a class. The class contains code to draw a 3d car. I'm supposed to make it so there are cars going in both directions on a street. I called the cars so they're in their starting positions. I also made it so they all move. The problem I'm facing now is calling more cars over and over so it looks like it won't ever stop.

My professor said, "The cars are all
controlled by global variable incrementing/decrementing."

Right now after the 8 cars I called for both directions move, after the last car is nothing. Anyone have an idea how to do this?
It's a very vague description ...

I usually change the coordinate of the car directly so after they disappear at the end of the right screen, I change the position to just before they appear on the left screen..

I usually do this b/c it's just for show, does it really have to be a different car everytime ? If so destroy the car that have disappear at the end the screen and make a new one...

I know my answer is not really helping ,
Perhaps show more of your code ?
Yeah sorry, I was on my way to work. Didn't have my main.cpp. I'll post the important parts after I get home. But yeah that's what I feel too. I wish he would have told me a little more. His answers have been becoming vague.
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

//global variables
Car objects(0.0, 0.0, 0.0, 100.0, 50.0, 0.0);
Car objects1(150.0, 0.0, 0.0, 100.0, 50.0, 0.0);
Car objects2(300.0, 0.0, 0.0, 100.0, 50.0, 0.0);
Car objects3(450.0, 0.0, 0.0, 100.0, 50.0, 0.0);
Car objects4(600.0, 0.0, 0.0, 100.0, 50.0, 0.0);
Car objects5(-150.0, 0.0, 0.0, 100.0, 50.0, 0.0);
Car objects6(-300.0, 0.0, 0.0, 100.0, 50.0, 0.0);
Car objects7(-450.0, 0.0, 0.0, 100.0, 50.0, 0.0);
Car objects8(-600.0, 0.0, 0.0, 100.0, 50.0, 0.0);

Car objects9(0.0, 0.0, -125.0, 100.0, 50.0, 0.0);
Car objects10(150.0, 0.0, -125.0, 100.0, 50.0, 0.0);
Car objects11(300.0, 0.0, -125.0, 100.0, 50.0, 0.0);
Car objects12(450.0, 0.0, -125.0, 100.0, 50.0, 0.0);
Car objects13(600.0, 0.0, -125.0, 100.0, 50.0, 0.0);
Car objects14(-150.0, 0.0, -125.0, 100.0, 50.0, 0.0);
Car objects15(-300.0, 0.0, -125.0, 100.0, 50.0, 0.0);
Car objects16(-450.0, 0.0, -125.0, 100.0, 50.0, 0.0);
Car objects17(-600.0, 0.0, -125.0, 100.0, 50.0, 0.0);

Terrain ground(0.0, 0.0, 0.0, 1500.0, 1500.0, 0.0);

Terrain road(0.0, 5.0, 0.0, 1500.0, 250.0, 1.0);

Terrain roadLine(0.0, 5.0, 0.0, 50.0, 10.0, 5.0);

Terrain building1(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building2(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building3(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building4(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building5(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building6(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building7(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building8(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building9(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building10(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building11(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building12(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);
Terrain building13(0.0, 40.0, -200.0, 50.0, (rand() % 75 + 100), 50.0);

Airplane plane(200.0, 0.0, 300.0, 25.0, 150.0, 5.0);

void renderFrame(float lastFrameDuration) {

	setColor(1.0, 0.0, 0.0);
	drawText(300.0, 750.0, "Welcome to Liberty City");

	glClearColor(.52, .80, .97, 1.0);

	enable3d();
	setWireframeRendering(false);
	glPushMatrix();
	glRotatef(10.0, 1, 0, 0);

	objects.drawCar();
	objects1.drawCar();
	objects2.drawCar();
	objects3.drawCar();
	objects4.drawCar();
	objects5.drawCar();
	objects6.drawCar();
	objects7.drawCar();
	objects8.drawCar();

	objects9.drawCar1();
	objects10.drawCar1();
	objects11.drawCar1();
	objects12.drawCar1();
	objects13.drawCar1();
	objects14.drawCar1();
	objects15.drawCar1();
	objects16.drawCar1();
	objects17.drawCar1();

	road.drawRoad();

	ground.drawTerrain();

	roadLine.drawRoadLine();

	building1.drawBuilding1();
	building2.drawBuilding2();
	building3.drawBuilding3();
	building4.drawBuilding4();
	building5.drawBuilding5();
	building6.drawBuilding6();
	building7.drawBuilding7();
	building8.drawBuilding8();
	building9.drawBuilding9();
	building10.drawBuilding10();
	building11.drawBuilding11();
	building12.drawBuilding12();
	building13.drawBuilding13();

	plane.drawAirplane();

	glPopMatrix();
	disable3d();
}


Ok this is what my main.cpp looks like. As you can see I have 9 cars that go left and 9 cars that go right. Then after they are finished going across the screen theres just empty space. I need it so that they just keep coming across the screen and don't stop.
Topic archived. No new replies allowed.