How do I import a dictionary of words into my game?

0 favourites
  • 6 posts
From the Asset Store
Simple but fun word game. Restore an original word from shuffled letters.
  • Hi all,

    I want to create an auto-runner that uses real words to influence terrain generation. My idea is to create pieces of the environment using only ONE Sprite that has 26 frames (representing the entire pool of the English alphabet).


    The word "CARS" is selected and stored in an Array. The game will loop through the array spawning instances of "Sprite" and setting the frame to the equivalent number in alphabet (-1).


    For 1 to TotalLettersInWord

    -> Spawn Sprite at XY

    -> Set Frame to WordArray[CurrentLetter]

    -> Add 1 to CurrentLetter

    All sprites will be moving to the Left with behaviour "Destroy outside of layout"

    Once the last letter has been spawned it goes back to the first letter, looping indefinitely (another part of the game will change the word).

    I am using this method because I think it will be an interesting way to create patterns within the game's landscapes based on the patterns in word construction in the English language, i.e., vowels are only used after certain letters, and certain combinations NEVER come up, such as X followed by R.

    SO MY QUESTION IS - What is the best method of creating a list / table of words that the game chooses from? I want to be able to sort them by character length, but other than that I could practically include a whole dictionary as long as it wouldn't slow the game down to a crawl. Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Actually, using the dictionary object would be perfect for this..

  • Actually, using the dictionary object would be perfect for this..

    Oh my.. There's a dictionary object?... I think I have been "thinking around the problem" and overlooked something major...

  • I'd use an array. It's not value pairs you are dealing with, but just single entries. It's also easier to access. Dictionaries are not ordered, you can't access entries randomly.

    So just create an array with size (words, 1, 1) and then fill the words.

    Construct 2 only offers sorting alphabetically as far as I can see. So if you want to quickly be able to access words with a specific length, you could for example sort your words by length right from the start and then remember where are words with length x. Another way would be creating multiple arrays (from the same object), one for each word length (give them an instance variable) and then selecting the appropriate array.

    Maybe there is also a data structure plugin that let's you perform some fast searches, but as far as I can see, your wordlist won't change once it's in a game, so theres probably no need for expensive searches.

  • Dictionaries are not ordered, you can't access entries


    Doesn't the tokenat() expression work for that, or am I misunderstanding you?

  • Doesn't the tokenat() expression work for that, or am I misunderstanding you?

    My sentence was missing a word. Wanted to say that you can't access a random key from the dictionary (or can you, aside from the "for each key"-loop?).

    And not sure what you want to do with tokenat. Did you want to store keys like "4" for 4 letter words, "5" for five letter words and give the keys values like "park;east;gone;..."? I don't see an advantage over the array then, if anything I think it would be slower than just grabbing a value directly.

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