BBC BASIC for Windows
Programming >> Graphics and Games >> CLS specific co-ordinates http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1350681639 CLS specific co-ordinates
Post by Usama Amin on Oct 19th, 2012, 9:20pm
Hey guys, I'm new to programming and i've started to make a Space invaders game and wanted to know if there's any way to clear only a row (e.g. Row 23 or something)? Re: CLS specific co-ordinates
Post by admin on Oct 20th, 2012, 09:18am
I'm new to programming and i've started to make a Space invaders game and wanted to know if there's any way to clear only a row (e.g. Row 23 or something)? :)
If you're working with text coordinates the easiest way is probably to overwrite the row with spaces. So if the text viewport is 80-characters wide you could do:
Code:
PRINT TAB(0,23) SPC(80);
That will clear the row to the current text background colour. If you've switched into the 'write text at graphics cursor' mode (VDU 5) you will need to temporarily switch back to VDU 4 mode to make it work:
Code:
VDU 4
PRINT TAB(0,23) SPC(80);
VDU 5
Or even combine everything into a single PRINT:
Code:
PRINT CHR$(4) TAB(0,23) SPC(80) CHR$(5);
Another way is to temporarily set a text viewport covering the row(s) you want to clear, and then do a CLS (VDU 12). Afterwards you can restore the text viewport to the entire window (VDU 26) or set a new one:
Code:
VDU 28,0,23,79,23,12,26
If you're working with graphics coordinates then you can clear the row using a RECTANGLE FILL, for example:
Code:
RECTANGLE FILL 0,0,1280,40
That will clear the bottom row to the current graphics foreground colour (assuming a width of 640 pixels and a row height of 20 pixels).
Richard.
Re: CLS specific co-ordinates
Post by Usama Amin on Oct 21st, 2012, 09:14am