Computer Science Canada Slot machine |
Author: | Amarylis [ Wed Nov 30, 2011 8:33 pm ] |
Post subject: | Slot machine |
Well, er, hello everyone! I'm a new member to compsci.ca ^.^ For my school assignment, I have to create a slot machine program. That's really about the only requirement thus far, the teacher has yet to finish writting the assignment sheet, but I'm sort of already done a version that I could hand in (for a fairly good mark, might I add), and now I figured I would just try to add as many features as I could think of. My only problem now is, I can't think of anything else that I could add, aside from better graphics (which I am working on. I made the background image on Paint, so it's really not that good at all. Problem with being horrible at art is, well, you're horrible at art). I've uploaded the latest version of it, and would love it if anyone could give me some feedback on it's current state, and/or (if people can find it in their hearts to help) give some advice as to what I could change/add to it Oh, and if anyone would like an earlier version of it, I can upload that as well |
Author: | Aange10 [ Wed Nov 30, 2011 11:20 pm ] | ||||||||||||
Post subject: | Re: Slot machine | ||||||||||||
Okay, here are some things I noticed. First and foremost, the slots should be spun all 3 at the same time (as apposed to one at a time). Like slot machines do. Also I would suggest making the white box take up only the space of the icons. Secondly,
All of these procedures could be made into one, and you could just have the picture as a parameter. For instance
Your read balance procedure, the if statements could be easier; It would be simpler to say
instead of having one if for if it is true, and one for if it is false. Your "Draw initial graphics" could be a procedure (Name Intro) When they exit the program, you should delay a second and a half and then close the window. This can be done by instead of saying
to define your screen, you can use
that away you can close the window by saying
Generally, this program is pretty nice. The only thing that REALLY needs to be fixed is it reeling one at a time. The procedures are a bit redundant, but thats an easily change. Might I recommend the icons 'spinning' instead of 'flashing' |
Author: | Amarylis [ Thu Dec 01, 2011 6:45 am ] |
Post subject: | Re: Slot machine |
The procedures really are rather redundant, my teacher just likes seeing them in a program.... Thank you for the input! I think I figured out how to make them flash all three at once (though I'm not entirely sure how I could make them spin... Graphics stuff is not my strong point) |
Author: | Aange10 [ Thu Dec 01, 2011 6:16 pm ] |
Post subject: | RE:Slot machine |
Would you post it? and Quote: The procedures really are rather redundant, my teacher just likes seeing them in a program Having anything redundant is terrible. It slows down the program, makes it harder to read, and more code generally adds unnecessary complexity. Your teacher would be much more impressed to see you having a procedure with a parameter that also doubles to bullet proof it. |
Author: | Amarylis [ Thu Dec 01, 2011 7:03 pm ] |
Post subject: | Re: Slot machine |
I'm not entirely sure how much my teacher actually knows about programming, I sometimes get the feeling she just looks to see if there are procedures (not for the content of them), and if the program runs. Aside from that, and the visual components to the projects (she likes to have "pretty pictures" in the programs), everything is pretty much fair game for what the actual code is, no matter how redundant or unnecessary it is. The general consensus seems to be, the more complex the program, the higher the mark, irrelevant of how needed the complexity actually is. As for the program itself, I'm uploading it now (it should be attached to this post, right? Sorry, new to this forum and not quite sure how these things work in this one ) |
Author: | Aange10 [ Thu Dec 01, 2011 7:08 pm ] |
Post subject: | RE:Slot machine |
Sounds to me like your teacher is terrible. |
Author: | Aange10 [ Thu Dec 01, 2011 7:19 pm ] | ||||
Post subject: | RE:Slot machine | ||||
It wouldn't be terribly difficult to have the flash at different times, it makes it seem less like your being juked. Also
If you ever find yourself with code that is so repetitive, then you should consider for loops, or another means. Think about what your i for loop does... It shows us how many times we drew the item to the screen. So why can't our j : for (for example) keep track of what we're assigning values for? To put it to test
* One with ingenuity would realize the redundancy within the i for (Drawing three times, delaying). If said person had said ingenuity, they could think of an efficient way to fix it. |
Author: | Amarylis [ Thu Dec 01, 2011 8:21 pm ] |
Post subject: | Re: Slot machine |
Okay, so I'm fairly sure I have it now. If anything, it's at least more programmer-friendly, not quite sure about efficency... I made a process for drawing everything with parameters that set it so my first for loop will define how many of the icons will be flashing. Here it is~ |
Author: | Aange10 [ Thu Dec 01, 2011 9:06 pm ] | ||||||
Post subject: | RE:Slot machine | ||||||
Congradulations! Its a lot less redundant! Do remember repetitive thigns often can be fixed with a procedure or a for, in this case
But ingenuity is a big part of this. In my opinion you are doing really well. So don't let a lot of criticism bring you down. Sometimes the criticism turns out to be just suggestions. ... Changing the drawpic to clear everytime seems a bit unneccasary. Keeping it at 0 would be better, it's less the computer has to do; you call it every time you draw something, which is unneccasary. Try adding the 0 parameter back in, and doing it only after delays. You made a whole new procedure that just has an x parameter, and then some if statements telling it how many times to repeat. Instead of the if statements, why don't you use it as it's end result; how many times it repeats.
See how our procedure just went from 37 lines to 5 lines? .... I also suggest you fix your comments going off the screen in windowed mode. It's a more or less general way of commenting, see Turing Walkthrough for a 'how to comment' tutorial. I personally find
to be a nice style of commenting. Line 76, you probably have a typo. If I'm correct your looking for strintok not strrealok. Also I noticed you have a lot of variable declarations and what not towards the bottom of the screen. Can't most of that go at the top, with the other declarations? |
Author: | Amarylis [ Thu Dec 01, 2011 9:57 pm ] |
Post subject: | Re: Slot machine |
Okay, I've simplified the code even further, and don't worry, I take criticism not as a "put down" of sorts, but more of a challange :3 I know that I wont be able to learn anything more through my school, so I decided to post things in here where others who have a much broader knowledge on the subject than I can give their input on my code. As for my clearing the area where I'll draw a new picture every time, it seems necessary thus far, but I think changing the Pic.Draw's picMerge parameter to a picCopy should fix that right up I've fixed the things you've mentioned, and yes, line 76 was a typo that I had forgotten to fix when I changed the balance into an integer as opposed to a real Uploaded 1.2.6.1 |
Author: | Aange10 [ Thu Dec 01, 2011 11:22 pm ] |
Post subject: | RE:Slot machine |
Quote: As for my clearing the area where I'll draw a new picture every time, it seems necessary thus far, but I think changing the Pic.Draw's picMerge parameter to a picCopy should fix that right up
Definitely necessary.. If your drawing the picture back on top of another picture. picMerge isn't the problem. Say If I have a 5x5 grid, and I color a square at 1,1 and another at 2,2 and another at 3,3, I don't need to erase each box before i color it. I only need to erase them if there's something already there. The biggest problem here, is that if there came a time you needed another picture into the procedure, it might make things not work so well. Think about when you need it to clear, and do it there. Instead of hard coding the procedure to do it every time. Other than that, theres a tiny flaw in your program. (And no, I'm not talking about the syntax errors in the procedures(: ) Whats the point of your for i in drawEverything procedure? Toy with that, and see why you don't want it. Also your if choice (z) = 1 then statements are being ran 5 times in the *spin*. Don't you want it to do it once; at the end? |
Author: | Amarylis [ Fri Dec 02, 2011 5:23 am ] |
Post subject: | RE:Slot machine |
oh, crap, I thought I took the choice(z) out of the second for loop |
Author: | evildaddy911 [ Fri Dec 02, 2011 8:37 am ] |
Post subject: | Re: Slot machine |
Quote: I'm not entirely sure how much my teacher actually knows about programming, I sometimes get the feeling she just looks to see if there are procedures (not for the content of them), and if the program runs. Aside from that, and the visual components to the projects (she likes to have "pretty pictures" in the programs), everything is pretty much fair game for what the actual code is, no matter how redundant or unnecessary it is.
yeah, same with my teacher, i asked him how to use numbers with Input.KeyDown, and he said, "I dont know, ive never used it before |
Author: | Amarylis [ Fri Dec 02, 2011 12:53 pm ] |
Post subject: | Re: Slot machine |
Okay, so I'm fairly sure this should hold the script, almost void of all useless crap. |
Author: | Aange10 [ Sat Dec 03, 2011 7:56 pm ] |
Post subject: | RE:Slot machine |
Seems better. Now just time to add features! Yay! |
Author: | Amarylis [ Sun Dec 04, 2011 3:24 pm ] |
Post subject: | RE:Slot machine |
I've been doiong some work on it, I added a high score system, and a charity system (my teacher decided that, to make it a "lesser evil" so to speak, the gambling-based game would have to have an option for the player to donate some of his/her money to charity at the end), as well as encrypted the text files so that it'll be harder for people who dont know what they're doing to cheat (it's just converting the balance integer into a string, really). I've aksi added a way for players to put in how much they want to bet, and changed the winnings from 15x to 7x the amount entered Now I just have to wait for the slow compiler to take a half hour to compile, after that i'll upload it Edit: Compiled! It should be at the end of this post |
Author: | Aange10 [ Sun Dec 04, 2011 3:56 pm ] |
Post subject: | RE:Slot machine |
Shouldn't take that long to compile |
Author: | Aange10 [ Sun Dec 04, 2011 4:16 pm ] |
Post subject: | RE:Slot machine |
As far as game play goes, since there is one row you should definitely win 1.25 on 2 fruit, instead of 1. As far as code goes, your comments are still not good. Try going through and following the algorithm, and make sure the comments DO NOT EXCEED 80 columns. Edit: Try and look at some of the submissions for how code should be organized. I submitted about an hour ago a little game I made earlier, try looking at the format of the code. Though if you need help on something, the comments should be a bit more thorough. |
Author: | Amarylis [ Sun Dec 04, 2011 4:50 pm ] |
Post subject: | RE:Slot machine |
I like the 1x on two fruits as opposed to 1.25, it's supposed to be hard to win. Sorry, but I'm going to decline that suggestion (I'm making a new version with 3x3 grid soon) For the commends, i'll lower them down to column 80. On my screen, they didn't go over because I'm always using the full screen code editor |