2 player switch turn different score

PRRP gamesPRRP games Member Posts: 27
edited January 2015 in Working with GS (PC)

Hey guys,
I am building a dart counter. But i have a few questions about it.

How can i make a number keybord with a blank box.
And when I press enter the number goes from the total score, of one of the players.

After pressing enter, how can i make the turn switch?

Sorry for my really bad English :| ,

PRRP

Best Answer

  • tatiangtatiang Posts: 11,949
    Accepted Answer

    Make an integer attribute called game.playerTurn and set it to 1. It will switch between 1 and 2. Make two more integer attributes called game.player1Score and game.player2Score. Make a text attribute called game.keyboardInput.

    If touch is pressed
    Keyboard Input [prompt: "Enter a number"] attribute game.keyboardInput

    If game.keyboardInput ≠ ""
    If game.playerTurn=1
    Change attribute game.player1Score to game.player1Score-game.keyboardInput
    If game.playerTurn=2
    Change attribute game.player2Score to game.player2Score-game.keyboardInput
    Change attribute game.playerTurn to 3-game.playerTurn
    Change attribute game.keyboardInput to ""

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

  • PRRP gamesPRRP games Member Posts: 27

    I want to build an app that counts my score when i am darting in real life.
    I already made two scores but i want a way of typing in my score. ( like this: )
    How can I make that work, because there are two different scores?

  • PRRP gamesPRRP games Member Posts: 27

    @tatiang‌ Thanks!

  • PRRP gamesPRRP games Member Posts: 27

    One more question.

    @tatiang said:

    If touch is pressed Where do i have top put this in?
    Keyboard Input [prompt: "Enter a number"] attribute game.keyboardInput


    If game.keyboardInput ≠ ""
    If game.playerTurn=1
    Change attribute game.player1Score to game.player1Score-game.keyboardInput
    If game.playerTurn=2
    Change attribute game.player2Score to game.player2Score-game.keyboardInput
    Change attribute game.playerTurn to 3-game.playerTurn
    Change attribute game.keyboardInput to ""

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Are we talking about darts as in throwing darts at a dart board? :D

    Can you give me an example of how a round might go? Does each player start with a certain number of points and then subtract points each turn? Sorry, I'm not that familiar with darts.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ArmellineArmelline Member, PRO Posts: 5,354
    edited January 2015

    Darts is a... unique game :D Someone sat down one day and said "I'm going to make a game that people will mostly play drunk, or at least with a pint in their hand. For the scoring, I'll make them subtract, add and multiply numbers of up to three digits at every opportunity, and put the numbers in a seemingly random order!"

    At least that's what I like to believe.

    http://www.darts.org.nz/dart-scoring.htm

    (Rules will vary ofc, but this is the key points.)

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Lol @Armelline‌, looks like I have some learning to do!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    With a numeric keypad like that, you have to find a way to "build" the number. If you wanted to key in 43, you can't just add 4+3. You either have to add a factor of ten (410^1+310^0) or concatenate text ("4".."3"). I'd probably do the latter. Someone probably already has a demo of this...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ArmellineArmelline Member, PRO Posts: 5,354
    edited January 2015

    In short, a person throws three darts each round. Each dart can hit one of 20 wedges. Within that wedge, it can hit single, double or triple score. So if you hit the 5 wedge, you score will be 5, 10 or 15 depending on where you hit. You can also hit the outer center ring for 25 points or the inner ring for 50 points.

    So the lowest showing dart possible is 1, and the highest is 60.

    These scores are then deducted from the total (501 by the linked rules) and the first player to reach 0 (and meet a "win" condition if one is required), wins.

  • PRRP gamesPRRP games Member Posts: 27

    Hey,

    I made my number pad! and its working.
    But at darts you can throw a maximum of 180 at 1 turn. So could i set
    the maximum of my text input to 180?

  • ArmellineArmelline Member, PRO Posts: 5,354

    I'd recommend you put a rule that says "If inputted number > 180, change inputted number to 180". Trying to limit the input itself would be very problematic.

  • PRRP gamesPRRP games Member Posts: 27

    At witch atribute i have to adjust that?

  • PRRP gamesPRRP games Member Posts: 27
    edited January 2015

    stupid question :#
    Witch condition i have to add?

  • ArmellineArmelline Member, PRO Posts: 5,354

    Whichever one you're storing the inputted score in.

  • PRRP gamesPRRP games Member Posts: 27

    What I added to my text box actor:
    Rule
    attribute

    but i dont know what to select after 'if'

  • ArmellineArmelline Member, PRO Posts: 5,354

    I think you're going to need to explain a little about how you set up the number pad. When you press a number, what happens (in the logic)?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    You guys have been busy! I made a demo but I'm not sure you need it any more. It limits entry to 2 digits.

    http://forums.gamesalad.com/discussion/comment/516905/#Comment_516905

    Edit: oops, just noticed you're using PC Creator* and I made the demo in Mac Creator. Carry on...

    *I should be getting Windows 8 set up in a day or two so no more lame excuses for me :p

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • PRRP gamesPRRP games Member Posts: 27
    edited January 2015

    imagephoto vraagplaatje_zps1e247b0e.jpg" alt="" title="" />

    This are my rules. but it didn't work :(

  • PRRP gamesPRRP games Member Posts: 27
    edited January 2015

    thanks @tatiang for your help.
    indeed, the number pad is working but there are a few things that aren't.

    • I dont haven a maximum for text input ( you can throw a maximum of 180 per round at darts)
    • When i press the enter button the turn doesn't switch to the other player
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    The way I did this was to make the input a text attribute and the rule for adding a digit (pressing a button) limited to textLength(game.input) < 2, or for your needs, < 3. It would take more sophisticated rules to limit the score to 180. And the enter button should change game.currentPlayer to 3-game.currentPlayer, assuming that game.currentPlayer starts with a value of 1.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • PRRP gamesPRRP games Member Posts: 27
    edited January 2015

    This is my text box at the moment:

    imagephoto vraagplaatje2_zps47f15819.jpg" alt="" title="" />

    What should i change?
    it works fine now, only not with the turnes

    at the first 'change attribute' in the second box is standing: game.score1-game.keyboardinput

  • PRRP gamesPRRP games Member Posts: 27

    @tatiang‌

    I understand what you did with the enter button, but i can't make it work. can you explain it a little more.

    imagephoto vraagplaatje3_zps875af1ff.jpg" alt="" title="" />

    this are my Game attributes. How can i make the turn switch work with this attributes?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    As I explained above, you use an attribute set to 1 and subtract it from 3 each time the enter button is pressed. This might look strange but mathematically it works like this:

    If it is player 1's turn and you press the enter button, the next player will be 3-1=2.
    If it is player 2's turn and you press the enter button, the next player will be 3-2=1.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.