Constrain value between two points

FajlajpFajlajp Member Posts: 666
edited October 2013 in Working with GS (Mac)
I´m stuck with a thing in my game that starts to get really annoying.
Here is a picture of my slider(it´s not a volume slider)
photo 10_BETBAR_A_zps5e39fd70.png
The slider should be like in the game "governor of poker where you slide a little thing to determine how much you want to bet/raise
I´ve constrained it so it doesn´t go to far but I´ve the problem of constraining it to a value. I want the value to be between to values. We can call them moneyMax and moneyMin. But I can´t get it to constrain between does to vaule when I slide determine on how far the slider is to the right.
Hope this not was a bad explanation and I hope that you understand what I mean.
Please help me.

Comments

  • -Timo--Timo- Member Posts: 2,313
    you know how to make it slide with a min and max point? ;)
    I don't know your values and how to do this exactly but you have to do something with the self.position.x from the money thing :) something like constrain game.moneyBet to self.position.x/4? so when position is 200 the bet is 50 and when position is 1000 bet is 250?
    but probably you have to do something with the code ;)
    hope this makes sense
  • FajlajpFajlajp Member Posts: 666
    I know that it has to do with the self.position.x and moneybbut I just don't know how
  • -Timo--Timo- Member Posts: 2,313
    don't you know how to get the right values? or don't you know how to put this in a rule or something?
  • FajlajpFajlajp Member Posts: 666
    how to get the right values
  • -Timo--Timo- Member Posts: 2,313
    edited October 2013
    well before someone can help you we need more info. what do you want to be minimum bet? what do you want to be maximum bet? what is the money actor his min positionX and max positionX?
  • FajlajpFajlajp Member Posts: 666
    It all depends on how much money you have and what is miniumum to check/call.
    That's why I've two to values called moneyMin and moneyMax.
  • FajlajpFajlajp Member Posts: 666
    It's 300 between sliderMin and sliderMax
  • -Timo--Timo- Member Posts: 2,313
    edited October 2013
    constrain game.bet to ((money.max-money.min)/300+(money.min/300))*self.position-300
    didn't tried so not sure if it will work... ;)

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited October 2013
    Try something like this in the slider actor:
    When pressed
    -- Constrain Attribute: self.Position.X To: max( game.sliderMin ,min( game.sliderMax , game.Mouse.Position.X ))
    -- Constrain Attribute: game.betAmount To:300*( self.Position.X /( game.sliderMax - game.sliderMin ))
  • RexCarsalotRexCarsalot Member Posts: 96
    I know this doesn't HELP with your question, but I wanted to mention: Did you notice the small skull & cross swords image that goes over the wooden board? This is what you will actually be sliding. When you slide that skull, the amount should show up in the board window.
  • RexCarsalotRexCarsalot Member Posts: 96
    edited October 2013
    Also, I emailed you several new updates as well as my suggestion for the basic game structure, with starting chip and blind raises.
  • FajlajpFajlajp Member Posts: 666
    @rexcarsalot
    Yes,I noticed the skull :)
  • FajlajpFajlajp Member Posts: 666
    Still having problem with this :(
    It seems to be a really hard thing to solve. So I thought I should explain better so more understand.

    I´m try to making a bet/raise slide bar like in the game "governor of poker" and it basiclly a slider that has a minimum value and a max value.
    I´ve set the bar to slide like this:
    -- Constrain Attribute: self.Position.X To: max( game.sliderMin ,min( game.sliderMax , game.Mouse.Position.X )
    The sliderMin is 575 and the sliderMax is 875 so it´s 300 between those points. Now I want to constrain a value called BetAmount between those two points and the miniumum value should be moneyMin and moneyMax.
    moneyMin and moneyMax could change depending the minimum you have to bet and max is how much money you have.
    Do you guys understand what I mean?
  • FajlajpFajlajp Member Posts: 666
    edited October 2013
    I tag some Gamesalad pros that I´m sure could help me fix this, but all other help is accepted ;)
    @socks
    @fryingbaconstudios
    @rthurman
    @gyroscope
    @jonmulcahy
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Is this what you're looking for?
  • FajlajpFajlajp Member Posts: 666
    @Jamie_c
    It´s not always you have 300 and it´s not always you have to bet a minimum of 0. So it´s right but wrong.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    What are the min and max bets? I guess I'm thinking you would just use that same concept and adjust the formula as needed for whatever your current min and max bets are.
  • MantoManto Member Posts: 796
    Constrain Attribute: BetAmount to moneyMin+(moneyMax-moneyMin)*sliderValue/300

    sliderValue changes from 0 to 300. It could be replaced by slider.position.x-sliderMin.
  • FajlajpFajlajp Member Posts: 666
    @manto1
    It worked :) Thanks :)
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Ah yes I was going reccomend using a variable in the equation as a multiplier. Kind of the same as above.
Sign In or Register to comment.