Need Help with a Word Find game I'm making, please.

C

ChillAssLofi

Guest
Hi, I am trying to make a "word find game". You know where you get a jumble of random letters and you try to find words hidden inside. (I suppose this is actually more like the game Boggle if you're familiar with that.) As you choose the tiles with the letters, the letters should appear on screen below the game board as if you were typing them. They then also need to be checked by the dictionary/spellcheck functionality I have built in to make sure it's a valid word. Once you choose the letters, they get destroyed, assuming of course that you spelled a word correctly. My problem lies within the two halves of this communicating correctly with one another. The gameboard with the falling completely-random tiles works fine. The dictionary (when set to accept keyboard_input) works correctly, but when I set it to use the tiles to spell out the words (through the mouse), nothing happens. The two halves of the game have no idea the other exists. below is the code to the tiles, can someone be kind enough to look through it and see where I'm going wrong? (I'm not new to GML but I'm also far far far away from being any sort of master at this) Thank you for any help you can give me.
create.png
draw.pngstep.png
 

Nidoking

Member
How much do you understand about variable scope? It looks like every o_tile has its own str variable, but you're trying to use that as an accumulator for all of the letters clicked. (Clumsily... you're overwriting str rather than adding the new letter to it.) For str to accumulate letters from multiple tiles, you'd need to put it in an instance of an object that every tile can read or make it global. And you might want to scour your whole project for other variables you've scoped incorrectly.
 
C

ChillAssLofi

Guest
How much do you understand about variable scope? It looks like every o_tile has its own str variable, but you're trying to use that as an accumulator for all of the letters clicked. (Clumsily... you're overwriting str rather than adding the new letter to it.) For str to accumulate letters from multiple tiles, you'd need to put it in an instance of an object that every tile can read or make it global. And you might want to scour your whole project for other variables you've scoped incorrectly.
I know nothing about scoping at all. But what I'm getting from your answer is that I'm overusing str. I should therefore make it either global, or make an instance that can read the tile? Would making str a global variable fix the issue? I am not sure at all how to make an instance of an object that every tile can read. Like I said, I'm not new to GML, but there's a lot of stuff I just don't know, and oddly there's not any tutorials on word games, so I'm basically doing this with my limited knowledge, tutorials about on screen keyboards, and match-3 puzzles. Thank you for your answer however, I appreciate it.
 

Nidoking

Member
Variable scoping is a wide enough topic that a more general tutorial should help you with it. The point is that having every tile maintain its own str is not what you want. You want one single str that stores letters for all tiles. Making it global will do that, but I would recommend not initializing it in the o_tile create event. Same with randomize. Those are things you want to do once, at the start of the game. For that, I prefer to use a persistent control object.
 
C

ChillAssLofi

Guest
Variable scoping is a wide enough topic that a more general tutorial should help you with it. The point is that having every tile maintain its own str is not what you want. You want one single str that stores letters for all tiles. Making it global will do that, but I would recommend not initializing it in the o_tile create event. Same with randomize. Those are things you want to do once, at the start of the game. For that, I prefer to use a persistent control object.
Oh I get what you're saying now. I should make a "blank" object, (meaning; no-sprite) and in that put the randomize and the global variables, and then put that into the room? Thank you so much, I'll give that try right now.
 
Top