Array Checking

0 favourites
  • 14 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • My subject probably makes no sense, but I wasn't sure how to explain it.

    I'm making a word search game. The game works great right now, but there is a ton of code and I am wondering if there is a way to shrink it.

    I'm using an array to store a 1 or 0 value for each letter in the grid.

    I am using that to check if a word is formed. When a letter is clicked on, it turns the array index of that letter to a 1.

    Say the word is bat at position 1,2,3. I check if array.at(1) and array.at(2) and array.at(3) are = to 1. If so, that word is found. however, I also need a condition if all the other letters are set to 0. So for each word there is 26 lines of actions.

    Is there anyway to shrink this? Eventually I would like to just create strings of data to build new boards and have a Key variable has the key for each board.

    I hope that makes sense.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Posting your capx would probably help visualize exactly what you're meaning.

  • Yeah sorry. Completely spaced it

    For my sake, I currently don't have any of the Check for 0 conditions, only because it's a ton of work and I wanted to know if there was another way first.

    www.edfarias.com/word.capx

  • I'm thinking maybe there isn't an easy way to do this LOL.

  • Instead of checking with events, you could make a variable for your txtWords which stores a list of the txtGame.IIDs then you could just check with a pattern in events.

    http://dl.dropbox.com/u/5426011/examples12/ArcadEd.capx r99

    edit: The array object isn't used anymore.

    Also here is another way of doing something similar:

    http://www.scirra.com/forum/word-search-game_topic44971.html

  • Thanks man, that is really awesome. I'm still trying to wrap my head around exactly what you did. If I have any questions I will post.

  • OK, I figured it out. Genius man, I didn't even think of using the instance variables :). Thanks again. I learn so many new things about construct every day.

  • Hi I just wonder if your word search game was been made?! :) because all the links presented are server error . :((

  • YEah, it's been on the windows, apple and google stores for several months now. It was the first game I finished and published :).

    https://itunes.apple.com/us/app/word-search-4-kids/id564990078?ls=1&mt=8

  • R0J0hound

    Heeeeelp!! What should i do. If all the words were found. How should i put it on next layout?

    its system then Compare two values then: " what should i put to know if all the words in 'txtWord' is found "

    before i make an action: system go to next layout.

    thanks in advance <img src="smileys/smiley32.gif" border="0" align="middle" />

  • maddymouse

    If you know how many words are on each layout, then create a global variable to keep track.

    Global Variable WordsFound

    Each time a word is a found, add 1 to WordsFound

    When WordsFound = Amount of words on the level

    -> reset WordsFound to 0

    -> go to next layout

  • ArcadEd

    it works!! thanks a lot <img src="smileys/smiley4.gif" border="0" align="middle" /> <img src="smileys/smiley32.gif" border="0" align="middle" />

  • how did you groups all the scattered letters into one group? Did you use family? (i am only using free edition. i dont have family, is there anything i can do to make it the same??) <img src="smileys/smiley24.gif" border="0" align="middle" /> <img src="smileys/smiley5.gif" border="0" align="middle" />

  • I didn't use a family. In my final version of the game I used arrays that that stored the letters.

    <img src="http://content.screencast.com/users/ArcadEd/folders/Jing/media/6ee23e4d-04b0-40ef-bcdd-244835e07472/2013-03-05_0855.png" border="0" />

    Then using tokenat I populate the Text Boxes.

    <img src="http://content.screencast.com/users/ArcadEd/folders/Jing/media/c7ade66e-d08d-474c-9e47-31a82d0f73f5/2013-03-05_0858.png" border="0" />

    This really wasn't an easy project at first, especially if you are just learning construct.

    The way I did it was such that I could easily add levels just by updating the 3 main global variables, or even have those global variables updated via an ajax/php action.

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