I have a program that computes basically a bouncy ball inside a fixed area, and if it has direct collision with stationary object it prints the collision info in a file... I have all the logic done but i want to get it to write the information in colums:
Number of moves to generate=100
Moving Object: x=1 y=8 x_movement=-1 y_movement=1
Stationary Object: x=1 y=10
Collision:1 Move:2 Location:2,5 Direction:5,2
Collision:2 Move:58 Location:4,2 Direction:2,3
A total of 2 collisions occurred in 100 moves.
However i keep getting my first row, pushed over like this :
Collision:1 Move:2 Location:2,5 Direction:5,2
Collision:2 Move:58 Location:4,2 Direction:2,3
How can i fix it ? Im using the setw(x) and it should work??
Code:if ((nextx==statx)&&(nexty==staty)){ // Direct collision collisions++; string loc, dir; loc= currentx + "," + currenty; dir= movx + "," + movy; output << left; output << setw(10) << "Collision:" << setw(10) << collisions << "Move:" << setw(10) << step << "Location:" << setw(10) << loc << "Direction:" << setw(10) << dir << endl; movx=-movx; movy=-movy; nextx=currentx+movx; nexty=currenty+movy;



LinkBack URL
About LinkBacks


