ok. i'm making a real time strategy game, and i just started yesterday (so i haven't gotten far). so far i have only made the soldier selection system, you know with the click and drag box that you drag around your soldiers and the little green circle appears under them? i have it pretty much down, but i encountered one problem. when the units are withing the box, they are selected and the ring shows up and everything works. but when i release the mouse button and the box dissapears, they are no longer selected.
i know what the problem is, but i don't know how to fix it. the part that checks if the object is inside the box on the screen is inside the if endif statement "if mouseclick()=1". now, that is the only place that i can put it that makes it work. the problem with that is that when mouseclick()=0, it is no longer selected because the declaration of its selection is inside the "if mouseclick()=1" statement.
how can i change my code so that the objects stay selected after they have had the box dragged around them even if the box no longer exists? here is my code (it's not much yet, but is completely functional)
REM -----------------------------------------------------------------------------------------------------------
REM -----------------------------------------------------------------------------------------------------------
REM ---------------------- REAL TIME STRATEGY GAME ----------------------------------------
REM -----------------------------------------------------------------------------------------------------------
REM -----------------------------------------------------------------------------------------------------------
REM basic game settings
sync on
sync rate 25
REM game variables
soldiercount=10
REM load
gosub load
REM start of loop
DO
REM selection array
dim select(soldiercount)
REM temporary camera controls
if upkey()=1 then pitch camera up 1
if downkey()=1 then pitch camera down 1
if rightkey()=1 then turn camera right 1
if leftkey()=1 then turn camera left 1
if spacekey()=1 then move camera 5
REM selection box
if mouseclick()=1
if hold=0
mx#=mousex()
my#=mousey()
endif
hold=1
ink rgb(0, 500, 0),rgb(0,0,0)
line mx#,my#,mousex(),my#
line mx#,my#,mx#,mousey()
line mx#,mousey(),mousex(),mousey()
line mousex(),my#,mousex(),mousey()
rem selectoin recognition
for selection = 1 to soldiercount
msx# = mousex()
msy# = mousey()
osx#=object screen x(selection)
osy#=object screen y(selection)
if osx# < msx# and osx# > mx# and osy# > my# and osy# < msy#
select(selection)=1
endif
if osx# > msx# and osx# < mx# and osy# < my# and osy# > msy#
select(selection)=1
endif
next selection
else
hold=0
endif
REM show selected unit's selection ring
for selection = 1 to soldiercount
if select(selection)=1
show object selection+10
position object selection+10, object position x(selection), object position y(selection), object position z(selection)
zrotate object selection+10, wrapvalue(object angle z(selection+10)+5)
else
hide object selection+10
endif
next selection
REM end loop
sync
LOOP
REM -----------------------------------------------------------------------------------------------------------
REM --------------------------------------------SUBROUTINES----------------------------------------------------
REM -----------------------------------------------------------------------------------------------------------
REM loading subroutine
load:
rem make ground
make matrix 1, 10000, 10000, 50, 50
set matrix 1, 0, 0, 0, 1, 1, 1, 1
position matrix 1, 0, 0, 0
randomize matrix 1, 100
rem make soldier and its selection ring
for soldiernumber= 1 to 10
make object box soldiernumber, 100, 100, 100
if soldiernumber > 5
position object soldiernumber, 500*(soldiernumber-5), get ground height(1,100,1000),2000
else
position object soldiernumber, 500*soldiernumber, get ground height(1,100,1000),1000
endif
make object plain soldiernumber+10, 256, 256
set object soldiernumber+10,1,0,0
xrotate object soldiernumber+10, 90
load bitmap "selection ring.bmp",1
get image 1, 0, 0, 512, 512
texture object soldiernumber+10, 1
delete bitmap 1
hide object soldiernumber+10
next soldiernumber
REM starting camera position
position camera 1500, 1000, -100
pitch camera down 30
return
PLEASE HELP
Your Head A-Splode