Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

How to make a spin effect

Ok, i'm making a slot machine in programming class and we have a couple days left and im done so im going to add a couple feature like a spin effect

I was going to have the different picture keep popping up for a little

this is what a tried, it doesnt work idk why and I know its probably the most retarded way possible but its the only way I can think of

[Image: 03d5f4972f9e8b1e6dcfe2ed496d1ec9.png]

I know its aids, hopefully you can tell what im trying to do by that pic. Can anyone help me do this


Can anyone help with this, I just need a spinning effect with my picture boxes
You should really use a switch statement. And what type of spin effect do you want, a 2D one. a 2.5D one or 3D one?
(Jan 8, 2015 06:16 PM)+Haze Wrote:  You should really use a switch statement. And what type of spin effect do you want, a 2D one. a 2.5D one or 3D one?

A switch is unnecessary on an image, especially since he'd have to override the equals and hashcode methods of them just to do this. Besides, if-then-else conditionals are sometimes better to use in some places, whereas swtiches are better in others (this not being one). And if you look at his code, he's just trying to change an image based on what the current one is every tick, so it's obviously a 2D rotation.

OP: if you really want to reuse your code, setup a system to call that function every tick (windows forms are event driven, so not the best idea, but still). Otherwise I'd suggest creating a new form object and adding in the animations there.
(Jan 8, 2015 07:18 PM)mienkrsftajz Wrote:  A switch is unnecessary on an image

I'm talking about his bunch of if statements. Not the image -__-
(Jan 8, 2015 07:19 PM)+Haze Wrote:  I'm talking about his bunch of if statements. Not the image -__-

I am too. He'd have to use the Image as the object reference for the Switch - which leads back to my other statements. Unless he wrapped them in a parent class and assigned them a numerical ID or something. In either case, refer to my previous post.
The code looks pretty bad but should work i guess, make sure you have your timer enabled. (tmrSpin.Enabled = true)
If you would like to troll your teacher i suggest to do this in WPF with a storyboard. >:D

[Image: D12KBT6.png]
It would not be hard to implement a switch into this at all, and it would clean up the code. In fact, you could easily make the code for the tick just a few lines.
(Jan 8, 2015 07:18 PM)mienkrsftajz Wrote:  A switch is unnecessary on an image, especially since he'd have to override the equals and hashcode methods of them just to do this. Besides, if-then-else conditionals are sometimes better to use in some places, whereas swtiches are better in others (this not being one). And if you look at his code, he's just trying to change an image based on what the current one is every tick, so it's obviously a 2D rotation.

OP: if you really want to reuse your code, setup a system to call that function every tick (windows forms are event driven, so not the best idea, but still). Otherwise I'd suggest creating a new form object and adding in the animations there.

I just typed out a long post then randomly got messed up. Thanks hackforums. Anyway, creating a private int that you would increment on a switch would be much faster than anything you suggested. You only looked at face values. Program for programmer first, compiler second, blah blah not retyping it all.
(Jan 9, 2015 09:43 AM)Corios Wrote:  I just typed out a long post then randomly got messed up. Thanks hackforums. Anyway, creating a private int that you would increment on a switch would be much faster than anything you suggested. You only looked at face values. Program for programmer first, compiler second, blah blah not retyping it all.

I also suggested that in my second post. Also, it wouldn't be any easier; if you think overriding methods is hard, then there is an issue.
How about making the images into a gif? Just a thought.
get all your images in pictureboxes and just bringtofront(). Also, you might need to leave this in method on your form and use if(invoke required) or at least set Illegal crossthread checking off(will give you errors every now or than, but it's usefull to see if this is the issue
I coded it so you could however many images without needing to change the code, and could add however many PictureBoxes. Adding more PictureBoxes you would need to come up with a better timing system, because you want the the leftmost PictureBox(es) to stop spinning first, then moving to the rightmost. I went with making the intervals random for how long the slot spins, but if you change it to a fixed time it would be easy to add more PictureBoxes.

[Image: ntHM3Qf.gif]


Code: http://pastebin.com/raw.php?i=eunUP2WW

To do a check if they won, for my setup all you have to do is see if all objects in currentImages are the same value (all integers are the same). This would mean all the images in the slots are the same.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by MаestroFeb 2, 2017 06:03 AM 1 157 Feb 2, 2017 06:03 AM
Last Post: hfTP54
[.NET] by SubGeniusMar 30, 2015 11:01 AM 21 1,375 Mar 30, 2015 11:01 AM
Last Post: juliando
[.NET] by Mr FoxFeb 6, 2015 11:33 PM 2 159 Feb 6, 2015 11:33 PM
Last Post: Mr Fox