I am having a problem moving an image...I know how to move an image straight up and straight down..but how would I move an image from one location to any location on the screen. I will appreciate any help
Moving An image
Blitz3D Forums/Blitz3D Programming/Moving An image You will need to find the angle between the both of them. Once you have this, you can do :
To get the angle, you need the two points. Start point (x1,y1) and end point (x2,y2). Then:
I'm at college the now so i can't write up a demo, but the above will work :)
image_x = image_x + cos(angle) image_y = image_y + sin(angle)
To get the angle, you need the two points. Start point (x1,y1) and end point (x2,y2). Then:
angle = ATan2( y2 - y1, x2 - x1 )
I'm at college the now so i can't write up a demo, but the above will work :)
wow...thank you
is there a way to get the image to stop..at an exact point??
Graphics 640,480 Repeat Cls x1#=Rand(0,640) x2#=Rand(0,640) y1#=Rand(0,480) y2#=Rand(0,480) steps=Rand(1,50) delx#=Float(x2-x1)/steps dely#=Float(y2-y1)/steps For n#=0 To steps Cls Color 255,0,0 Oval x1-5,y1-5,10,10,True Oval x2-5,y2-5,10,10,True Color 0,255,0 Oval x1+(delx*n)-5,y1+(dely*n)-5,10,10,True Delay 50 Next Until KeyHit(1)
Well, your stop point would be your end point :)
Just compare x and y co-ords, then stop the movement. :)
Just compare x and y co-ords, then stop the movement. :)
...angle between the both of them... at college the now so ...
Gotta love that Scottish dialect on the definite article. These are classic examples and you used the both of them in one posting ! Aw... the nice !