Slot spinner picks objects from list

0 favourites
  • 12 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi guys, I've looked at all the slot machine and number generator threads (in particular the "Generating Random Numbers Without Duplicates" tute) but can't figure out a way to do the following:

    I'm trying to make a lottery/slot machine that picks a winner from a list every spin (then deletes itself from the list), until eventually every object in the list has come up only once and it's "empty" at the end.

    I've managed this as a simple random number generator but, that doesn't help the slot machine, which needs to visually 'spin' through each object's sprite, slowly coming to a stop on the winner for that spin. Only objects still in the list should appear on the spinner. The final spin would be just 1 sprite spinning around I guess.

    Any ideas? Cheers guys.

  • I'd check out R0J0Hound's example in this thread:

    http://www.scirra.com/forum/your-c2-tests_topic41840_post258214.html#258214

  • Yeah, I had a look at that example as well. All of his fruit are in 1 sprite strip though, so I can't remove any of them once they come up (say the cherrys for example). The sprites are baked into that ticker tape strip.

    That's why I was thinking to have the sprites each separate in a list and called somewhere, so they can be left out after coming up?

  • I posted a couple of slot machine examples quite a bit back...here's the link-

    Forum link

    Here's another example I didn't post (uses seperate sprites for reels)

    Link

    Good luck.

  • Heya Chrisbrobs,

    Cheers for the ideas. Yeah I originally had a long look at that thread of yours and tried the animation frame idea. I'm having a look at the capx you just posted as well while revisiting that thread. So here comes stupid question. :D

    Where are your sprites for when the reel has stopped? As in, I see oranges and cherrys in browser when running it, but I can't find them 'anywhere' in the capx. I've even looked inside every sprite's animation frames as well. -_-

    On the note of using animation frames, is there a way to delete or 'skip' animation frames during runtime? I thought of removing each frame as it came up, 1-by-1, so they wouldn't show up on subsequent spins, until eventually there'd just be the 1 last frame left spinning and inevitably win?

  • Hi,

    Question1:

    Where are your sprites for when the reel has stopped? As in, I see oranges and cherrys in browser when running it, but I can't find them 'anywhere' in the capx. I've even looked inside every sprite's animation frames as well.

    Check the sprite object 'reel 1'...the second animation called 'stop'.

    Question2:

    On the note of using animation frames, is there a way to delete or 'skip' animation frames during runtime? I thought of removing each frame as it came up, 1-by-1, so they wouldn't show up on subsequent spins, until eventually there'd just be the 1 last frame left spinning and inevitably win?

    Have you got a illustration or image (or even a basic capx) that I could look at ?

  • Oh wow.. the "Animations" window position defaulted to behind the "Edit Image" window so I never saw it. Well that explains multiple animations per sprite then. ^^; Cheers.

    My current capx is a mess of 3 different approaches. :(

    I'm not necessarily set on the idea of using the animation frames to achieve the result. It only crossed my mind after seeing how you did your slot machine on that older thread.

    I would prefer to just store all my lotto numbers in an array, then associate a sprite with each number to display. As a number comes up, I could move it to the back of the array (or delete it?), then re-draw from the leftover numbers until eventually only 1 number is left in the pot.

    The animation frame example seemed easier to get the 'slowly coming to a stop on a number' effect by slowing the animation down with: self.AnimationSpeed - ((10*self.AnimationSpeed/100) * dt)

    or whatever. But I could never figure how to ignore/delete a frame once it had come up, which made me think to store a list of the lotto numbers in an array and just associate each one with it's respective sprite.

    The original "Random Unique Number Generator" tutorial I saw does this perfectly, but doesn't give any of the visual excitement of "coming to a rest" on the winning number each time. It just instantly spits out the unique number.

    So I'm torn between these two methods atm. :( Unless there is (quite likely) a better way to achieve a lotto machine that I'm not thinking of. Cheers for the advice guys.

  • L4T3NCY@

    The original "Random Unique Number Generator" tutorial I saw does this perfectly, but doesn't give any of the visual excitement of "coming to a rest" on the winning number each time. It just instantly spits out the unique number.

    Why dont you just use the above tutorial as a base..and just add some graphics?

    Here's a simple example:

    <img src="http://dl.dropbox.com/u/22173473/randomnsplash.jpg" border="0">

    Play

    Download Capx

    (Credits to kittiewan for the tutorial)

  • Hi everyone,

    So the slot/lotto machine ended up going well at the End-of-Year Company party. Staff won prizes and merriment was enjoyed by all!

    There was no other examples of what I wanted here yet (chrisbrobs thatnks for trying!) so, I'm posting the full capx for anyone to use at their own party if they want. ^.^ Have tried to comment the capx everywhere as much as possible.

    docs.google.com/open

    DISCLAIMER: This is SUPER hacky.. but it got the job done. With only a few hours on weeknights and weekends to do this, it didn't need to be pretty code-wise, just work. I've since removed all the photos of people/prizes and the propriety art, so the capx just has my orsum stick drawings in it now as replacements. It's enough for you to get the idea though. The random number generation uses kittiewan's "Generating Random Numbers Without Duplicates" tutorial (which is solid!).

    Notes:

    -The slot spinning effect is purely for show. Even if a person/prize has come up before, they will show up in the spinner as it is only animating the sprite for show. I wanted to find a way to remove staff/prizes as we went along eventually whittling the staff/prize lists down but, ran out of time. This got the job done.

    -There are actually 2 random generators for the prizes. The first one occludes the last few frames of the prize sprite (which contained the Grand Prizes). After a certain number of spins, I stop using the 1st generator with the limit, and switch to the no-limits generator allowing for the possibility of a Grand Prize coming up. This way you guarantee a Grand Prize will come up somewhere towards the end and not on the 1st damn spin.

    -To increase/decrease the number of staff/prizes just play with the Global Variables at the top. I didn't get time to cleanly rig everything up to be pointing at just 1 place though, so you'll need to hand adjust the "countdown" global here & there as well to match your number of prizes.

    -Having the keyboard not accept inputs until spinning has ended was critical! After a few drinks, people will just hammer that Spacebar if they're gonna win stuff so, it needed to be robust. :D

    If anyone has any questions (or suggestions on cleaner ways to achieve these results!) feel free to comment. ^^/

  • chrisbrobs@

    Can you upload your capx again please?

    I am trying study to make a slot machin game .

    but, there is no concept of how to get started.

    Thank you

  • chrisbrobs

    I second ffffff, the capx and examples are offline. Might need a reupload..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try asking people or admins on http://spin-slot.com/ if u r realy interested

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)