Type Deletion Problem
Blitz3D Forums/Blitz3D Beginners Area/Type Deletion Problem
| ||
Function TestShotAst() For a.ast = Each ast For s.shots = Each shots If ImagesCollide(a\img,a\x,a\y,0,s\img,s\x,s\y,0) as.ast = New ast as\x = a\x as\y = a\y as\rot = 0 as\size = a\size + 1 as\img = aimg0(a\rot) as\vx = Rnd(-2,2) as\vy = Rnd(-2,2) a\size = a\size + 1 Delete s End If Next Next End Function I know I've had this exact same problem before, but I can't remember how I fixed it. Anyways, this is the function in my little Asteroids game that checks to see if the players shot has hit the asteroid. It makes a new asteroid and makes the old one smaller. The problem is, if there is more than one shot on the screen, It gives me an error "Image does not exist" and it highlits the "If ImagesCollide(a\img,a\x,a\y,0,s\img,s\x,s\y,0)" line. I know I've fixed this problem before, and I'm sure it's very simple, but I can't see the problem right now, can anyone else? |
| ||
Delete s change to Delete s.shots |
| ||
Nope, still doesn't work. |
| ||
Come to think of it, shouldn't you be checking each asteroid against each shot? You seem to be checking the other way around. Check your debuglog too. What does the type collections contain? |
| ||
I've tried flipping many things around. If I flip the fors around, it says Object does not exist instead of image, and if I flip the ImagesCollide part around, it does the same thing. I think I'm looking at the right thing here for the debug log. Under TestShotAst() it says a.ast and all it's variables, s.shots and all it's variables, and a.ast and all it's variables. |
| ||
could you give me some working code? |
| ||
You just want the whole thing? I can put the graphics on my webspace. |
| ||
Yes please :o) |
| ||
It's Here: http://www.antibox.net/grant/Asteroids(Working Title-In Progress).zip |
| ||
Oh sorry, and the controls are left and right and up and spacebar. |
| ||
aimg0(0) is empty you only set aimg() from 1 to 30 So as\rot needs to equal a number from 1 to 30. It can't be 0 Don't even try to do this: as\img = "aimg" + a\size + "(a\rot)" after that as\img equals 0 You just need to check when your images equal 0 for better debugging. |
| ||
aimg0(0) does equal something. It equals astim. Dim aimg0(30) aimg0(0) = astim For i = 1 To 30 aimg0(i) = CopyImage(astim) RotateImage aimg0(i),12 * i Next |
| ||
ok the game works nicely for me just change the "as\img =" line |
| ||
Ohhhhh... Your right. I see what was happening. It works now. Thanks! Oh, and thanks for the fireworks code Ross C. I'm going to use it for the new highscore screen. It doesn't have much to do with space, but still... I'll give you credit, don't worry :) |
| ||
Your welcome. You could also use a 2D array like this: Dim aimg(3,30) ... as\img = aimg(as\size,as\rot) thats probably what I would do |