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.
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.
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.
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.
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.
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.
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.
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 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.
Frame 1 - Cherry
Frame 2 - Bar
Frame 3 - Red 7
So to spin the images i have the following bits of code. (this is purely for Reel 1 only)
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.