First of all, thanks to everyone who answered to my problem, I didn't expect anyone to do it x). You are all great!
< snip >
I always check if my code works after adding few lines, but when I am facing problem like this one, I happen to try a bunch of things but indeed, I've let all those things stack up unecessarily so it may looks like I don't often try my code.
- If I get rid of
while(ObjMove_GetY(n) < x){yield}", the problem will just be worst as the stars will directly explode when they spawn. What this line does is it prevents the stars to explode directly, because I want my stars to only explode when they reach x. But, I think you are kinda wrong in your reasoning without willing to be pretentious, because what my line does is see if the stars are above x, and then only if it becomes false see if the stars and under x and only then reading the next part of my task. The explosion doesn't occur as long as those 2 conditions aren't false. That's what I think anyway, I might be wrong as I am still new.
- For
if(x > GetStgFrameHeight - 200){wait(180);}, I couldn't think of another way to "solve" the problem because all my stars kept exploding at the same time when the laser was teleporting to the top, but now thanks to you I know the reason of why random stars pop at (0;0) so thanks
(I still can't figure out how to solve my problems though.)
- For my lasers, if I get rid of
Obj_Delete(obj) it will be problematic, as the laser will eventually reach the end of its delay and spawn as enemy projectiles, and that's not what I want. I only want a delay laser. The first idea was to make interact the spawned laser with stars, but I couldn't find a way to do it so it ended only using my delay laser.
- Well, for shifting my "x" to the laser's loop instead of keeping it in my mainloop, I don't see an efficient way to easily do it and I wanna limit the amount of occurring problems, so I won't do it for now. If I move it to laser's loop, it will make things harder as x won't progress independently from the task, so it will create new problems that I will probably struggle a lot to fix, that's the reason why it is not in the laser's loop.
-For
if(ObjMove_GetY(obj3) > GetStgFrameHeight){Obj_IsDeleted(obj3)} (and with obj2), I have to agree with you, those lines are useless.
< snip >
Ok, it took me a long time but I wrote back all the code for shooting my stars in your way. As conclusion to this, I've found that even if I've changed the behaviour of all my stars to make them independent through your method, it doesn't work (sorry, I tried my best but it still doesn't work). Here's my code:
https://pastebin.com/EXLvcTjZ As Drake mentionned it earlier, the problem resides in fact in my conditions line when my stars hit x. Indeed, my stars don't interact with my lasers but with x, because I couldn't figure out how to make them interact. The problem is right here:
while(ObjMove_GetY(obj2) > x){yield;}
while(ObjMove_GetY(obj2) < x){yield;} I can't find a way to write it as an "if" condition, so I end up with those two "while". With your method, the problem is only shifted from the "explosion" function to the task "starBullet" :/. There are few things that I didn't understand in what you said:
-The behaviour of the bullet has to be independent for each bullet. What will this do? In my way to right things, I decided to do this in my ascent and descent loops by deleting them, so when each star reach x they delete.
- Even if I use "explosion" as a function, stars keep popping out from (0;0), so I don't know anymore x).
edit: I guess I am still not good enough to make things like this, I probably should give up for now and come back later when I'll have more materials to work with. I am out of idea for this :/