I need help on randomizing variables 
Author Message
 I need help on randomizing variables

alright, i'm a bit new to VB, and i can't afford those big books, so...

I'm making a game.  i have defined variables for stats of players.  i'd like to
know how to generate a random number based on a variable.

the general idea of my code is like this:

Option Explicit

Dim accuracy as integer
Dim Evade as integer
Dim CoH as Integer
Dim SCoH As Integer
Dim TCoH As Integer
Dim Hit As Boolean

Public Sub Chance_Of_Hit
Accuracy  = 20
Evade  = 10
CoH  = Accuracy*2 + Evade

'(Insert how to randomize CoH Here)

SCoH = Accuracy*4 + Evade * 2
TCoH = SCoH - CoH
If TCoH > (what ever value i put here) Then
Hit = True
Else
If TCoH < (What ever value i put here) Then
Hit = False
End If
End If
End Sub



Sun, 21 Apr 2002 03:00:00 GMT  
 I need help on randomizing variables
    Just use Rnd, it is built into VB. You can find it in the help file. It
generates numbers between 0 and 1, but you can scale them up if you need to.
Randomize it the first time you use it.
     Maybe try: chance_of_hit = rnd * accuracy * (1 - evade)
with everything on a 0 to 1 scale. (Or 0 to 100%)


Quote:
>alright, i'm a bit new to VB, and i can't afford those big books, so...

>I'm making a game.  i have defined variables for stats of players.  i'd
like to
>know how to generate a random number based on a variable.



Sun, 21 Apr 2002 03:00:00 GMT  
 I need help on randomizing variables
Randomize
CoH = Rnd

Hope this helps,
Jason Bouzane


Quote:
> alright, i'm a bit new to VB, and i can't afford those big books, so...

> I'm making a game.  i have defined variables for stats of players.  i'd
like to
> know how to generate a random number based on a variable.

> the general idea of my code is like this:

> Option Explicit

> Dim accuracy as integer
> Dim Evade as integer
> Dim CoH as Integer
> Dim SCoH As Integer
> Dim TCoH As Integer
> Dim Hit As Boolean

> Public Sub Chance_Of_Hit
> Accuracy  = 20
> Evade  = 10
> CoH  = Accuracy*2 + Evade

> '(Insert how to randomize CoH Here)

> SCoH = Accuracy*4 + Evade * 2
> TCoH = SCoH - CoH
> If TCoH > (what ever value i put here) Then
> Hit = True
> Else
> If TCoH < (What ever value i put here) Then
> Hit = False
> End If
> End If
> End Sub



Mon, 22 Apr 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. need help randomizing on GWBASIC

2. Need help with RANDOMIZE/RND

3. Need Help with Randomize

4. Desperate - need help with Randomize

5. Randomizing Variables

6. Randomizing Variables

7. When is Randomized needed?

8. Randomize and VB help please

9. Help with QBasic's "RANDOMIZE"

10. Help Generating Randomize Records

11. HELP - Challenging Randomize() question.

12. help on randomizing an image

 

 
Powered by phpBB® Forum Software