Computer Science Canada Game Help - Using Rand.Int in a Variable |
Author: | sliverofshadows475 [ Sun Dec 21, 2008 12:31 pm ] | ||
Post subject: | Game Help - Using Rand.Int in a Variable | ||
Hey guys, I've got a new problem with my game. Here's the syntax.
The help I need is referring to lines 14-18: FirePercentageAlien1-5. As you see, I have given the values as Rand.Int, allowing for the values to equal anything from 1 to 3. I'm planning on using this as my Firing Percentage for my alien enemies. So, then if the FirePercentageAlien1 = 3, then it shoots. The problem with this is that since it isn't looped, it only generates 1 number. I want it to continously generate numbers, but I've tried putting a loop into the variable, but it doesn't seem to work. When this works properly, every second, I want the alien to have a 33.4% chance of firing a beam. But, with this, the aliens have a 33.4% chance of continuously (sp?) firing a beam, throughout the whole game. Any help would be greatly appreciated. Thanks, -sliverofshadows475 |
Author: | TheGuardian001 [ Sun Dec 21, 2008 12:52 pm ] | ||
Post subject: | Re: Game Help - Using Rand.Int in a Variable | ||
in Lines 14-18, get rid of the Rand.Int calls. Then, right at the start of the loop,
should fix the problem. |
Author: | sliverofshadows475 [ Sun Dec 21, 2008 12:54 pm ] |
Post subject: | Re: Game Help - Using Rand.Int in a Variable |
Thank you very much, it worked exactly as I needed it ![]() |
Author: | syntax_error [ Sun Dec 21, 2008 5:46 pm ] |
Post subject: | RE:Game Help - Using Rand.Int in a Variable |
Just noted some other things you might want to rethink about, you could hold all your images in an array as well and that would be a more cleaner looking code; another thing have all your images in the folder as your turing file so you only have to move the folder to transfer the game to someone else et cetera. |
Author: | S_Grimm [ Sun Dec 21, 2008 6:32 pm ] | ||||
Post subject: | RE:Game Help - Using Rand.Int in a Variable | ||||
Don't Define the path as "C:\Documents\....." use root instead. So if you have the project stored in "C:\Final" have a folder in there called something like "resources", then call the new Pics by
here's a test code using a .gif file.
|