can this work, and if so why isn't it?
Blitz3D Forums/Blitz3D Beginners Area/can this work, and if so why isn't it?
| ||
If MouseHit(1) And ImagesCollide(t\image,t\x,t\y,0,ret_col,MouseX(),MouseY(),0) SetBuffer ImageBuffer(t\image) DrawImage bull_hit,MouseX(),MouseY() SetBuffer BackBuffer() DrawImage (t\image,t\x,t\y) End If can it work?? am i doing it wrong? |
| ||
I can see what you're trying to do, but how is it not working? Is the image not being updated, or not showing at all...etc |
| ||
I think DrawImage (t\image,t\x,t\y) should be placed between CLS and FLIP instead of inside this IF..ENDIF block. |
| ||
DrawImage bull_hit,MouseX()-t\x,MouseY()-t\y? |
| ||
What exactly isn't working? |
| ||
big10p has a point. you need to subtract the image x and y values from the mousex and y values.. and if you have automidhandle true then it gets even more complicated Warner also has a point that drawimage needs to be outside the if block so it always draws the image. |
| ||
i'm trying to draw a bullet hole image on my target image. i'm not very good at 2d stuff, so i don't know if you can use drawimage onto an image buffer. i have a drawimage outside the if block as well. i'll post the entire function.Function updatetargets() For t.target=Each target sinx=sinx+1 siny=siny+1 t\x=Sin(sinx)*100 t\y=Sin(siny)*100 DrawImage(t\image,t\x,t\y) If MouseHit(1) And ImagesCollide(t\image,t\x,t\y,0,ret_col,MouseX(),MouseY(),0) SetBuffer ImageBuffer(t\image); this DrawImage bull_hit,MouseX(),MouseY();and this SetBuffer BackBuffer(); and this are the lines i'm talking about. ClsColor 200,50,200;this doesn't actually change the color, not sure whats happening. Cls DrawImage (t\image,t\x,t\y) End If Next End Function |
| ||
change thisDrawImage bull_hit,MouseX(),MouseY();and this to this DrawImage bull_hit,MouseX()-t\x,MouseY()-t\y;and this |
| ||
Um, I already said this. Are you not seeing my posts? |
| ||
i have tried that, it still doesn't work. |
| ||
It does work. Here, try this: |
| ||
try this, i added movement via sin() it doesn't work well,if at all. |
| ||
You are drawing the image at (Sin(x)*100, Sin(y)*100), but you are testing the image at (x, y). That is inconsistent. If you test the image at the point where it is drawn at, it will work. |
| ||
WRTIf MouseHit(1) And ImageRectOverlap(image,x,y,MouseX(),MouseY(),1,1) There is no reason to use this command.. its only needed when you are trying to see if an image is overlapping another... in other words, two rectangles are overlapping. You could just go mx=mousex() my=mousey() If MouseHit(1) And mx=>x and my=>y and mx<x+ImageWidth(Image) and my<y+ImageHeight(image) you then know that the point of intercept is mx-x, my-y and the mouse position will not have changed. When you draw your target on the image be sure your imagehandle is set to the middle so it is centred on your mouse point. Cheers |