First thanks for the help in advance.
I have not touched basic since around 1990 as such am really rusty. I have been playing around with the scrolling tutorial and have not been able to do what I want to do.
The effect I am looking for is to have a "map" (topographical) as my background. As the mouse moves over this background I would like my sprite to display a corresponding section of a different image. (photo).
I can create a sprite that shows a singular portion of the photo image but not one that will change as the position of the sprite moves. Perhaps this is not the proper method of doing this procedure?
Rem ***** Main Source File *****
sync rate 60
sync on
backdrop off
load bitmap "background.JPG",0
load bitmap "targets.JPG",1
set current bitmap 1
get image 1,0,0,1280,960,0
set current bitmap 2
get image 2,0,0,320,240,0
sprite 1,0,0,1
sprite 2,x1,y1,2
spr=2
repeat
mx#=mousex()
my#=mousey()
set sprite texture coord spr, 0, 0.0 + (mx# / 320), 0.0 + (my# / 240)
set sprite texture coord spr, 1, 1.0 + (mx# / 320), 0.0 + (my# / 240)
set sprite texture coord spr, 2, 0.0 + (mx# / 320), 1.0 + (my# / 240)
set sprite texture coord spr, 3, 1.0 + (mx# / 320), 1.0 + (my# / 240)
if mouseclick()=1 then sprite 2,mx#,my#,2
I appreciate any pointers in the general direction I need to go.
I have concluded that within the confines of DARKbasic it is impossible to define sprite texture coordinates that are outside of the defined sprites initial area.
I have chosen to create the effect I was seeking out of 25 sprites and change which sprite is displayed based on mouse position and key presses.
if mouseclick()= 1 then
rem tricking a FLOAT into INT
rem my image is 1280 pixels wide by 960 tall which when divided by 25
rem results in sprites 256 pixels wide by 192 pixels tall. Determining
rem which of 5 columns we should display from by forcing a FLOAT into an INT
rem we drop the remainder resulting in a number between 1 and 5
XMouseAxis = ((mousex() + 256) / 256)
rem same trick for y axis remember to use parenthesis correctly
YMouseAxis = ((mousey() + 192 )/ 192)
rem multiplying YMouseAxis by XMouseAxis provides the correct sprite number to display
XYSprite = YMouseAxis * XMouseAxis
sprite XYSprite, mousex(), mousey(), 1