/    Sign up×
Community /Pin to ProfileBookmark

Slot machine rules

Hello readers

I have made a slot machine for my game project. When a player clicks on the spin button, the reel flicks through random images. When it stops at an image it should give the player a rule to how the game is being played.

The rules are:
1. pick a card
2. pick 2 cards
3. reverse direction
4. miss a go
5. steal a card
6. return a card

would anyone have an idea how this could be done? Maybe if you know some code that might help I would really appreciated it.

Thanks

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@misfitplanetApr 21.2011 — I could get you started, but you'll have to be more specific on the rules, unless there are some gamlers here that know better than I do, but anyway, I start it like this:

[CODE]function Cylinder()
{// This is a cycliner, that round thing that spins with all the 7's on it or Apples or Boobs or whatever
this.cylinders = [div1, div2, div3, etc.] //an array of divs that contain background images
this.position = position; the index to the div the cylider points to, in other wors the image it lands on, hopefully triple 7's
}

function Slot()
{// here is your slot machine, add the methods for your rules here
this.cylinders - [] // the array that cylider objects go into, maybe your slot has three maybe five, who knows?

this.spin = _spin; //method
this.randomNumber = _random; /method
}

function _random(number)
{
//return a number between zero and number
}

function _spin()
{// returns an array of the new positiosn of the cylinders
var i;
var cylinderPositions = []
for(i=0;i<this.cylinders.length;i++)
{
cylinderPositions = cylinderPositions.concat(this.random(this.cylinders[0].length))
}
return cylinderPositions
}}[/CODE]
Copy linkTweet thisAlerts:
@mickster69authorApr 21.2011 — The rules for the game is

  • 1. pick a card - will ask the player to pick 1 card from the next player


  • 2. pick 2 cards - will ask the player to pick 2 cards from the next player


  • 3. reverse direction - will make the game go the opposite direction


  • 4. miss a go - a player will miss a turn and will jump straight to the next player (e.g from player 1 to 3)


  • 5. steal a card - a player will get a pop up menu asking them to select a player to steal a card from and then pick a card from that player


  • 6. return a card - a player will return a certain card to the player they picked from when they receive it


  • hope this makes the rules a bit clearer
    Copy linkTweet thisAlerts:
    @misfitplanetApr 21.2011 — Ok, at the casino the slot machines have three cyclinders or 5. I'm takign it that you will only need one, Right? And on each cyclinder as it spins a rule will come up?

    Is this what you mean?
    Copy linkTweet thisAlerts:
    @mickster69authorApr 21.2011 — Yeah kinda like that. It's just one cylinder that spins and it will stop at only one of them rules and then the player will have to do whichever one it stops at.
    Copy linkTweet thisAlerts:
    @misfitplanetApr 21.2011 — I could help you with the data part of the set up, but I haven't ventured into animation in javascript. But, jquery looks like the nice way to go if you choose that direction.

    Although, jquery does require specific set up that I could not help you with fi tht is the way you go.

    Do you want to do animation? If so, you may want to get start with some one else. If you just want simple images to appear when a button is pressed, I could help you with that.
    Copy linkTweet thisAlerts:
    @mickster69authorApr 21.2011 — yeah animation would be the next step I need to do. The images and button works fine. Just need to get the rules to apply so that the game will be completed.
    Copy linkTweet thisAlerts:
    @misfitplanetApr 21.2011 — Does this look nice enough of an exampel of image animation?

    http://themeforest.s3.amazonaws.com/22_jQueryForBeginners/jquery_11/index.html

    If so, and you are on a deadline I think you can conquer all these excellent video tutorials in a day or two.

    Here the site if you think this may get the results you are looking for:

    http://blog.themeforest.net/screencasts/jquery-for-absolute-beginners-video-series/

    I'd already wold have already went through it (only went oto 5 not knowing any javascript so I was confused) but, I'm doing a bare bones version of my site first, no fancy-shmancy for me untill I get it all perfect underneath. Then, I'm going to put the icing on the cake later.
    Copy linkTweet thisAlerts:
    @mickster69authorApr 22.2011 — Thanks for your help. I will have a look at this. For now I must get a little bit of the dissertation started as it's the most important thing needed done. 50 pages of writing (fun times. lol)
    ×

    Success!

    Help @mickster69 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.6,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...