Do not fire if friendlies below
dysnak
Member Posts: 16
Hi All,
Can anyone please help me with the below?
I am new to Gamesalad and have very little programming experience and the set up of rules etc...
To learn the tool I thought I'd create a Space Invaders clone from scratch and all has been going well until I tried to create the 'Do I fire' rule for Invaders.
There are the following checks in this rule, Is a random number generated between 0-100 over 90 (This works), are there more than or equal to 3 Invader bullets already on screen (This works), are there any invaders below me (This is the one I can't get right).
For ease of reference I'll refer to the top level of invaders as Inv 1, middle level as Inv 2 and bottom level as Inv 3. I am currently trying to check based on the x position of invaders.
So:
Each aliens x position is turned into an attribute (Inv1, Inv2X, Inv3X)
Inv 1 checks if Inv2X and Inv3X is not equal to Inv1X then I can fire
Inv 2 checks if Inv3X is not equal to Inv2X then I can fire
Now I know the starting x positions of Inv 2 & Inv 3 are the same as Inv 1 to begin with because there is a spawn rule in Inv 1 that spawns Inv 2 actor at same self.positionX and self.positionY-50 (set to 50 so I can clearly see if any Inv 1s are firing when they shouldn't). And Inv 2 has a spawn rule for In 3 using the same position.
The spawning of Invaders works fine but they continue to fire if another Invader is below them
Thanks
Dysnak
Can anyone please help me with the below?
I am new to Gamesalad and have very little programming experience and the set up of rules etc...
To learn the tool I thought I'd create a Space Invaders clone from scratch and all has been going well until I tried to create the 'Do I fire' rule for Invaders.
There are the following checks in this rule, Is a random number generated between 0-100 over 90 (This works), are there more than or equal to 3 Invader bullets already on screen (This works), are there any invaders below me (This is the one I can't get right).
For ease of reference I'll refer to the top level of invaders as Inv 1, middle level as Inv 2 and bottom level as Inv 3. I am currently trying to check based on the x position of invaders.
So:
Each aliens x position is turned into an attribute (Inv1, Inv2X, Inv3X)
Inv 1 checks if Inv2X and Inv3X is not equal to Inv1X then I can fire
Inv 2 checks if Inv3X is not equal to Inv2X then I can fire
Now I know the starting x positions of Inv 2 & Inv 3 are the same as Inv 1 to begin with because there is a spawn rule in Inv 1 that spawns Inv 2 actor at same self.positionX and self.positionY-50 (set to 50 so I can clearly see if any Inv 1s are firing when they shouldn't). And Inv 2 has a spawn rule for In 3 using the same position.
The spawning of Invaders works fine but they continue to fire if another Invader is below them
Thanks
Dysnak
Comments
Lots of spawning going on then. (It can make your game quite slow as its one of the more intensive behaviors, but sometimes its the only way to achieve what you want).
You may be getting problems because they are spawned but not sure.
It sounds like your doing everything right otherwise.
Could you try it a different way, (if you've got like 12 invaders on screen at one time?) Could you make a game attribute. Which tracked each column of invaders.
e.g. column_a, column_b, column_c etc.
so if invader3 is shot in column a, change attribute column_a from 1 to.. 2. and if invader2 is shot change column_a to 3.
Then on each of the corresponding invaders, have a rule,
invader1
if column_a = 1 then change attribute allowed_to_shoot to 1.
invader2
if column_a = 3 then change attribute allowed_to_shoot to 1.
invader3
if column_a = 3 then change attribute allowed_to_shoot to 1.
Not sure how well this idea would work with your set up.. But at least it will do away with some constrain attributes where you would be tracking their x_position as that is also pretty processor intensive along with spawning and timers.
Hope its of some use anyway.
Good luck, look forward to seeing the completed game.
(You could also setup some tracking to see if all the invaders in a row have been destroyed, if they have, something else happens...)
One question though you mentioned they are spawned but not 'sure', does sure mean placed in the scene through the editor?