I'm working on a text adventure game at the moment, its in its very early stages but something I would like to add to it would be a "compass" of sorts that sits in the top right hand corner of the screen and depending on your actions and movements it changes the direction it points.
I can draw one using CIRCLE and LINE comands (it only has to point 4 directions) but I have the problem of refreshing it so it points a new direction. If I use CLS then redraw it then it clears all my previous text as well which is no good. I could draw a "black" line over the top of the unwanted 3 directions each time I want the compass to point somewhere new, but thats messy. Is there any way to clear a small section of the screen only, or un-draw a line that has been placed?
Any help is much appreciated, I know this is a proper noob question!
By the way this is the code I have at the moment (which I then work into my text adventure with each option chosen and obviously edited to take the PRINT commands out)
CLS SCREEN 20 DIM direction AS STRING CIRCLE (950, 60), 50, 4 program: INPUT "Would you like to go North, South, East or West"; direction SELECT CASE UCASE(direction) CASE "NORTH" PRINT "This should put a line for North" LINE (950, 10)-(950,60) ' White pointer line LINE (950, 60)-(950,110), 0 'black south line LINE (950, 60)-(1000,60), 0 'black east line LINE (900, 60)-(950,60), 0 'black west line GOTO program CASE "SOUTH" PRINT "This should put a line for South" LINE (950, 60)-(950,110) 'South line LINE (950, 10)-(950,60), 0 'Black north line LINE (950, 60)-(1000,60), 0 'Black east line LINE (900, 60)-(950,60), 0 'Black west line GOTO program CASE "EAST" PRINT "This should put a line for EAST" LINE (950, 60)-(1000,60) 'East line LINE (950, 60)-(950,110), 0 'Black South line LINE (950, 10)-(950,60), 0 'Black north line LINE (900, 60)-(950,60), 0 'Black west line GOTO program CASE "WEST" PRINT "This should put a line for WEST" LINE (900, 60)-(950,60) LINE (950, 60)-(1000,60), 0 'Black East line LINE (950, 60)-(950,110), 0 'Black South line LINE (950, 10)-(950,60), 0 'Black north line GOTO program CASE ELSE END END SELECT
It works but its messy. I'll probably have to make the whole thing a sub program to put it inside the text adventure itself, but thats ok.
Any suggestions? Thanks!
edit by hartnell. put code in code tags.
Well, what I'd think is that you should be CLSing every time you're about to make any changes to what's being displayed, then redraw everything from scratch. So assuming that the main program code there is going to be running in a loop, just putting a CLS at the start of it should work, assuming that that's the only things you want displayed. Otherwise, any extra text/objects to display should just be put after that section, so they still get redrawn.
Sorry if I confuse you, I'm not the greatest with explanations. :P
Hmm… cheers for the advice, but if I use CLS then it clears all my text off the screen as well. Being a text adventure I want to keep at least the last couple of "moves" on the screen so players can keep track of what they are doing. If worst comes to worst it wont kill it to have the text be cleared and re-printing the latest move… think I will just keep playing with it for now! Thanks for the help!
Use Locate to "write over" the compass area with blank spaces. Let's say that that the compass area is about four character wide, then try :
Locate compassY, compassX Print " "
This will require some fine-tuning by you.
Legend! That'll work, then I can just redraw the compass over the blank spaces! Thanks!
Does anyone know of any tutorials on locking/unlocking the screen, buffers etc?
Are you working in FreeBASIC? I'm not for sure if you said for certain. —hartnell
Many of the tutorials of QBExpress will be of interest to you. I know the name may sound like QBExpress is about QBasic. However, it's mostly about FreeBASIC :
I'm sure there's a tutorial there that will help you. (Sorry, haven't worked with FB lately.)