Deleting an ORBE that is pushed into the DOOR
BlitzMax Forums/BlitzMax Programming/Deleting an ORBE that is pushed into the DOOR
| ||
Thanks for helping me with my last question. The advice that I was given worked, and it seems like I'm starting to get the hang of BlitzBasic already and I'm an extremely beginning programmer. I now have another question. In my game, I'm trying to make it so that when the player (EATUM) pushes an ORBE into a door, the ORBE is deleted. But, when the ORBE is pushed into the door, I keep getting an "Object doesn't exist" error message. Even when I make the ORBE an array (like I did with my apples), I still get an error message that says "Object doesn't exist." Thus, how do I fix that? By the way, I'm using BlitzPlus, but I was thinking maybe someone here can help me with this problem as well. Thanks EN The source code is below this line. ---------------------------------------------------------------- Graphics 900, 900 SetBuffer BackBuffer() EATUM = LoadImage ("Eatum.png") APPLE = LoadImage("Apple.png") ORBE = LoadImage("Orbe.png") DOOR = LoadImage("Door.png") BACKGROUND = LoadImage("Clouds.jpg") Type EATUM Field x,y End Type Type APPLE Field x,y End Type Type ORBE Field x,y End Type Type DOOR Field x,y End Type e.EATUM = New EATUM e\x = 70 e\y = 200 For z = 1 To 5 a.Apple = New Apple a\x = 100+30*z a\y = 90*z Next For j = 1 To 1 o.ORBE = New ORBE o\x = 100*j o\y = -200*j Next d.DOOR = New DOOR d\x = 50 d\y = 50 Score = 0 ScrollRightLeft = -200 While Not KeyDown (1) Cls TileImage BACKGROUND,ScrollRightLeft DrawImage (EATUM,e\x,e\y) DrawImage (ORBE,o\x,o\y) DrawImage (DOOR,d\x,d\y) ;puts the apples in the game. For a.APPLE = Each APPLE DrawImage(APPLE,a\x,a\y) If ImagesCollide(EATUM,e\x,e\y,0,APPLE,a\x,a\y,0) Then Delete a score = score + 1 Next Text 150,150, "Score" + Score ;when the left arrow key is pressed, player moves to the left and the background moves too. If KeyDown(203) e\x = e\x - 3 ScrollRightLeft = ScrollRightLeft + 3 ;when the player is moving left and collides with the ORBE, the player the ORBE will be pushed in the left direction. If ImagesCollide(EATUM,e\x,e\y,0,ORBE,o\x,o\y,0) Then o\x = o\x - 3 EndIf ;when the right arrow key is pressed, player moves to the right and the background moves too. If KeyDown(205) e\x = e\x + 3 ScrollRightLeft = ScrollRightLeft - 3 ;when the player is moving right and collides with the ORBE, the player will push the ORBE in the right direction too. If ImagesCollide(EATUM,e\x,e\y,0,ORBE,o\x,o\y,0) Then o\x = o\x + 3 EndIf ;when the up key is pressed, the player moves up If KeyDown(200) e\y = e\y - 3 ;If the player collides with the ORBE while moving up, then the ORBE will be pushed up as well. If ImagesCollide(EATUM,e\x,e\y,0,ORBE,o\x,o\y,0) Then o\y = o\y - 3 EndIf ;when the down key is pressed the player moves down If KeyDown(208) e\y = e\y + 3 ;if the player is moving down and collides with the ORBE, the ORBE will be pushed in the down direction as well If ImagesCollide(EATUM,e\x,e\y,0,ORBE,o\x,o\y,0) Then o\y = o\y + 3 EndIf ;Now, Here is the part that is not working in my program. I'm trying to make it so that when the ORBE is pushed into the door by the player, the it disappears and is deleted, but when I do that, I get an error message that says that "the object doesn't exist." I also tried to make my ORBE an array like I did with the apples, but I still get the same error message. It says that the "Object doesn't exist." Thus, how do I fix it? If ImagesCollide(DOOR,d\x,d\y,0,ORBE,o\x,o\y,0) Then Delete o Text 350,300, "Great Job" Flip Wend |
| ||
This is the BlitzMax section. |