Skip navigation
Home/Support/

Forums

1187 Views 7 Replies Latest reply: Aug 6, 2009 6:05 PM by Roulette System Player RSS
wwscoper Calculating status... 46 posts since
May 12, 2009
Currently Being Moderated

May 13, 2009 12:54 PM

updating bets based on _droptarget

I have another question on my roulette game that I am building.

 

The bets for the game are being placed by dragging a chip to a slot on the table. There are six slots, with numbers 1-6, 6-12, 12-18, etc....

 

I have a $25 chip and a $5 chip. I am using _droptarget to detect when a chip has been placed on one of the slots. If a $25 chip is placed on "slot1",

slot1Bet += 25;

 

Now the tricky part...if I move the chip from slot1 to another slot before the roulette wheel is spun, I need to change the bets so that "slot1 -=  25" and another slot gets the bet added. I'm calulating the final results by using something like this:

 

 

if (winningNumber<= 6){

return Number(money) + Number(slot1Bet) - Number(slot2Bet) - Number(slot3Bet) - Number(slot4Bet) - Number(slot5Bet) - Number(slot6Bet);

 

 

Any ideas?

 

Thanks!

 

P.S. sorry for reposting this, but I thought it better to start a new thread since my last question was answered.

  • kglad All-Star 52,264 posts since
    Jul 21, 2002
    Currently Being Moderated
    1. May 13, 2009 1:03 PM (in response to wwscoper)
    Re: updating bets based on _droptarget

    you could define a property of each chip that stores its slot.  when a chip is dropped check its property to see if you need to update a slotbet (ie, the property is defined) and then update its property.

  • kglad All-Star 52,264 posts since
    Jul 21, 2002
    Currently Being Moderated
    3. May 13, 2009 4:31 PM (in response to wwscoper)
    Re: updating bets based on _droptarget

    i would approach this with some fore-planning.  first, i would have each chip have a value property (how much it's worth), in addition to a slot property to indicate which slot the chip is placed on.  (btw, you do not need to intialize chip.slot=undefined.  chip.slot will be undefined unless you explicitly define it which you're not going to do unless it's dropped on a slot).

     

    and each slot1,..,slot36,slot0,slot00 i would add to a parent movieclip (say table) and assign it a property storing its slot number (though this can be derived easily using the slot movieclip's _name property and the flash string methods).

     

    and i would create the initial setup using some parameters to give you more flexibility:

     

    var chipValA:Array=[1,5,25,100];  // chip values

    var chipNumA:Array=[20,20,20,20];  // number of $1, $5, $25, $100 chips.

     

    i would create 1 of each of those chips and assign a linkage id:  chip1_ID,chip5_ID,chip25_ID,chip100_ID

     

    you could then code:

     

    var dep:Number = 0;

    for(var i:Number=0;i<chipNumA.length;i++){

    for(var j:Number=0;j<chipNumA[i];j++){

    var mc:MovieClip = this.attachMovie("chip"+chipValA[i]+"_ID","chip_"+dep,dep++);

    mc.value=chipValA[i];

    // assign _x and _y properties

    mc.startX=mc._x;

    mc.startY=mc._y;

    mc.onPress=function(){

    this.startDrag();

    }

    mc.onRelease=mc.onReleaseOutside=function(){

    for(mc in table){  // loops through all the slots

    if(typeof(table[mc])=="movieclip"&&table[mc]._parent==table){

    if(eval(this._droptarget)== table[mc]){

    if(table[mc].chip==undefined){

    this._x=table[mc]._x;

    this._y=table[mc]._y;

    this.slot=table[mc].slot;

    table[mc].chip=this;

    } else {

    // this slot already has a chip on it.  decide what to do.  replace previously placed chip, add to slot or return this chip to its startX,startY

    }

    } else {

    this._x=this.startX;

    this._y=this.startY;

    }

    }

    }

    }

     

    then when your wheel spins you can loop through all the table children like above (to loop through all the slots), to see which have a chip property.  the chip property references the chip(s) placed on that slot and has(have) a value property so you can determine the amount won.

     

    after each slot's payout is determined, reassign the slot's chip property to undefined.

     

    if a slot can hold multiple chips, make its slot property an array so you can push chips into the array should there be more than one chip placed on a slot.

  • kglad All-Star 52,264 posts since
    Jul 21, 2002
    Currently Being Moderated
    5. May 15, 2009 7:42 AM (in response to wwscoper)
    Re: updating bets based on _droptarget

    you're welcome.

  • Roulette System Player Calculating status... 1 posts since
    Aug 6, 2009

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points