Space Invaders logic. Need help (NEW PROBLEM)

0 favourites
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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


  • its because X remains 900 !

    try to add an action that change X to 899 or less below the drop action

  • 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 :(

  • 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 )

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








  • 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

    EDIT * - Here's the CAP file if it's any help - spaceinvaders.capx

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Hmm, a perfectly laid out problem with a .capx included, why hasn't this been solved yet!? <img src="smileys/smiley17.gif" border="0" align="middle">

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

    SpaceInvaders_Edited.capx (r95)

  • 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.

  • Yeah, that's what I did in the edited .capx, removed those conditions. Just wanted to make sure I hadn't broken anything in the process.

  • Nimtrix You removed the code that moves the enemies down when they reach the end!

  • ramones:

    Oh, yeah I just realized, fixing it now =)

    Alright, should be fixed now, had a feeling I did something, that's why I kept going on about breaking things. xD Thanks ramones!

  • Nope , You didn't Nimtrix , But your old pal Kbd fixed that for ya !! :)

    Here it is !

  • :

    What do you mean nope? =)

    Haha, they're moving down fine aren't they?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)