[SOLVED]How do I write the boolean logic for my letter game.

0 favourites
  • 6 posts
From the Asset Store
A cool way for kids to write and practice English Alphabets
  • I have attached an Image to make it easier to explain. There are 8 spaces and 21 letters/symbols.

    I need to the game to have the following functionality:

    drag letter on/off a space and the letter snaps to center of the space

    letter cant go on a space that already has a letter. If you try drag a letter it will just go back to original position.

    letters on one space can move to an empty space but if there is a letter there it returns back to the space it was.

    Basically you should be able to drag and drop letters anywhere as long as there is not already a letter there.

    Below is working logic for dragging and snapping while also making sure the letter cant go on a space that already has a letter:

    The area I am having trouble with is when you drag a letter off a space and have the space's boolean value set back to false so that another letter can be placed there.

    Any help would be much appreciated

  • You can do this:

    fullLeterBox on Drag Start

    ...fullLeterBox is overlapping emptyLetterBox -> emptyLetterBox set hasLetter to False

    One other thing - what if when you drop the letter, it's overlapping two empty boxes?

    I suggest you add another sub-event under #11:

    emptyLetterBox pick nearest to (fullLeterBox.x, fullLeterBox.y)

  • Awesome! It's working now. That was a good tip also regarding overlapping boxes. When I tried to drag over two boxes a box was set to true when it did not have a letter in it. I wonder can I clean this up a bit though. I have three separate events now to cover all eventualities. I don't see how I can simplify though....

  • Just to point out, event 16 is making sure the letter snaps back to its origin when removed from space. This is not covered by event 9's else statement as far as I can tell or something is preventing it.

  • Nah, it all looks good to me. Couldn't write it better myself

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tnx again!

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