Im confused
Blitz3D Forums/Blitz3D Beginners Area/Im confused
| ||
PROBLEM SOLVED Okay, I'm trying to create a program where I fire with an image and I hit another image and then make it disappear. Tell me how to shoot something then when they make contact make the image DISAPPEAR. PROBLEM SOLVED ---------------------------------------------------------------------- |
| ||
FreeImage retard |
| ||
HA! im sorry. but that was funny... no offense or anything :P ~DS~ |
| ||
Freeimage retard hahahaHAHAHAHAHA that totally sounded ambiguous |
| ||
XD |
| ||
lol im serious can anyone help me? I dont understand... |
| ||
First, you missed a couple of parameters for the ImageCollide() function, specifically the Frame number. Set it to 0 if only using an image without frames. ImageRectCollide (image,x,y,frame,rect x,rect y,rect width,rect height) How about trying: If ImagesCollide(bullet,b\x,b\y,0,retard,r\x,r\y,0) Then Delete retard |
| ||
it says cannot delete non-newtype. |
| ||
Um... you can't delete images.. you can only free them...If ImagesCollide(bullet,b\x,b\y,0,retard,r\x,r\y,0) Then FreeImage retard Did you even try? |
| ||
A number of people think you're trying to delete the image, but I don't think you are. I think you're wanting to delete the type instance, but the type instance is called r, so it should be delete r instead of delete retard. retard is just the name of the type, it does not point to an object in particular. Incidentally, it would be less confusing - for you and us - if you changed the variable you use to load the image into. Having a type called retard and an image called retard is asking for confusion. I think Blitz3D won't care and will not confuse them, but it will make your life easier. Then we'd know for sure which you were trying to do. |
| ||
i put freeimage and it nows says that the image doesn't exist! I'm still stuck. |
| ||
I haven't changed your code just placed some comments at some points indicating what some of the problems are..and there are a few.;CONFUSED AKA THE PROGRAM WON'T WORK ret = LoadImage("retard.jpg") colin = LoadImage ("colin.jpg") ResizeImage (colin,100,100) bullet = LoadImage("bullet.bmp") AutoMidHandle True SeedRnd MilliSecs() x= 0 y = 0 Type bullet Field x Field y End Type Type retard Field x Field y End Type SetBuffer BackBuffer() Repeat Cls ; clearing the screen at the begining of each loop ;drawling colin DrawImage colin,x,y ;moving colin If KeyDown(203) Then x = x - 5 If KeyDown(205) Then x = x + 5 If KeyDown(200) Then y = y - 5 If KeyDown(208) Then y = y + 5 If KeyHit(57) Then b.bullet = New bullet b\x = x - 200 b\y = y - 130 EndIf For b.bullet = Each bullet b\y = b\y - 5 DrawImage bullet,b\x,b\y If b\y < -100 Then Delete b Next ; ret stuff etc........ If x = x Then r.retard = New retard ; <<<< - X will always equal X - This is going to create a new 'retard' object each frame - totally unnecessary r\x = 130 r\y = 0 DrawImage ret,r\x,r\y If ImagesCollide(bullet,b\x,b\y,0,ret,r\x,r\y,0) Then FreeImage ret ;This should be in your bullet for..next loop as b/x and b/y will be undefined at this point ;also if you free the image then you won't be able to draw it again. Flip Until KeyDown(1) |
| ||
Theres this little line here also:If x = x Then r.retard = New retard That will always be true, thus you are constantly creating more instances of the Retard type. I seriously suggest that you re-write everything. It works like a charm sometimes when you do it for the second time. EDIT: I posted the same time as Matty...not a chance. |
| ||
Now just tell me how when I hit the image with the bullet that the "retard" disappears. I fixed the other stuff I think. :) Thank you so much so far. |
| ||
Had a bit of free time, though this is not from in front of a machine that has blitz installed but try this:;CONFUSED AKA THE PROGRAM WON'T WORK Graphics 800,600,0,2 ;you really should specify the graphics mode first. ret = LoadImage("retard.jpg") colin = LoadImage ("colin.jpg") ResizeImage (colin,100,100) bullet = LoadImage("bullet.bmp") AutoMidHandle True SeedRnd MilliSecs() x= 0 y = 0 Type bullet Field x Field y End Type Type retard Field x Field y End Type SetBuffer BackBuffer() Repeat Cls ; clearing the screen at the beginning of each loop ;drawling colin DrawImage colin,x,y ;moving colin If KeyDown(203) Then x = x - 5 If KeyDown(205) Then x = x + 5 If KeyDown(200) Then y = y - 5 If KeyDown(208) Then y = y + 5 If KeyHit(57) Then b.bullet = New bullet b\x = x - 200 b\y = y - 130 EndIf ;i put this in for a bit of fun... if (millisecs()>time) then time=millisecs()+Rand(500,2000) r.retard=new retard r\x = rand(0,graphicswidth()) r\y = rand(0,graphicsheight()/2) endif For b.bullet = Each bullet b\y = b\y - 5 DrawImage bullet,b\x,b\y For r.retard = each retard If ImagesCollide(bullet,b\x,b\y,0,ret,r\x,r\y,0) then delete r endif next If b\y < -100 Then Delete b Next For r.retard = each retard drawimage ret,r\x,r\y next vwait Flip false Until KeyDown(1) |
| ||
Matty thank you very much problem solved!( I liked the extra stuff too :p ) Thanks also to everyone else who posted! I'm a noob lol. |
| ||
Depends, if you don't study Matty's version then you are really a noob :D |
| ||
"FreeImage retard" Heh.. wasn't calling you a retard btw. |
| ||
Hehe :) classic.. |