How do I work a three of a kind (Dice game)?

0 favourites
From the Asset Store
a basic game template with which you can show your own creativity with interactive and exciting rolling of ion dice!
  • I'm re-creating a dice game, Zonk!!!. I'm having trouble by making a score for a 3 of the kind in the same roll. For Ex: if I rolled three 1's in the same roll, I'll get a score of 1,000. I'm using animation frames, but trying to make 1 a three of a kind for ever dice, is long. Can ya'll help me fix this code?

    If ya'll could help me with one of them, I can do the rest for the remaining numbers.

    Tagged:

  • You could use pickedcount to determine how many are on screen, does an animation frame check really matter if you used 6 different objects instead of 1 object? Something like for each ZD1 > set variable to ZD1.pickedcount would give you the number on screen and if it's 3 then you know it's 3 of a kind.

  • You could use pickedcount to determine how many are on screen, does an animation frame check really matter if you used 6 different objects instead of 1 object? Something like for each ZD1 > set variable to ZD1.pickedcount would give you the number on screen and if it's 3 then you know it's 3 of a kind.

    Can you show me a code of that please?

  • For the code, will it follow the rule I have for the kinds

  • Not sure because it depends how you coded the rest of it. What I shared is the code : system for each ZD1 : set variable to ZD1.pickedcount. This counts the number on screen which is what you want?

  • How can I set the pickedcount? For instance, my instance variable of the ZD1, is called faceVal, which will take effect of the animation fame of the dice. If the animationframe of ZD1 is 1, then the faceVal is 1. How can I make it a 3 of a kind in the same roll out of this?

    This is all of the code for right now

  • How can I set the pickedcount? For instance, my instance variable of the ZD1, is called faceVal, which will take effect of the animation fame of the dice. If the animationframe of ZD1 is 1, then the faceVal is 1. How can I make it a 3 of a kind in the same roll out of this?

    This is all of the code for right now

    How can I set the pickedcount? For this, I meant how can I set this to 3, and how can I use the animation frames in it as well? If I'd roll 3: 1's (1,000), 2's (200), 3's (300), 4's (400), 5's (500), or 6's (600).

    I could probably understand it better if you show an example of Event Sheet in the (test) game.

  • Don't mind the current code in the function command, that where the 3, 4, 5 of a kinds will be

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When you've attempted to make the game yourself it's not as easy as describing what to do. It looks like you are using 6 instances of the same object so that's good. In the first example you are trying to compare 6 different objects and I was wondering why. On the code I'm seeing there you can use 'ZD1 FaceVal=1' : action - set a variable to ZD1.pickedcount. That gives you the number of ZD1 that rolled a 1 etc

  • When you've attempted to make the game yourself it's not as easy as describing what to do. It looks like you are using 6 instances of the same object so that's good. In the first example you are trying to compare 6 different objects and I was wondering why. On the code I'm seeing there you can use 'ZD1 FaceVal=1' : action - set a variable to ZD1.pickedcount. That gives you the number of ZD1 that rolled a 1 etc

    Sorry, I'm still not following

  • > When you've attempted to make the game yourself it's not as easy as describing what to do. It looks like you are using 6 instances of the same object so that's good. In the first example you are trying to compare 6 different objects and I was wondering why. On the code I'm seeing there you can use 'ZD1 FaceVal=1' : action - set a variable to ZD1.pickedcount. That gives you the number of ZD1 that rolled a 1 etc

    Sorry, I'm still not following

    With help, I'm able to figure out what you mean. Thank you for your help!!! I'll give you a shout out in the game, once finished

  • > > When you've attempted to make the game yourself it's not as easy as describing what to do. It looks like you are using 6 instances of the same object so that's good. In the first example you are trying to compare 6 different objects and I was wondering why. On the code I'm seeing there you can use 'ZD1 FaceVal=1' : action - set a variable to ZD1.pickedcount. That gives you the number of ZD1 that rolled a 1 etc

    >

    > Sorry, I'm still not following

    With help, I'm able to figure out what you mean. Thank you for your help!!! I'll give you a shout out in the game, once finished

    Now how would I make a small (1,2,3,4,5 or 2,3,4,5,6) and a large (1,2,3,4,5,6) straight without messing up the code when it comes to scoring if ZD1 is 1 and ZD5 is 1 (ZD1 = 1 - Add 100, ZD5 = 1 - Add 50) I've tried to figure it out, but it kept messing up the score by adding extra points

  • You would need to check if any Dice have val=1 AND any Dice have val=2 etc until 5. And since it's a chore to do that with each Dice you can put the Dice objects into a Family, this limits events so you can group all Dice together.

    Then you can say for each Dice (family) where Dice.val=1 set variable to Dice.pickedcount. Same as before basically but with a Family. Then if it's 1 or greater then you are good. You could check for val=1,2,3,4,5 in the same event with subsequent sub event checks and if all of them return 1 or greater then you have the straight.

  • Also I came up with a way to make this game using an array but you already started making it. You could roll 6 dice which are 6 rows of an array, an array helps you to count the number of each type or determine if you rolled something by using 'array contains value'. Also you can sort an array so you could put any dice rolls in numerical order to find the straight.

  • Also I came up with a way to make this game using an array but you already started making it. You could roll 6 dice which are 6 rows of an array, an array helps you to count the number of each type or determine if you rolled something by using 'array contains value'. Also you can sort an array so you could put any dice rolls in numerical order to find the straight.

    It's going to take some time to figure out how to use it. Thanks you for the help

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