Hi there kRx
I've slightly modified your code so that when you select (press Enter) on the "Attack" option, the box pops up and when you select the "Magic" or "Item" option, the box disappears. I hope this is what you want it to do
`setup
sync on : sync rate 30 : set display mode 800,600,16
`end setup
`creates an array to store keypresses
dim key(250) : dim oldkey(250)
`sets up initial HP
hp = 100
`Enemy Stats
ename$ = "Robot"
text 300,500,"hp"
` set 'select'
selectt = 1
do
`clear screen
cls
`checks for key press to stop repeated presses
for a = 1 to 250
if key(a) = 1 then oldkey(a) = 1
if keystate(a) = 1 and oldkey(a) = 0 : key(a) = 1 : else : key(a) = 0 : endif
if keystate(a) = 0 then oldkey(a) = 0
next a
`calls battle command function
battlecommand() = 1
commandbox()=1
`end function call
`select attack etc calls when downkey=1 down to magic etc
if commandbox()=1 then selectt = 1
if selectt = 1
ink rgb(255,255,255),0
text 10,10,"Attack"
ink rgb(128,128,0),0
text 10,30,"Magic"
text 10,50,"Item"
else
if selectt = 0
ink rgb(128,128,0),0
text 10,10,"Attack"
endif
endif
if selectt = 2
ink rgb(255,255,255),0
text 10,30,"Magic"
ink rgb(128,128,0),0
text 10,10, "Attack"
text 10,50, "Item"
else
if selectt < 0
ink rgb(128,128,0),0
text 10,30,"Magic"
endif
endif
if selectt = 3
ink rgb(255,255,255),0
text 10,50,"Item"
ink rgb(128,128,0),0
text 10,10,"Attack"
text 10,30,"Magic"
else
if selectt < 0
ink rgb(128,128,0),0
text 10,30,"Item"
endif
endif
`downkeys
if key(208) = 1
inc selectt,1
if selectt > 3 then selectt = 3
endif
`upkeys
if key(200) = 1
dec selectt,1
if selectt < 1 then selectt = 1
endif
`end select attack etc calls
`set x as string to be called in text command
ink rgb(255,255,255),0
`text 350,500,str$(hp)
`attack section
`code brings up target menu with one press of return
if returnkey()=1 and selectt = 1 then hit=1
if returnkey()=0 and hit=1 then action=1 : hit = 0
if action=1
targetbox()=1
ink rgb(255,255,255),0
text 75,420,ename$
text 550,350,"-->"
if returnkey()=1 and action = 1 then inc action,1
if action > 2 then action = 2
endif
if action = 2
newhp = hp - 20
hp = newhp
hp$ = str$(hp)
action = 0
endif
ink rgb(255,255,255),0
text 350,500,str$(hp)
`end attack selection
sync
loop
`shows the battle command
function battlecommand()
draw to front
ink rgb(255,255,255),0
box 0,480,799,599
ink rgb(0,0,128),0
box 2,482,797,597
ink rgb(255,255,255),0
text 30,500,"Robot"
endfunction
function commandbox()
draw to front
ink rgb(255,255,255),0
box 0,0,150,150
ink rgb(0,0,128),0
box 2,2,148,148
ink rgb(255,255,255),1
endfunction
function targetbox()
draw to front
ink rgb(255,255,255),0
box 50,400,250,580
ink rgb(0,0,128),0
box 52,402,248,578
endfunction
The reason the box doesn't disappear is because you aren't *clearing* the screen. So, the old information that the screen displayed still exists.
This can be done using the
CLS command, OR you can simply hide all your previous data.
You maybe thinking 'but I used the
SYNC command'. The
SYNC command that you used simply *adds to* or *works ON* (or *changes*) the display on your screen but doesn't clear away old data.
When dealing with 3D however, clearing is unnecessary and only refreshing will do because 3D objects are almost always 'in the picture' - that is, they have to be present at all times and they are only *changed* or *worked on* - i.e. rotated, moved, scaled etc....
I hope this helps and good luck with your project
Regards
HelloWorld Tommorrow