first, Im making a game, and i want to do like shoots, that u need to load, and if u dont got shoots u cant shoot. ive allready maked the variable shoots. so i want to know how to do that if the shoots variable is not 0 u can shoot. oh and the shoot is the custume2 of the sprite of the man.
2. if i do pick random 1 to 2, can i control the chances of what the computer will choose? for exemple: 70% that it choose 1 and 30% that is choose 2..
Hope u understand.
Thanks.
Offline
neilsomthing wrote:
first, Im making a game, and i want to do like shoots, that u need to load, and if u dont got shoots u cant shoot. ive allready maked the variable shoots. so i want to know how to do that if the shoots variable is not 0 u can shoot. oh and the shoot is the custume2 of the sprite of the man.
2. if i do pick random 1 to 2, can i control the chances of what the computer will choose? for exemple: 70% that it choose 1 and 30% that is choose 2..
Hope u understand.
Thanks.
1. You are going to need to test on the shoots variable and do things based on the value so you are going to have to use the 'IF block' or the 'IF Then Else block'
[blocks]
<if> <( <{ shoots }> <>> 0 )>
<broadcast[ Fire a Bullet ]and wait c>
<else>
<say[ Darn...out of bullets!
<end>
[/blocks]
2. To set up a 70%/30% probability, use something like this:
[blocks]
<if><( <pick random( 1 )to( 10 <>> 3 )>
do the 70% stuff
<else>
do the 30% stuff
<end>
Hope that helps.
Offline
UMMM.. i didnt understand the the seceond thing. can u explain me without the blocks?
Offline
I can try. You want something to happen randomly but 70% of the time. The computer only generates random numbers evenly...but if we ask it to pick a number between 1 and 10 there is a 70% chance that the number it picks will be greater than 3.
Looking at it another way, It might come up with
any of these number: 1,2,3 (3 chances out of 10 = 30%)
or it might come up with
4,5,6,7,8,9,10 (7 chances out of 10 = 70%)
so if we let it pick a number between 1 and 10 and then check to see if the number it picked is greater than 3 (the second group), it will be true 70% of the time. And, of course, false 30% of the time.
I hope that makes it a bit clearer.
Offline
Paddle2See wrote:
I can try. You want something to happen randomly but 70% of the time. The computer only generates random numbers evenly...but if we ask it to pick a number between 1 and 10 there is a 70% chance that the number it picks will be greater than 3.
Looking at it another way, It might come up with
any of these number: 1,2,3 (3 chances out of 10 = 30%)
or it might come up with
4,5,6,7,8,9,10 (7 chances out of 10 = 70%)
so if we let it pick a number between 1 and 10 and then check to see if the number it picked is greater than 3 (the second group), it will be true 70% of the time. And, of course, false 30% of the time.
I hope that makes it a bit clearer.
And you could do:
set variable to pick random 1-10.
If variable > 3
set variable to the number you want.
Therefore, if the variable is greater than three (which 70% of the time it is) it will become the number you want!
Offline