![]() |
|
[C#] How to make a spin effect - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] How to make a spin effect (/showthread.php?tid=4626943) |
How to make a spin effect - Jack_Soff - Jan 8, 2015 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 ![]() 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 * - +Haze - Jan 8, 2015 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? * - mienkrsftajz - Jan 8, 2015 (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. * - +Haze - Jan 8, 2015 (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 -__- * - mienkrsftajz - Jan 8, 2015 (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. * - Snoweyes - Jan 9, 2015 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 * - TyrantKingBen - Jan 9, 2015 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. * - Corios - Jan 9, 2015 (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. 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. * - mienkrsftajz - Jan 9, 2015 (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. * - Odus - Jan 9, 2015 How about making the images into a gif? Just a thought. * - CRclaner - Jan 9, 2015 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 * - TyrantKingBen - Jan 9, 2015 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. ![]() 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. |