Space Invaders logic. Need help (NEW PROBLEM)

Get help using Construct 2

Post » Mon Jun 25, 2012 10:38 pm

Hi. I'm making a Space Invaders clone and having trouble working out the logic for when the aliens reach the edge of the screen and drop down a level.

At the moment I have a direction variable set to 1 (for right). Every second the aliens move 10 pixels to the right. I've got it checking for the one of the aliens X coord being >= 900 (just to the left of the screen edge. At that point I set a variable named aliendrop to 1 which tells it to drop all aliens down 20 pixels and change the direction variable to 0 (the left).

Now this works, ish, except that there's a second until the aliens move back below 900 again. In that short period the section that moves the aliens down if the X is >= 900 is executed over and over.

Has anyone any ideas how I should structure it so that the ADD Y is only done once per direction.

I hope I explained it well, it's hurting my brains. lol

Thanks.vandinz2012-06-26 16:13:28
B
19
S
5
G
4
Posts: 208
Reputation: 3,960

Post » Mon Jun 25, 2012 10:51 pm

its because X remains 900 !
try to add an action that change X to 899 or less below the drop actionkbdmaster2012-06-25 22:52:02
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Mon Jun 25, 2012 10:56 pm

I didn't really want to 'jump' the X coord to a value less than 900 as this would make it look like the aliens jerk back which isn't right anyway. I know I'm doing it wrong, there must be a better method to perform the action. I can't come up with one atm though :(
B
19
S
5
G
4
Posts: 208
Reputation: 3,960

Post » Mon Jun 25, 2012 11:10 pm

Sorry , There is another method , I just forgot it :)
You can make the event play 1 time with an event
Here it is !
"The condition : Trigger once while true !"
It's a condition that you have to place last
You can find it in : System > Special Conditions

Note : PM me if it works ( you can pm people by addind in your post @+their name )
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Tue Jun 26, 2012 4:06 am

You could forgo variables altogether and simply use sprites as waypoint markers for the path? On collision the enemy sprite would change direction.


l>-------Vl
lV-------<l
l>-------Vl
lV-------<l
l>-------Vl
Mr E Bear2012-06-26 04:11:07
B
49
S
14
G
3
Posts: 540
Reputation: 5,611

Post » Tue Jun 26, 2012 3:09 pm

Thanks guys. Your suggestion worked a treat KD but I've not run into another issue.

Here's the 'code' to check if the enemy sprite has passed a certain point. It works fine until the player kills all of a certain type. For example in the picture you can see the yellow alien sprite. If the player kills all them, the game then ignores this event and the aliens go off the screen!

I've set it as an OR block so the game checks if alien1 OR alien2 OR alien3 goes passed a point but it's behaving as though it's set as an AND. Have I set this right? Can you spot any problems in the way I've used the OR block?

Thanks again.



Uploaded with ImageShack.us

EDIT * - Here's the CAP file if it's any help - spaceinvaders.capxvandinz2012-06-26 15:14:11
B
19
S
5
G
4
Posts: 208
Reputation: 3,960

Post » Wed Jun 27, 2012 12:40 am

I still can't figure this out. I've tried everything I can think of, read numerous threads on here and I can't see anything wrong with what I've created. So WHY does it treat the OR statements as AND? Is this a known bug?

When all of a certain sprite have been destroyed, is a 'blank' version placed somewhere by the engine that might be messing up the check? I'm pulling my hair out here! lol. vandinz2012-06-27 00:41:34
B
19
S
5
G
4
Posts: 208
Reputation: 3,960

Post » Wed Jun 27, 2012 9:17 pm

OK one last try at bumping this thread. I hate doing that but I'm totally stuck at the moment and can't move on with this issue. PLEASE if anyone has any ideas they'll be greatly appreciated.
B
19
S
5
G
4
Posts: 208
Reputation: 3,960

Post » Wed Jun 27, 2012 10:00 pm

Hmm, a perfectly laid out problem with a .capx included, why hasn't this been solved yet!?

Anyways, I think this should do it, let me know if I broke anything and I'll try again:

SpaceInvaders_Edited.capx (r95)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Wed Jun 27, 2012 10:49 pm

I think the 'pick all' conditions are the problem. 'Pick all Sprite2' is false when there are no Sprite2 so that event won't run.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Next

Return to How do I....?

Who is online

Users browsing this forum: DiabloOvermind, emoticon, odiusfly and 20 guests