Godot Version 4.6.3
Question
Hey guys!
I wanna create a very simple game for a Jam with the focus on completion and presentation rather than complexity in game design. With that in mind I’d like to create a game with 9 cells which each have assigned a random number from 1 to 9.
You are supposed to flip them and the values are added and you have to reach a certain value set by the program randomly. There will be 45 rounds, since there are 45 possible values in total. And you gain and lose depending on your performance in each round.
I’d also like two sorts of preview features. One where the random numbers are shown for a short time right at the start of a turn and a selective preview function for single cells called by the player.
My goal with this post is not to have all questions answered on the spot but rather have a little support on the general approach. I am a newbee at coding and I know there’s something with arrays here but I wouldn’t know how or where to start. If one or more could lend a hand here, that would be ace.
Thanks for your time and help! Love you guys!
Hi,
Soo if I get this right then the gameplay is: the game choses a random number like 20.The player flips those 9 boxes and if the number of that box is lucky like 15,5 and the sum of them is 20, you win?
Can you explain how? lol
Is this some variant of that memory game where you flip cards up to match them but instead of matching, you’re trying to sum them up and once you exceed like in blackjack, you fail and all the cards turn back over. And because the total is always 45, those values nearer the end and beginning, it’s easier since you always can exclude one or include one number?
It’s interesting, though I think if you vary the number instead of letting it be one to nine always, it’d add more challenge. But as it is, you can just use a simple arrays for this and put the logic in the parent or a global. Then you get each label in the square to always reflect an entry in that array. Finally, you just switch its visibility on and off depending on player choice.
You might consider putting them all in one group. This way, you can just call them at once with godot’s innate call group functions. Or just loop through them at the start to show and after the timer is up, stop showing them.
You likely also need a variable to toggle when it is ok for the player to flip things and when the game ignores the player’s input like when you’re playing an animation for the start of a round.
For the sum check, you can just reset total to zero, loop through the labels for each and ask them if they are visible. If they are, then you add them.
Not sure if i understand your game right, but those are the broad outlines for a simple implementation
Yo @Frozen_Fried
Not quite but almost. You have to arrive at the value (in your example) of 20 by picking the right numbers from 1 to 9. For example you would have to find the numbers 9, 8 and 3 (or any other valid cobination), since they add up to 20.
Does that make more sense?
There are 45 rounds in total because if you add the numbers 1 through 9 you get 45.
You got the whole gist of it.
Yeah, it could be beefed up gameplay-wise but as it is I’d like a small project with focus on completion. I am lost enough as it is with a little scale like this with regards to coding. 
Yo!
Just found out that my brain is just too small for puzzle games xD
Just break up the tasks. Like for a start, just place the label or whatever your preference is on the squares. You can do things manually or otherwise. But once the numbers are there, u can experiment with toggling them on and off as a start.
For it’s just a matter of referring to the parent node or global’s array. Then writing the logic to shuffle the contents of the array or otherwise generate the random numbers. Add in the check for the times when you don’t want the user’s input to count and you’re mostly done.
Everyone is lost at the start, but I find just writing out what you need to tends to help.
Thanks man!
I got the array running and it generates numbers. So far so good. It’s all over the place and not from 1 to 9 but at least within 1 to 9.
How do I turn the values of this array into strings that I can then pass on to the label in my scene?