Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Simple Multi-Purpose Wheel

Here's a really simple, but still pretty cool event system that could have any number of uses. I'm just going to make a wheel, make it spin, stop it with a the 'down' key, and set an 'accuracy' variable accordingly. This can have any number of uses, but for the sake of demonstration it's a 'accuracy meter' today. If you're a beginner, you might learn something. If you're not, maybe you'll still find this useful somehow. =D

First I'm going to load this generic, 3 second MS paint graphic into the 'pictures' resource bank.

http://img524.imageshack.us/img524/2953/circlewa8.png[/img]

Feel free to make your own that doesn't suck.

http://img230.imageshack.us/img230/8403/event1pj4.png[/img]

ok first, i'm just going to create an event to draw the 'wheel' picture, and set a variable called 'circle +10' to = 0 ; then turn on a switch that will switch the event to the second page.

http://img524.imageshack.us/img524/6963/event2xx7.png[/img]

Okay, now just remember to make sure to set the 'condition' switch of this page to the switch you turned-on on the first page. (The whole 2-page thing actually is unnecessary, but this is just the way I did it. it could have been done more efficiently on one page.)

Okay, now i created a conditional branch to see if a switch called 'circle b' was turned off, and if it was off it was to show a text message, and then turn the switch on. This is because i wanted the event to loop without repeating a message that would show before the wheel moved. (these seemingly useless messages WHERE relevant messages for something i'm working on, but i removed them for the sake of tutorial)

Okay, so now i create a conditional branch for if 'circle b' is turned on. Make sure all of the following is inside the 'true' half of this branch.

Now i want to add +10 to the 'circle +10' variable that i created on the last page. This is because we will be rotating the circle 10 degrees on each frame.
So set the variable to add +10, and set the circle graphic to rotate +10.
Now I add a 1 frame 'wait'. This is because the graphic didn't seem to want to rotate without that 1-frame wait.

Now I want to check if a key (i set the 'down key') is being pressed. If it IS, we want to stop the wheel, and tell the user how good his/her timing was. So we change the rotation speed of the wheel to '0', which will stop it from rotating.

Now, I want to show the user how close the wheel is from pointing straight up, which would be 360 degrees.. but that's not going to tell him/her how accurate his attack is going to be (360% isn't very realistic of a percentage, right?), so i want to copy the value of the 'circle +10' variable to another variable called 'accuracy', then I want to divide the 'accuracy' variable by 4 to come up with a reasonable accuracy percentage that I could use for whatever purpose (my example is an attack, but it could really be anything). Of course this makes the max accuracy 90%, but we gotta gave SOME bit of chance in there, right?

Now, the reason I didn't just divide the 'circle +10' variable, and use that for the accuracy, is because I want this event to loop, and if I divided the 'circle +10' variable, it would mess up the numbers of the next calculation by changing the variable from 360 to 90, and the 'circle +10' variable would no longer be in sync with the actual angle that the wheel is pointing at.

Last, but not least, I want to make sure the wheel sets back to 0 after it hits 360. Make sure this is AFTER the 'key press' branch, otherwise it can mess up the player's score and turn a perfect 360 into a 0. Okay, so I just want to check if the 'circle +10' variable is equal to, or greater than 360, and set it to 0 if it is.

http://img524.imageshack.us/img524/3246 ... eeldp7.png[/img]

Now I have a variable that I can further use as a determiner for how likely something will be (I won't get into how to go about doing that in this tutorial), while adding a bit of interactivity!


Of coruse you could replace the +10 increment with a different number (On both the wheel rotation, and the variable increase), but remember that the more accurate your wheel is (less of an increment would allow for a larger array of numbers), the slower it's going to move (with this method, anyway), because that's more frames it has to go through per rotation.

If I somehow missed explaining something, just look at the screenshots. I'm sure someone can use this for something.. maybe go wheel of fortune and turn it into a prize wheel, maybe something more creative?

(BTW I apologize for the somewhat sloppy eventing, it could have been much simpler. I was just kinda messing around, and thought it was kinda cool, so I wanted to share it.)
 
I actually really like this. I've done similar things before (and am using something like that in Sandfall) but never in the form of a spinning circle. Good idea.
 

Zeriab

Sponsor

What a lovely event. I like it :D
Just a little thing. If you increment the variable with a number that does not go up into 360 you might get more than 360 degrees and an accuracy higher than 90%.

*hugs*
- Zeriab
 
It really is very well organized and very creative, I give you congratulations on your creativity, even this is easy, I never would have imagined to do this because I am not very creative hehehe.

Congratulations my friend!
 
mmm how could you control the rotation? mmm, maybe that was too easy... ok, how could you make it spin by pressing a button several times?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top