A variation of my other code. A sprite moves around, and the mouse is the light source. There's a significant slow down when the mouse is actually over the sprite. I'm not sure if this is because I'm using a sprite this time rather than a plane, or not.
I have nowhere to upload the images to, so you'll have to supply them. clouds.jpg is the texture images, t.jpg is the spotlight(a white gradient sphere fading out to black) And no, the images do not have to be the same size. Actually, you should make the light image smaller.
screenwidth = 800
screenheight = 600
set display mode screenwidth,screenheight,32
load image "clouds.jpg", 1, 1
load image "t.jpg", 2, 1
make memblock from image 1,1
make memblock from image 2,2
make memblock from image 3,1
width = memblock dword(1, 0)
height = memblock dword(1, 4)
width2 = memblock dword(2, 0)
height2 = memblock dword(2, 4)
sync on
autocam off
backdrop on
position camera 0,0,0
for x=1 to width
for y=1 to height
location = ((y-1)*width + x - 1) * 4 + 12
write memblock dword 3, location, rgb(0,0,0)
next y
next x
sx = 100
sy = 100
ax = 1
ay = 1
do
inc sx,ax
inc sy,ay
if sx > screenwidth-width or sx < 0 then ax=-ax
if sy > screenheight-height or sy < 0 then ay=-ay
fx = mousex()
fy = mousey()
w = width2/-2
h = height2/-2
for x = 1 to width2
for y = 1 to height2
x2 = fx + w + x
y2 = fy + h + y
if x2 > sx and x2 <= sx+width and y2 > sy and y2 <= sy+height
location = ((y-1)*width2 + x - 1) * 4 + 12
b = memblock byte(2,location)
g = memblock byte(2,location+1)
r = memblock byte(2,location+2)
location = ((y2-(sy+1))*width + (x2-sx) - 1) * 4 + 12
b = (memblock byte(1, location) * b) / 255
g = (memblock byte(1, location+1) * g) / 255
r = (memblock byte(1, location+2) * r) / 255
write memblock dword 3, location, rgb(r,g,b)
endif
next y
next x
make image from memblock 3, 3
sprite 1,sx,sy,3
set cursor 0,0
print screen fps()
sync
loop
"eureka" - Archimedes