#151780 - Alphanoob - Tue Mar 04, 2008 10:34 pm
This question, I am sure, is a rather simple one to answer, but I just cant see why it isnt working like I planned... so here it is. I was experimenting with movement, and made a quick program to make a 4 pixel square move around on the top screen in accordance with my keystrokes. I decided I wanted to make it display the x and y coordinates of it, and inserted printf("x-coordinate: %i\n", x); and printf("y-coordinate: %i\n", y); into my while loop. It displayed the coordinates, but every time it loops through the stuff, It prints again on a different line. I simply want the program to print each thing in one spot, and change as I move the square around. Anyone know what I am doing wrong?
#151812 - Dwedit - Wed Mar 05, 2008 5:09 am
(post edited)
Assuming you're using Libgba's or LibNDS's console:
Check "C:\devkitpro\examples\gba\graphics\ansi_console\source\console.c"
Code: |
// ansi escape sequence to clear screen and home cursor
// /x1b[line;columnH
iprintf("\x1b[2J");
// ansi escape sequence to set print co-ordinates
// /x1b[line;columnH
iprintf("\x1b[10;10HHello World!");
// ansi escape sequence to move cursor up
// /x1b[linesA
iprintf("\x1b[10ALine 0");
// ansi escape sequence to move cursor left
// /x1b[columnsD
iprintf("\x1b[28DColumn 0");
// ansi escape sequence to move cursor down
// /x1b[linesB
iprintf("\x1b[19BLine 19");
// ansi escape sequence to move cursor right
// /x1b[columnsC
iprintf("\x1b[5CColumn 20");
|
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#151850 - Alphanoob - Wed Mar 05, 2008 11:37 pm
I dont quite get what all that code does, and the guide I *was* using cut off halfway through tile graphics without once mentioning iprintf. sorry, but could you please explain it a little clearer?
#151857 - Alphanoob - Thu Mar 06, 2008 12:49 am
btw: am I posting all of these Q's on the wrong forum section?
#151859 - nanou - Thu Mar 06, 2008 1:25 am
Really, all you need to do is clear the screen and home the cursor at the top of each loop, or at least before you start printing again. The first example will do that for you, and then you can carry on as normal.
_________________
- nanou
#151864 - Alphanoob - Thu Mar 06, 2008 2:00 am
thanks, you guys rock. I think that I may actually get somewhere with my program now!
#151924 - Cisco - Thu Mar 06, 2008 7:53 pm
Hi
There is any escape code to change text colour to obtain a diferente colour in the same line or in differents lines, not the same colour in all the screen?