Here's an example
Rem Project: Dark Basic Pro Project
Rem Created: Wednesday, December 01, 2010
Rem ***** Main Source File *****
sync on
global BX,BY,Width,Height
BX=50
BY=50
Width=100
Height=100
do
cls
if not shiftkey()
if keystate(17) or upkey()
dec BY,1
endif
if keystate(30) or leftkey()
dec BX,1
endif
if keystate(31) or downkey()
inc BY,1
endif
if keystate(32) or rightkey()
inc BX,1
endif
else
if keystate(17) or upkey()
dec BY,2
endif
if keystate(30) or leftkey()
dec BX,2
endif
if keystate(31) or downkey()
inc BY,2
endif
if keystate(32) or rightkey()
inc BX,2
endif
endif
if BX<0
BX=0
endif
if BX>screen width()-(Width)+1
BX=screen width()-(Width)+1
endif
if BY>screen height()-(Height)+1
BY=screen height()-(Height)+1
endif
if BY<0
BY=0
endif
BOX BX,BY,BX+Width,BY+Height,RGB(255,0,0),RGB(0,255,0),RGB(0,0,255),RGB(0,255,255)
center text screen width()/2, screen height()/2, "BX:"+str$(BX)
center text screen width()/2, screen height()/2+20, "BY:"+str$(BY)
center text screen width()/2, screen height()/2+40, "Width:"+str$(Width)
center text screen width()/2, screen height()/2+60, "Height:"+str$(Height)
sync
loop
As you can clearly see, if you hold down either the W/A/S/D keys or the arrow keys, and move the box, the box CANNOT escape the borders.
I would like to be able to the same thing without the keys.
So for instance, if I were to set BX to screen width()/2, and BY to screen height()/2, and Width and Height to 100,100, no matter WHAT size I make it, it will still remain exactly in the middle. And if I were to position it at a given coordinate, it would position at that coordinate + the size to give me the exact coordinates of the box.
CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!