The Daily Click ::. Forums ::. Klik Coding Help ::. Slot Machine
 

Post Reply  Post Oekaki 
 

Posted By Message

Michael DeAngelo



Registered
  11/04/2012 17:20:32
Points
  22
13th June, 2012 at 13/06/2012 20:35:09 -

Hey everyone!

I've been conceptualizing a game for a few days now, but I can't seem to get my mind wrapped around how I would get it to work in MMF2.

What I want is a basic slot machine, but wherever I've looked for examples, I've been stuck. I found the application that was on MMF2 bonus CD, but that only shows the Slot Machine game itself, none of the MMF2 coding. I assume the payline schedule is as simple as background coding. It's randomizing the reels that I can't wrap my head around. I figure what I could do is have the reels already created, and just start it at a random point as it starts falling. Then a collision check once the reels stop spinning could determine the payout.

If anyone has any advice, or, better yet, an example that they could provide, I'd really appreciate it.

Thanks so much!

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
13th June, 2012 at 13/06/2012 20:54:52 -

Hmm...Maybe this is an example I can come up with. Unfortunately I'm not at my MMF2 computer right now (I'm on break at the day job). Here's a quick-and-dirty explanation...

What I recommend you do is have animations set on three Active Objects as slot machine tumblers. Have a different animation frame set up for each result.

When the player pulls the lever/presses the space bar/inserts a coin etc. then the tumblers start spinning. To indicate this, set a flag ON for each of the tumblers:


IF Player Presses SPACEBAR
AND IF Tumbler's Alterable Value A = 0
THEN Tumbler 1 set Flag 0 ON
AND Tumber 2 set Flag 0 ON
AND Tumber 3 set Flag 0 ON



While the tumblers are spinning, make a random animation frame appear. Meanwhile, a counter will steadily add up for each counter:


IF Tumbler Flag 0 is ON
THEN add 1 to Tumbler's Alterable Value A
AND set Tumbler's Animation Frame to Random(x) [where "x" is the number of animation frames for the Tumbler]



When the timer reaches its limit, the tumblers will stop, and the player can press the spacebar again to start the process over again:


IF Tumbler Flag 0 is ON
AND IF Tumbler's Alterable Value A =/> 50 (or whatever)
THEN Set Tumbler's Flag 0 to OFF
AND Set Tumbler's Alterable Value A to 0



 
n/a

Michael DeAngelo



Registered
  11/04/2012 17:20:32
Points
  22
14th June, 2012 at 14/06/2012 13:27:37 -

This will be great to experiment with for sure. Your instructions are very simple and easy to follow as well. Thanks!

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
14th June, 2012 at 14/06/2012 16:39:12 -

I think the only snag you'll find is something to do with the animation frames; they're set to be Base 0 (starting with "0" instead of "1"), but then again I am fairly sure Alterable Values are as well. Just keep aware of it, and you ought to do fine.

 
n/a

Michael DeAngelo



Registered
  11/04/2012 17:20:32
Points
  22
14th June, 2012 at 14/06/2012 17:06:29 -

It worked pretty much right away, and that's a great first foray into this idea. What I'm thinking about trying going forward is designing five reels in their entirety, and then determining what values are in the 4 lines by looking at the position of the reel itself. Once it reaches a certain threshold, a duplicate of the reel would be created, and start from the top again. The only thing I have to make sure of is that it is a tight fit. It's probably more events than I'd prefer, but it'll make the reel system look a little classier. Good news is, most of the code that you provided should, in theory, still fit.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
14th June, 2012 at 14/06/2012 22:13:31 -

Once I've a moment to spare, I'd like to put together an example of different slot machine mechanisms, and how to set up betting, payouts, and so on. If you can share the Event List you come up with this, it could be a great base to build on.

 
n/a

Michael DeAngelo



Registered
  11/04/2012 17:20:32
Points
  22
15th June, 2012 at 15/06/2012 14:03:15 -

I need to get much better at this first . I don't even have something cognizant so far. Just testing the pieces to see what I can do.

This all stemmed from a slot machine I played in AC this last week. My MMF2 coding skills are messy at best for now, but I'm trying. I'll try and get together some cash for someone to tutor me.

 
n/a

Michael DeAngelo



Registered
  11/04/2012 17:20:32
Points
  22
19th June, 2012 at 19/06/2012 16:41:54 -

I tried my hand at this for a few days now. It was ridiculously messy. When the reel would cycle back to the top, it would make a mess of the one that was leaving the bottom (in theory, they should have met exactly). After 100 or so events that are beginning to cancel each other out, I'm going to throw in the towel with this trial run.

I know what I want to do, but getting it to work is absolute carnage. My biggest disadvantage is that I'm probably just making it too complicated for myself.

This is basically what I want the end result to be for the slot mechanics: http://www.youtube.com/watch?v=9s5zSIoEruU

If anyone has any advice for how to do something of that style, I'd be interested in listening.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
20th June, 2012 at 20/06/2012 12:46:13 -

Michael: I now see what you mean by having the images return back to the top of the "reel." I hadn't been working in that direction, but I may be able to. From first glance however, I don't think the example I posted above would be workable for that effect. I do want to pursue this myself, as I'm curious as to how it can work.

I finally had a chance to fiddle around with a basic slot machine setup myself yesterday, and there were some notable changes I'd made from my original post so it could actually work.

For one thing, attempting to force animation frames manually didn't work for me at all. It didn't seem like animation frames could be linked up with changing states of Flags. I ended up creating three counters - one for each tumbler of the slot machine - and then forced the tumbler to match up with the value of the corresponding Counter.

With that method, I was easily able to set it up so that the tumblers could stop all at the same time, or each at different times. This creates a conventional "1, 2, 3" sequence of tumblers rolling, and then stopping.

In the coming days/weeks I'll pick away at this and see if I can come up with some sort of reel effect, and display the graphics like you're seeking, Michael. It'll be an interesting project and I have an idea or two already that might work just fine.

 
n/a

Michael DeAngelo



Registered
  11/04/2012 17:20:32
Points
  22
20th June, 2012 at 20/06/2012 14:08:19 -

That's wonderful! I decided to pick up the thrown towel as well, and keep looking into it also. It's still going to be messy, and overly robust, but for now, I'm just testing things. Once I have something worth looking at, I may post it for others. I know there is an easier way to do this, for sure. Right now, I just want to prove to myself that, even if it's not pretty, it is possible.

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
21st June, 2012 at 21/06/2012 09:48:58 -

I have just started work on a Slot Machine game for the Funtition and have designed a three reel single win line machine.

The reels consist of three active objects each. They are laid out like this:

Reel 1 Top
Reel 1
Reel 1 Bottom

Reel 1 has an Alterable Value called Reel Image and this is used to choose from the reel images available. The images have been placed in the Stopped animation and are individual frames for the animation.

For example:
Frame 1 - Cherry
Frame 2 - Bar
Frame 3 - Red 7

etc...

So to spin the images i have the following bits of code. (this is purely for Reel 1 only)


Always

Force Animation Frame of Reel 1 Top to Reel Image of Reel 1 + 1
Force Animation Frame of Reel 1 to Reel Image of Reel 1
Force Animation Frame of Reel 1 Bottom to Reel Image of Reel 1 - 1



The above code means that the top and bottom parts of the reel will display the previous and next parts of the reel.

The next part of code handles if the images are at the limits of the reel. i.e the first and last image



Reel image of Reel 1 = 0

Force Animation Frame of Reel Bottom to 14

Reel image of Reel 1 = 14

Force Animation Frame of Reel 1 Top to 0



I then use 3 individual counters to designate how much spin time is allocated to each reel and this is done whern the spin button is pressed.



Spin is pressed

Set Reel 1 counter to Random(24)+10 - This ensures that the first reel will spin through at least 10 frames
Set Reel 2 counter to Reel 1 counter + 6
Set Reel 3 Counter to Reel 1 counter + 12



The staggering in the code ensures that reel 1 stops then reel 2 and then reel 3

The next bit of code controls the spin itself.



Reel 1 counter < 0
Add 1 to Reel Image of Reel 1
Subtract 1 from Reel 1 counter



To make sure that the images flow properly i have added the following little bit of code into it to stop white space being displayed:



Reel image of reel 1 = 15
Set Reel image to 0



This makes for a very smooth animation albeit very quick.

Edited by lembi2001

 
n/a

Michael DeAngelo



Registered
  11/04/2012 17:20:32
Points
  22
21st June, 2012 at 21/06/2012 16:17:41 -

I don't have access to MMF2 at the moment, but this looks very good. I can't wait to plug it in and give it a go. Thanks for posting!

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
21st June, 2012 at 21/06/2012 17:21:03 -


Originally Posted by lembi2001
I have just started work on a Slot Machine game for the Funtition a...



Looking forward to seeing it, man.

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
21st June, 2012 at 21/06/2012 19:05:15 -

I have taken all the code relevant to my game out to leave you with just the basics of a three reel fruity!

https://sites.google.com/site/mmf2projectstuff/Home/fruit%20example.mfa?attredirects=0&d=1

There is probably a much cleaner way of doing it but it's version 1 so we'll see how it goes.

I want eventually to make a modular version of this engine.
I don't know if it is going to be possible though with all the different reel images you could do but we'll see.

Once i have got 3 reels down solid i might progress to 3 reel 5 winlines and then 5 reels and god knows how many win lines and wild symbols and allsorts of other things

 
n/a

Michael DeAngelo



Registered
  11/04/2012 17:20:32
Points
  22
21st June, 2012 at 21/06/2012 21:56:00 -

I wish I had half the talent that some of you guys seem to have in your little fingers alone. I've got so much creative juice flowing, but hardly the raw ability.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click