Computer Science Canada Slot Machine |
Author: | Steel [ Wed Dec 20, 2006 7:26 pm ] |
Post subject: | Slot Machine |
Hey, i gotta make a slot machine game, any ideas on what i should do, and, are you able to put pictures in if statements. Ex if "(picture of 7) then coins:= +20 or sumthing, also are you able to make pictures go randomly for the slot part. Im fairly new at turing and any help will be appreciated. Thx |
Author: | Prince Pwn [ Wed Dec 20, 2006 7:55 pm ] | ||
Post subject: | |||
Here's a small Turing program I made, look at the comments and try to understand it:
For the importing of a picture look here. |
Author: | TokenHerbz [ Wed Dec 20, 2006 8:03 pm ] |
Post subject: | |
i gotta make a slot machine game... So its for school yes? You learn nothing from copy paste code, so i suggest you ignor prince pwn code. Firstly, You can randomizse pictures, and use if's with them. Secondly, i'd suggest you look threw turing walkthrew http://www.compsci.ca/v2/viewtopic.php?t=8808 |
Author: | Steel [ Wed Dec 20, 2006 8:12 pm ] |
Post subject: | |
Thankz |
Author: | Prince Pwn [ Wed Dec 20, 2006 8:19 pm ] |
Post subject: | |
TokenHerbz wrote: You learn nothing from copy paste code, so i suggest you ignor prince pwn code. i learned by copy and pasting code. |
Author: | Steel [ Wed Dec 20, 2006 8:26 pm ] |
Post subject: | |
hmm what does the dot mean in like draw.Fill oval because i know you could also just do drawfilloval. |
Author: | Prince Pwn [ Wed Dec 20, 2006 8:38 pm ] |
Post subject: | |
No major difference. If you navigate your hard drive to your Turing installation folder, "Turing/Support/predefs/" you will find a few Turing files that are all noticeable such as "Dir", "Draw", and "Pic" that are all .tu files. When you use Draw.FillOval, it opens the "Turing/Support/predefs/" and looks inside the Draw.tu file and further executes the code inside that Draw.tu according to what you put inside your (). Saying drawfilloval has the same result, but doesn't look for "Turing/Support/predefs/". |
Author: | ericfourfour [ Wed Dec 20, 2006 9:55 pm ] |
Post subject: | |
Actually Draw. means it is a member of the Draw module. It is loaded on the memory at run time so there is no searching through folders involved. It takes the same speed for each. Draw. is recommended because it is easier to understand and helps you out later on. |
Author: | Hackmaster [ Wed Dec 20, 2006 10:23 pm ] | ||||
Post subject: | |||||
your problems are really easy to solve, and they can probably be done with the help of the Turing Walkthrough, or some other tutorial based on it. but whatever. I'll give you a hand. because you are fairly basic, I will keep it simple. for the random part, all you need to do is make a simple randint statement:
if you've never seen this before, I will tell you what it's about: randint is the command to start it all. "var" is the variable you will be giving the random integer to. 1 and 10 are the limits of the randomization, so, if I put 1, 10, it means I will have a random number from 1-10. easy-peasy, right? then, all you do is have an if statement (or case, whatever you prefer) which puts a certain picture up on the screen depending on what number was rolled, something like this, maybe :
something like that. alright? hope this helped! |
Author: | ericfourfour [ Wed Dec 20, 2006 10:53 pm ] | ||||||
Post subject: | |||||||
Hackmaster wrote: for the random part, all you need to do is make a simple randint statement:
Simple but deadly. Don't use randint. It teaches bad programming practise. Instead use the function (not procedure) Rand.Int.
|
Author: | Hackmaster [ Wed Dec 20, 2006 10:57 pm ] |
Post subject: | |
finickty, finicktey.. jeez... really, it doesn't matter. use what you like. what is the differece between one command and putting a dot there? well, it may teach you about module refrence, but you adapt to that as time goes on. I said this way because he is new, and thus doesn't (in my opinion) need to care about little details like this for now. |
Author: | ericfourfour [ Wed Dec 20, 2006 11:03 pm ] |
Post subject: | |
There is more of a difference between Rand.Int and randint than a dot. Rand.Int is a function returning an integer. randint is a procedure that takes in a variable (the exact location) and assigns the value to it internally. Which one do you have more control over? This has been discussed countless times and the dot is hardly the issue between the two. |
Author: | Clayton [ Wed Dec 20, 2006 11:06 pm ] |
Post subject: | |
The difference between Rand.Int and randint is a lot more than just a dot. Rand.Int is a function, it creates a value, it in no way modifys the program around it unless you specifically tell it to. randint on the other hand is a procedure, a procedure that takes a variable argument and mercilessly changes its value within the procedure. This is generally regarded as bad programming practice and should be avoided at all costs, as you have no idea what's happening to your precious varible within that procedure. |
Author: | Hackmaster [ Wed Dec 20, 2006 11:12 pm ] |
Post subject: | |
I understand that guys... but it isn't really me you are appealing to. the only reason I said to do randint is because that's what they teach in the schools. (in my experience.) I'm just trying to make it simpler... but on second thought... when typing, there isn't much of a difference between randint and Rand.Int. Fine! that's fine... you win... |
Author: | Steel [ Thu Dec 21, 2006 4:00 pm ] |
Post subject: | |
Thanks guys your help is greatly appreciated. When the program is done ill try to post it here, and i think you are both right lol, all i gotta do now is learn how to put the pics in, but i could prob find that in tutorial thx again |