If..Then..Else?

This forum is currently in read-only mode.
  • Hi,

    Only had Construct for one week so still complete noob, many years ago I used to program in Speccy Basic, and then Stos ( on the Atari ST ).

    Have created a one screen game, move collect keys, open doors leave screen. I have a variable "keys" that debug shows to be working just as I hoped, ie increases by one if key is picked up, decreases when door is destroyed, but I need to know how to perform the equivalent of:-

    If "keys" = 0

    Then Bounce

    Else Destroy

    So that if I have no key then the door will remain locked

    Hope the explaination is clear, TIA Brett

  • if dude collides with door

    +value "keys" = 0

    --> bounce

    if dude collides with door

    +value "keys" = bigger than 0

    --> destroy door

    --> subtract 1 from "keys"

    try something like that.

  • Hi thanks for your reply, the real problem is in using construct, I know what I want to do, and the order I need to do them in, the trouble is that I right click here and can only compare a variable if it is the first set of an event, I would like to set it up as :-

    if dude hits door

    and keys = 0

    But can only seem to start from :-

    if keys = 0

    and dude hits door

    Then new action does not include Bounce in the options. I just seem to be fighting the programs controls rather than getting on with what I want to do. Have tried the FAQ and Wiki but not like a real manual. Cheers Brett

  • I'm not 100% sure what your problem was so this cap might be what you've got made already.

    http://dl.dropbox.com/u/1646976/doorsandkeys.cap

    Try go through the gray door at the start, yellow square is the key.

    Sorry if this is what you already have.

    Also posting a cap is always helpful to anyone understanding your problem.

  • Hi many thanks for taking the time and trouble to help, sadly the .cap you uploaded will not run, I get an error message saying that construct.exe has come to an unexpected termination. try to follow this:-

    I right click in the event editor and create an event sprite 1 collides with sprite 2 ( dude collides with door)

    by right clicking this I can add sub event: is global variable 'keys' Equal to 0

    but right click or left click on this I can only find options to delete the event or change/add conditions, there is no way to add the action to make dude bounce

    I can add the action bounce or destroy after the event dude collides door, but after the event or sub event is global variable 'keys' Equal to 0 I cannot add an action, only sub events which do not have the option to bounce or destroy.

    Hope this is clearer

    Brett

  • Hi Minor,

    Have uploaded the file keydoor.cap to Forums Uploads, onehourcomp,

    hope this helps make things clearer

    Cheers

    Brett

  • Since you can't open Minor's file I allowed myself to edit it a little(rename the sprites) and make a screenshot. I hope it helps you.

  • Tyrus rules O.K.

    Have it working now,

    Any idea why I colud not open Minor's file?

    Think it may be to do with my version of C++

    Anyway many thanks maybe now i can sleep at night.

    Cheers

    Brett

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Any idea why I colud not open Minor's file?

    What version of Construct are you using? The most likely reason is that he's using a newer version.

  • My bad - I'm using the latest unstable build 0.99.82.

    I always forget to mention my version when making a cap

  • My version is 0.99.62

    it was the latest stable version available when I went to the download site. Working now, well need to add a/some baddies so that dying becomes an option, but If..Else sorted thanks.

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