0 Favourites

# Multi-line slot game problem ?

• 4 posts
• Multi-line slot game problem ?

I have a Slot machine with 5 reels and 3 rows.

Each symbol/sprite has a unique variable assigned to it.

The player wins if he/she gets a horizontal line of the same symbols.

I want to add a 'multi line' winning capability..So basically the player wins even if the 5 matching symbols appear on different rows.

(see pic)

<img src="https://dl.dropbox.com/u/22173473/15LINECHECK.png" border="0" />

I know Rex created the 'matcher plugin' but I was wandering if there

was formula to achieve this without using a plugin.

• There are a lot of ways that you could do this. You would be best off implementing whatever method/formula is most intuitive to you, or whatever fits in easiest with your program. But here's how I would do it:

1. Apply the reel variables to a 5x3 array

2. Make a recursive function that takes the variable present at [x,y], and checks whether the same variable is present at [x+1,y] (i.e. the reel square directly to the right). If y>0, then check whether the variable is present at [x+1,y-1] (the reel to the above-right). If y<2, then check whether the variable is present at [x+1,y+1] (the reel to the below-right). If the variable is present in any of these position, then call the same function for that position. If x+1 == 5, then congratulations - you've got a line - do whatever it is that you need and don't call the function again.

3. Call the function for [0,0], [0,1], and [0,2].

If you hate the idea of using recursive functions, then I suppose you can do a similar implementation with one or two for/while loops.

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

Construct 3 users don't see these ads
• SketchyLogic,

Your solution sounds logical, but i,m a bit sketchy when it comes

to using arrays and functions (sorry..bad pun)

Im gonna be cheeky and ask you to look at the capx file I have uploaded

here-

capx

<img src="https://dl.dropbox.com/u/22173473/reelsplash.png" border="0">

and if poss, help me implement the events.

If your too busy...then I understand and maybe somebody else might

have a look.