• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Crossword Puzzle Design

Hello All,

I'm working on a crossword puzzle and I'm not sure how to begin coding.

I have one main sprite with 26 frames, each containing a letter of the alphabet. I have an enum for themes. As in "animals", "places", etc. I have one array set up so far, which contains numerous animal types; "bear", "koala", etc.

I would like a random theme to be selected, which then accesses a script to place the appropriate words in an array. Afterwards, word by word, I plan on reading one letter at a time for grid placement.

For example: Using the word "bear", I would obtain the B, then place the sprite on a grid using sprite_index 2, which is a "b". I would then continue for each letter of the word, then move onto the next.

This is my idea and I'm not sure it's a good approach, but I believe it could be much simpler. Would a DS Map be better? Is an enum recommended? etc.

Please let me know if I'm on the right track. Also, I'm not sure how to implement what I just explained. It's quite tricky!

Thanks much!
 

CloseRange

Member
well sprites for your letters isn't necessary.
Just use a mix of fonts and strings to work with and draw each letter with draw_text_transform to get it to the right size.
If you want to use your own custom font then you can use sprites but turn the sprites into a font and continue to use draw_text_transformed

If you want the crosswords to be a randomly generated pattern then it's a bit complex and a bit overkill perhaps.
If you want just advice on how to work with custom made patterns that's easier to help with.

Personally I'd make a custom data structure and store each puzzle in a file with that structure.
It could maybe look something like this:
Code:
bear:15,10,0
eagle:16,10,1
obviously you have the first part that is the word.
Then the next 2 numbers would represent the first cell position of the first letter. and the 3rd number would be the direction the word went.
0 - right
1 - down
you don't need a left and up because most crosswords don't have words that go that way. If you need it though you could always type the word backwards.
So in this case bear would be at position 15, 10 and face right
and eagle would be at 16 10 and face down.

You could just draw each puzzle out on paper and make a file real quick with the positions and words.
you could have a macro with an array of file names:
Code:
#macro animals
#macro buildings
file[animals, 0] = "file01.txt";
file[animals, 1] = "another_file.txt"
file[buildings, 0] = "file0550.txt"
(this assumes you're using game maker 2 if not you can just use enum's as they work mostly the exact same)
these files could then easily be accessed by you and it would be up to you to just then parse the file into a 2d array with all the characters.

if you want to get fancy you could create a 'crossword creator' that just simply allows you to input characters directly into a grid and then save that out to a file and then you can create crosswords really easily because you don't need real life paper and you don't need to hand type out the file data.
Plus that could be your own 'level editor' that the users can use later down the line. You don't need to keep it in but you can.
A level editor for this would actually be surprisingly easy if you know what you're doing it would take about 1-2 hours.
Just have a method to select a grid cell. Check input using keyboard_string (i think that's the variable name) and update the array.
You'll have to do that anyway if you want the user to be able to fill in the crossword anyway.
 
Great advice! I wouldn't have though of your suggestions and your explanation simplifies things for me much.

I like the idea of a level editor. We'll see how it goes!

Thank you!
 
Top