text based sport game

01-23-2002, 11:48 PM
I'm making a text based basketball game and I cant figure out how to make the program generate random names and player abilities at the beginning of each year. Any help would be appreciated thanks.

01-24-2002, 12:46 AM
I would have placed only the link to this thread but there was a
lot of sample code there.

Here's the Link of the original thread (http://visualbasicforum.com/showthread.php?s=&threadid=16882)

This should give you a good idea of where to start.....

Originally posted by mohanakannan

Dim arr(20) As Integer
Dim rs As New adodb.Recordset
Dim cn As New adodb.connection
Dim intCounter As Integer
Dim intTemp As Integer
Dim intSubCounter As Integer
Dim intRsCount As Integer
Dim bCheck As Boolean

cn.open "DSN=test"

rs.open "Select* from Table1", cn
intRsCount = rs.recordcount
For intCounter = 1 To 20
intTemp = Rnd(intRsCount * Rnd + 1)
For intSubCounter = 1 To 20
If arr(intSubCounter) = intTemp Then
bCheck = True
intCounter = intCounter - 1
Exit For
End If
Next intSubCounter
If bCheck = False Then
arr(intCounter) = intTemp
End If
bCheck = False '<<<<<Correction was made here
Next intCounter

For intCounter = 1 To 20
rs.open "Select * from Table1 where QuestionNo='" & arr(intCounter) & "'", cn
MsgBox rs.fields(0)
Next intCounter

just add an SequentialID to ur table for example QuestionNo

and index the table with it.

now the above code will work better than the previous.. ;)

01-25-2002, 06:18 AM
ive neva seen a text sport game

01-26-2002, 12:23 AM
Never seen a text sports game? Try here...www.dolphinsim.com

01-26-2002, 12:24 AM
Robby thanks for your help...I think I've figured it out now :)

01-26-2002, 01:21 AM
oooh i see

01-27-2002, 02:29 AM
you, like manage it, i get it now

01-27-2002, 04:00 AM
make an array containing the names of all the players then assign the name randomly to your players in the game.

const MaxPlayers = 10
const Jump = 100
const Block = 100

Player(1).name = PlayerNameArray(int(rnd*MaxPlayers)+1)

int(rnd*MaxPlayers)+1 makes a random numbers between 1 and MaxPlayers.

Stats you can do the same way are well:

Player(1).Jump = int(rnd*MaxJump)+1
Player(1).Block = int(rnd*MaxBlock)+1

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum