why die

Blitz3D Forums/Blitz3D Beginners Area/why die

MIKEYFYN(Posted 2003) [#1]
Hi

I am trying to create what is for me a complicated game (easy for most of you I suspect) It is based on the game where a worm or caterpiller eats apples while trying to avoid poisonous apples, eating itself and avoiding barriers(you know the one)

The worm, apples and barriers are type. After each level I delete these

for apple.apples = each apples
delete apple
next

and redo them by using new apples etc.
I use a boolean variable that is set to false in the main loop unless the worm hits one of the items above. It is then set to true and a fuction is called that deals with the end of the game.

My problem is that every now and then, the worm dies for no apparent reason. This is as though a posionous apple is luking invisably. This seems to happen even if no poisonous apples are (or have been) visible. The barriers remain in a static position as do the screen edge barriers.

On restarting the game the existing types are deleted as above and redone. The boolean variable is reset. I have looked through the code soo many times that I am going crosseyed.

I appreciate that this is difficult without seeing the code, but does anyone have any idea why this might be happening.

Thank you in anticipation.
Mikeyfyn


FlameDuck(Posted 2003) [#2]
You'll have to post a little more code than that (for example, you could zip up all your code and media, and host it on your website for everyone to grab). From your explaination there is no way to tell exactly what's wrong.


Neo Genesis10(Posted 2003) [#3]
A common mistake is to apply offsets to the X and Y coords of objects (in your case, possibly the poison apples). The best option is to put a stop command when it detects a collision with a poison apple and debug from there.


MIKEYFYN(Posted 2003) [#4]
thank you to you both, I will try putting a stop where the the function is called so I can see what is happening there.

The point about the red apple is that none are shown or have been shown on the screen when this happens.

Mikeyfyn


Difference(Posted 2003) [#5]
Not that it will solve your problem, but you can replace

For apple.apples = Each apples
delete apple
next

with:

Delete Each apples


robleong(Posted 2003) [#6]
Don't assume it's just the apples - it could be the other 2 reasons (barrier and eating itself). If I were you, I would first find out which of these 3 is the cause e.g. don't initiate any apples (or barriers) and see whether your worm dies unexpectedly.


MIKEYFYN(Posted 2003) [#7]
Peter and Robleong

Thank you both for taking the trouble to help me.
I have as neo genesis10 suggested (thank you) put a stop inplace of the call to the function. It appears that it is caused by the worm 'thinking' that it has bitten itself. I am now looking more closely at this part of the code.

Thank yo again for your help.

Mikeyfyn


MIKEYFYN(Posted 2003) [#8]
Peter Scheutz, Robleong and neo genesis10.

Just a final thank you for taking the trouble to help with the proplem in my code. I discovered a temporary array was still holding the position of the last section of the worm. Whenever the worm passed over that point it died. I now clear the array after each time it is used and the problem has dissapeared.

Thanks again

Mickeyfyn