|
-
Mar 8th, 2000, 06:11 AM
#1
Thread Starter
New Member
In my rpg, in the battle sequences, I want each character (4 players and 4 enemies) to execute the actions they chose in the order of their agility.
the variables for agility are:
player1agi,player2agi...
enemy1agi,enemy2agi...
I can't seem to be able to place them in order from greater agility to lower. Someone told me to use arrays using udts but being the VB newbie that i am, arrays using udts means ABSOLUTELY NOTHING to me. Plz help.
Thx alot from a real dumb VB newbie
Fred
-
Mar 8th, 2000, 12:09 PM
#2
Hi,
First for you're characters and enemies, are you using user defined types?
'example of user defined type
type Characters
ID as Byte
Agility as Byte
end type
Then you declare an array of this type.
Fill the appropriate values.
Sort the array by value of agility, and you have the combat sequence.
Maybe I could help you more if you could tell me how you keep track of you characters.
If you don't understand what i'm talking about in the lines above, I could explain, just tell me what you don't understand.
Good luck! 
Kayan.
-
Mar 9th, 2000, 06:15 AM
#3
Thread Starter
New Member
exact misunderstanding
what I'd like to know exactly is how to sort arrays by using the value of the integer that represents agility.
Thx alot !|!!
Fred
-
Mar 9th, 2000, 09:13 AM
#4
Now that I know that I'll show you how to sort an array using the bubble sort technic.
Code:
Dim agility(7) As Integer
'for memory permutations
Dim Temp As Integer
'counters
Dim Counter1, Counter2 As Integer
Counter1 = 7
Counter2 = 0
Do While Counter1 <> 0
Do While Counter2 < Counter1
If agility(Counter2) > agility(Counter2 + 1) Then
Temp = agility(Counter2)
agility(Counter2) = agility(Counter2 + 1)
agility(Counter2 + 1) = Temp
End If
Counter2 = Counter2 + 1
Loop
Counter2 = 0
Counter1 = Counter1 - 1
Loop
This code should resolve your problem, and has been tested.
Kayan
Edited by Kayan on 03-09-2000 at 09:18 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|