Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Programing a Roulette wheel?

Jazeeri

Villager
Xy$
0.00
Has anyone ever programed a roulette wheel/pseudo roulette wheel event or know of a tutorial I could view?
I know there is name input with numbers, which would be nice but not really necessary for a pseudo event, but if anyone had any ideas how to construct something like this, I would appreciate it!

It's meant to be a mini game and needs only be fun not exact.
 
Last edited:

Essy

Towns Guard
Xy$
0.00
Depends on how complex you want it. The idea should be pretty simple.
We have a wheel with N slots and an image also with N slots.
We can initialize the position at a spot M and continuously make the following transformation for each 'sub-roation' of the wheel.
M = (M+1) mod N
If we were to use a game variable..
Code:
$gameVariables.setValue(id_to_set,
($gameVariables.value(id_to_set) + 1) % number_of_slots)
At the same time as the transformation rotate the wheel
Code:
$gameScreen.picture(picture_id).rotate(rotation_amount);
The rotation amount will depend on the wheel itself, so you should play around with that.
This should make atleast a basic roulette wheel. You can just match the variable id against conditional branches to know which one it hit. You can gain effect in wheel rotation speed by varying the time between each transformation.

I'm afraid I haven't gotten into javascript just yet so I can't make a plug and play style script for it yet, but this should be more than enough to event it I'd think.
Another useful call for varying time would be..
Code:
$gameInterpreter.wait($gameVariables.value(gameVariableID));
This way you could simply tie the rotation steps into a game variable.(The smaller the value the quicker it would rotate.)
 

Jazeeri

Villager
Xy$
0.00
The rotation of the picture I understand --not sure how to allow player input. I was really thinking of something simpler (I am still learning all of this). This might be a bit difficult for me yet :) Thanks for your input!
 

Essy

Towns Guard
Xy$
0.00
Events:
http://oi68.tinypic.com/35hn5t1.jpg
http://oi64.tinypic.com/11c4eft.jpg
In Action:
http://oi65.tinypic.com/6xzsox.jpg
After holding Enter (OK button)
http://oi64.tinypic.com/23m2e6f.jpg

So after interacting with an NPC A
we can start up the event.
The event begins spinning the wheel rotating and keeping track of the position through that formula earlier.
After the player presses and holds enter, we set a switch, and it begins to slow down.(Using the code snippit sequence from earlier we can just add 1 to the variable at each interval.)
Once it has slowed down sufficiently(the variable is at a sufficiently high value) we use another switch and kill the rotation entirely. At this point you could do whatever you want before passing it back to NPC A.
 
Top