Rotation about an image
BlitzMax Forums/BlitzMax Beginners Area/Rotation about an image
| ||
Hi can anyone give me any help on this problem please: I have some code that displays a central rotatable image, and i have some code that detects collisions with that image. What i would like is to make the images that collide with the central image 'stick' to it. What i mean by this is to rotate with the image from then on - in exactly the same place as it hit the central image. I have tried playing with the setimagehandle to try to calculate the relative offset i would need but cant quite seem to get it right. The central image is midhandled and i have the automidhandle switched on. Any help/example code would be greatly appreciated. TheSwede |
| ||
Hello. Could you not recreate the rotating image with the colliding image stuck to it? Goodbye. |
| ||
Thanks for the reply... im not sure how to go about replacing the central image. However i think this may not be the best thing to do however, as in the game i am writing, i want to be able to detach and throw the objects back out at will. Basically the game will be a bit like asteroids, but you cant move you can catch the objects and throw them back out as ammunition. |
| ||
Graphics 800,600,0 ' createimage.bmx ' creates a 256x1 image with a black to blue color gradient Const BLUEBITS =$ff000000 Const GREENBITS=$ff008000 Graphics 800,600,0 AutoMidHandle(True) bluebox=CreateImage(64,64) map=LockImage(bluebox) For i=0 To 63 For x = 0 To 63 WritePixel(map,i,x,BLUEBITS|i*2) Next Next UnlockImage(bluebox) greenbox=CreateImage(64,64) map=LockImage(greenbox) For i=0 To 63 For x = 0 To 63 WritePixel(map,i,x,GREENBITS|i*2) Next Next 'SetImageHandle(greenbox,64,32) UnlockImage(greenbox) Distance = 64 Repeat Cls If move = 1 distance:+1 If distance>256 Then move=0 EndIf If move = 0 distance:-1 If distance<64 Then move=1 EndIf shiprot:+1 SetRotation(shiprot) DrawImage bluebox,MouseX(),MouseY() 'DrawText "Blue Color Gradient",0,0 DrawImage greenbox,MouseX()+(Cos(shiprot)*Distance),MouseY()+(Sin(shiprot)*Distance) Flip Until KeyDown(KEY_ESCAPE) |
| ||
better example: |
| ||
Just what I was after. Thankyou Bill and SoggyP for your helpful replies. And I get a nice gradient fill routine thrown in as well :) |