PDA

Click to See Complete Forum and Search --> : I'm clueless to whats happening


SteveCRM
Feb 1st, 2001, 06:06 PM
Okay...this program is [i]supposed[/] to bounce an asterisk (*) around in a console. It only moves back and forth and leaves a trail. But the console comes up blank...but little lines move accross the bottom??? :confused:


#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
cout<<"Welcome to dot mover!"<<endl<<"press '4' and '6' to move"<<endl;
int i;
int theChar;
int position=5;
int direction = 2; //1 = right 2 = left
while(theChar!=0)
{
if(direction==2)
{
for(i=i;i<position;i++)
{
cout<<" ";
if(position==80)
{
direction=1;
}
}
cout<<"*"<<endl;
}
getchar(theChar);
if(direction=1)
{
for(i=i;position<1;i--)
{
cout<<" ";
if(position==80)
{
direction=2;
}
cout<<"*"<<endl;
}
}
}
return 0;
}

nukem996
Feb 1st, 2001, 07:00 PM
i just learned c++ this summer. but i did win best program with my robot program. to move a "0" around a field of "1" or its the other way around. if u want the code ill try to dig it up.
i think it sounds like what u want.

SteveCRM
Feb 3rd, 2001, 01:21 PM
That would be great thanks! How did you do it? just redraw the 80*(12 is it?) characters each loop?

Thanks again :D