I've seen programs before such as games which display text e.g score,user,etc.. The text is display on the screen but it can be changed without redisplaying it.For example the score will just increase without changing where it is.
I've seen programs before such as games which display text e.g score,user,etc.. The text is display on the screen but it can be changed without redisplaying it.For example the score will just increase without changing where it is.
What you can do is use gotoxy(x,y) to move to that section of the screen, then update the score or whatever and then use the function again to move back to where you want. You can use this in a loop to continually update the score.
- Sean
If cities were built like software is built, the first woodpecker to come along would level civilization.
Black Frog Studios
does that work in non-gui apps?
>does that work in non-gui apps?
Yes, but it is platform dependent. If you use a Borland compiler then you will already have gotoxy defined in conio.h, otherwise you will have to write it yourself either with the Windows API for Windows systems or another method for other systems (curses are always a good bet).
-Prelude
My best code is written with the delete key.
Early versions of Microsoft's C / C++ compilers had _settextpostion(x,y) defined in graphics.h or graph.h I forget. However, I found that in pure dos I could use inline assembly for much of the con i/o. I don't know if this is acceptable programming or not, but it works for me using MSVC 1.0
This will cause a general protection fault in windows though if compiled using MSVC 6 and as a console app.Code:void setCusor(int x, int y); void setCursor(int x, int y) { _asm { mov ah,2 xor bx,bx mov dh,byte ptr x mov dl,byte ptr y int 10h } }
I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P
This thing will crash when compiled in 32bit MSVC 6.0Code:void setCursor(int x, int y) { _asm { mov ah,2 xor bx,bx mov dh,byte ptr x mov dl,byte ptr y int 10h } }
I think that you can't use interrupts like that
only building it with 16 bit compiler will do the job...
Win32API is not using any interrupts like
DOS programming...
(meaning that you won't program with interrupts
not that the Win is not using them at all)
>This thing will crash when compiled in 32bit MSVC 6.0
I tried the setCursor code on a Windows NT computer. It didn't crash, but it didn't move the cursor either. I wish it would have worked.
>>..I tried the setCursor code on a Windows NT computer. It didn't ...
Well it does to my Win98...
May be NT is preventing it somehow...
(hmm... may not those are interrupts!)
guys, I pointed out that this code will not work with a 32 bit compiler it uses 16 bit registers directly. It was compiled as a 16 bit dos app using MSVC 1.0.
I use it as
The 0 is used to set the active page... though that code snippit is not included in the code above.Code:setCursor(12,30,0), printf("Text String");
I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P
I would suggest using gotoxy(). This will work on newer machines, but beware of strange behaviour when out-of-bound coords are used!
Mainly though, the real difficuty lies in the fact that for many applications, the updating should be run in it's own thread. This allows non-interrupted refreshes that do not depend on the main program "loop". Threads are amazingly easy to set up and shut down. Look up CreateThread(), GetExitCodeThread(), and others as well...