SteveCRM
Feb 4th, 2001, 12:26 PM
Okay I've gotten a character to bounce around a console window...but now how do I make it stop flickering??? This for example:
#include <iostream.h>
#include <windows.h>
#include <conio.h>
int dummy;
void pause(unsigned long amount);
int main()
{
float Yspeed = 1;
float Xspeed = 1;
float x = 10;
float y = 10;
cout<<"o Mover: By Steve Mack"<<endl<<"Use the keypad to move (5 to exit)"<<endl;
pause(2000);
while(x!=1000)
{
int i;
for(i=1;i<=y+10;i++)
{
cout<<endl;
}
for(i=1;i<=x;i++)
{
cout<<" ";
}
cout<<"o"<<endl;
for(i=1;i<=25-y;i++)
{
cout<<endl;
}
x=x+Xspeed;
y=y+Yspeed;
if(x>=79 || x<=1)
{
Xspeed=Xspeed*-1;
}
if(y>=25 || y<=2)
{
Yspeed=Yspeed*-1;
}
pause(400);
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
}
cin>>dummy;
return 0;
}
void pause(unsigned long amount)
{ //creates a delay with the duration of amount.
unsigned long t = GetTickCount();
while((GetTickCount() - t) < amount);
}
feel free to play with the pauses(by denniswrenn), I want it to go pretty fast but without the flickering. :(
#include <iostream.h>
#include <windows.h>
#include <conio.h>
int dummy;
void pause(unsigned long amount);
int main()
{
float Yspeed = 1;
float Xspeed = 1;
float x = 10;
float y = 10;
cout<<"o Mover: By Steve Mack"<<endl<<"Use the keypad to move (5 to exit)"<<endl;
pause(2000);
while(x!=1000)
{
int i;
for(i=1;i<=y+10;i++)
{
cout<<endl;
}
for(i=1;i<=x;i++)
{
cout<<" ";
}
cout<<"o"<<endl;
for(i=1;i<=25-y;i++)
{
cout<<endl;
}
x=x+Xspeed;
y=y+Yspeed;
if(x>=79 || x<=1)
{
Xspeed=Xspeed*-1;
}
if(y>=25 || y<=2)
{
Yspeed=Yspeed*-1;
}
pause(400);
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
}
cin>>dummy;
return 0;
}
void pause(unsigned long amount)
{ //creates a delay with the duration of amount.
unsigned long t = GetTickCount();
while((GetTickCount() - t) < amount);
}
feel free to play with the pauses(by denniswrenn), I want it to go pretty fast but without the flickering. :(