making a char move across screen

I was trying to make a character, a c in this case, move across the screen. I thought that I could use a for loop with a variable and then use that variable as the field width of my c. Unfortunately for some reason i got c's all over the place and not in a straight line. Does anyone no why?

Comments

[b][red]This message was edited by Phat Nat at 2003-4-4 14:1:6[/red][/b][hr]: I was trying to make a character, a c in this case, move across the screen. I thought that I could use a for loop with a variable and then use that variable as the field width of my c. Unfortunately for some reason i got c's all over the place and not in a straight line. Does anyone no why?: : [code]: program move;: : var: position : integer;: thing : string;: timer : integer;: blank : string;: : begin: : thing := 'c';: blank := ' ';: : for position := 1 to 80 do: begin : write(thing:position);: for timer := 1 to 600: begin: end;: write(blank:position): end;: end.: : [/code]

Your problem is that you are writing a "c" and then writing a " " right after it and then repeating this. Try doing it like this:

This will set the cursor back to the place were it was so it will actually erase the old "c" before doing the next one. Also, your timer wait command probably won't work too well unless your running an extremely old computer. Try [b]delay(10);[/b] or put a couple of loops in:[code]VAR X, Y : Word;Begin For Y := 0 to 200 Do For X := 0 to 64000 Do;End;[/code]This should give you a decent speed, but it will change from computer to computer. Anyways, this should solve your problem.

: [b][red]This message was edited by Phat Nat at 2003-4-4 14:1:6[/red][/b][hr]: : I was trying to make a character, a c in this case, move across the screen. I thought that I could use a for loop with a variable and then use that variable as the field width of my c. Unfortunately for some reason i got c's all over the place and not in a straight line. Does anyone no why?: : : : [code]: : program move;: : : : var: : position : integer;: : thing : string;: : timer : integer;: : blank : string;: : : : begin: : : : thing := 'c';: : blank := ' ';: : : : for position := 1 to 80 do: : begin : : write(thing:position);: : for timer := 1 to 600: : begin: : end;: : write(blank:position): : end;: : end.: : : : [/code]: : Your problem is that you are writing a "c" and then writing a " " right after it and then repeating this. Try doing it like this:: : [code]: [b]USES Crt;[/b]: var: position : integer;: thing : string;: timer : integer;: blank : string;: : begin: thing := 'c';: blank := ' ';: : for position := 1 to 80 do: begin : [b]gotoxy(x,1);[/b]: write(thing:position);: for timer := 1 to 600: begin: end;: [b]gotoxy(x,1);[/b]: write(blank:position): end;: end.: [/code]: : This will set the cursor back to the place were it was so it will actually erase the old "c" before doing the next one. Also, your timer wait command probably won't work too well unless your running an extremely old computer. Try [b]delay(10);[/b] or put a couple of loops in:: [code]: VAR: X, Y : Word;: Begin: For Y := 0 to 200 Do: For X := 0 to 64000 Do;: End;: [/code]: This should give you a decent speed, but it will change from computer to computer. Anyways, this should solve your problem.: : Phat Nat: : : : thanks I was getting really confused.fred