We are about to switch to a new forum software. Until then we have removed the registration on this forum.
The problem here is that no explosion is happening when target is hit.
Here's what happens, I "shoot" with LMB, bullet shoots, hits target and there should be an explosion, but no explosion happens. The explosion only happens if I press the "shoot" (LMB) button again.
What can I do to make the explosion explode as it should?
Second half of the code
edit: my code gets extremely bugged if i post it as a code(wtf) so ill try as a quote
Answers
edit post, highlight code, press ctrl-o to format.
same code, different poster here:
https://forum.processing.org/two/discussion/20548/need-desperate-help-figuring-out-this-game
says it's a school project...
@koogs, when I press the ctrl+o to format it gets bugged
and it must be someone from my group, the code isn't the "same", the assignment is we have a base code and we must add/edit code
my code is almost how it needs to be except for some small problems, I just can't figure out how to get the explosion correct
unless you post runnable code we are limited in what we can do
or at least code that executes the explosion methods. it doesn't have to be the entire cannon code, just the explosion bit. but it should be runnable.
@koogs can I pm you the code? If I post a runable code I'd have to post the entire code which has had a lot of work and changes done to it
no
reduce the code to the bits that need debugging. the firing, the bullet stuff, none of that matters for debugging this bit. just enough code to exercise drawExplosion().
briefly looking at this you'd need:
explode = true
explosionStrength
explodePositionX and explodePositionY
and if drawExplosion is ok then it's how you're calling it that's broken.
unit testing...
looks ok. i've not changed drawExplosion (except to add some spaces to make it more readable, and to fix the spelling in the comment). press a key to explode...
so check how you're calling it. you may be invalidating some of the global variables this relies on in other code (which is why i'd be tempted to move this into a class of its own).
The explosion logic is similar to fireworks. It needs state check in order to know what to do:
http://studio.SketchPad.cc/sp/pad/view/ro.9Q6oRai8-41WJ/latest
if (explode)
is enough of a state check imo.