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?

mtnhome3d(Posted 2009) [#1]
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?


Tobo(Posted 2009) [#2]
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


Warner(Posted 2009) [#3]
I think
DrawImage (t\image,t\x,t\y)
should be placed between CLS and FLIP instead of inside this IF..ENDIF block.


big10p(Posted 2009) [#4]
DrawImage bull_hit,MouseX()-t\x,MouseY()-t\y
?


Matty(Posted 2009) [#5]
What exactly isn't working?


Nate the Great(Posted 2009) [#6]
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.


mtnhome3d(Posted 2009) [#7]
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




Nate the Great(Posted 2009) [#8]
change this

DrawImage bull_hit,MouseX(),MouseY();and this


to this

DrawImage bull_hit,MouseX()-t\x,MouseY()-t\y;and this



big10p(Posted 2009) [#9]
Um, I already said this. Are you not seeing my posts?


mtnhome3d(Posted 2009) [#10]
i have tried that, it still doesn't work.


Warner(Posted 2009) [#11]
It does work. Here, try this:



mtnhome3d(Posted 2009) [#12]

try this, i added movement via sin() it doesn't work well,if at all.


Warner(Posted 2009) [#13]
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.


_Skully(Posted 2009) [#14]
WRT
If 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