Page 1 of 1

How do I achieve space invader movement

PostPosted: Thu Jul 03, 2014 1:08 am
by abasel
How do I achieve the downwards movement of the space aliens in the standard spave invader game?

I can get on alien to move left and right, descending as it goes but I can't get a block of them to do this; well not without the others ultimatelt crashing into each other or loosing position.

Re: How do I achieve space invader movement

PostPosted: Thu Jul 03, 2014 2:12 am
by codah
Well, what is your current method? Any sample capx?

Edit: attached a capx.. first idea that came to mind so be nice :)

Re: How do I achieve space invader movement

PostPosted: Thu Jul 03, 2014 3:56 am
by farflamex
You basically just need to check if ANY invader has reached a certain coordinate (left or right). At that point, ALL invaders make the downwards movement and change direction.

Check the entire batch of aliens (with them all picked) to see if any has reached that point. If any were picked, you can set a variable and then in the next event, reverse the aliens if that variable is set. Alternatively, you can use a family to avoid the use of the variable, but it's a bit more complicated.

Re: How do I achieve space invader movement

PostPosted: Thu Jul 03, 2014 4:15 am
by codah
Yeah that's the approach I took in the capx (well I used collision with a sprite instead of raw coordinates). He seems to have the free edition, so no families.

Re: How do I achieve space invader movement

PostPosted: Thu Jul 03, 2014 9:24 am
by abasel
Excellent, so easy when you see how :-) I was missing the "Pick All" part so was battling with multiple objects. Got the full version but don't like using the premium parts because then my students can't use them at home - but I do tell them about things like families in case they purchase.

Thanks again

Re: How do I achieve space invader movement

PostPosted: Thu Jul 03, 2014 11:45 am
by farflamex
Ah yes. Families are very useful in situations where you've already picked one object and then suddenly require all of the same objects in the subevents (you can't access them because you've already picked one). For example where you need to compare a value of one object against all of the same type of object. You can do it with variables but families are nicer usually.

Re: How do I achieve space invader movement

PostPosted: Sat Jul 05, 2014 3:37 am
by abasel
Using the initial CAPX file as a guideline I created the following using bullet behaviour. Yip families would be much better for sure :D

Re: How do I achieve space invader movement

PostPosted: Sat Jul 05, 2014 3:48 am
by farflamex
Perfect :)