Hey guys, im new to Dark Basic and my friend and I using Dark Basic Pro to create a game much like Shining Force, but we intend on making it multiplayer later on down the track. What ive started is the battle engine coding for the turns, ive also done the code for attacking and killing characters but that code isnt running at the moment so i could rule it out interfering with the turns code. The turns code is simple, sort an array based on the characters speed, fastest to lowest, at the end of each turn.
Once i added the code it started crashing so it must be in the snippet ive given you guys. It prints the array after its been sorted, then it crashes. Can you guys find anything wrong with the code? Thanks
Rem Declare Types
Type CalcSpeed
Name As String
Speed As Integer
EndType
Type ModStats
HP As Integer
MP As Integer
AttackPower As Integer
DefencePower As Integer
Speed As Integer
Movement As Integer
IsMuddled As Boolean
EndType
Type RealStats
Owner As String
Name As String
HP As Integer
MP As Integer
AttackPower As Integer
DefencePower As Integer
Speed As Integer
Movement As Integer
IsMuddled As Boolean
Rem Declares the method
ChangeStat As ModStats
EndType
Rem Declare Arrays
Dim SpeedInfo(24) As CalcSpeed
Dim Character(24) As RealStats
`Declare First Character
Character(0).Owner = "Peons"
Character(0).Name = "Cheesy Git"
Character(0).HP = 12
Character(0).MP = 8
Character(0).AttackPower = 3
Character(0).DefencePower = 2
Character(0).Speed = 4
Character(0).Movement = 3
Character(0).IsMuddled = 0
`Set up Modified Array
Character(0).ChangeStat.HP = Character(0).HP
Character(0).ChangeStat.MP = Character(0).MP
Character(0).ChangeStat.AttackPower = Character(0).AttackPower
Character(0).ChangeStat.DefencePower = Character(0).DefencePower
Character(0).ChangeStat.Speed = Character(0).Speed
Character(0).ChangeStat.Movement = Character(0).Movement
Character(0).ChangeStat.IsMuddled = Character(0).IsMuddled
`Declare Second Character
Character(1).Owner = "Nano"
Character(1).Name = "Rykros"
Character(1).HP = 18
Character(1).MP = 4
Character(1).AttackPower = 5
Character(1).DefencePower = 4
Character(1).Speed = 7
Character(1).Movement = 5
Character(1).IsMuddled = 1
`Set up Modified Array
Character(1).ChangeStat.HP = Character(1).HP
Character(1).ChangeStat.MP = Character(1).MP
Character(1).ChangeStat.AttackPower = Character(1).AttackPower
Character(1).ChangeStat.DefencePower = Character(1).DefencePower
Character(1).ChangeStat.Speed = Character(1).Speed
Character(1).ChangeStat.Movement = Character(1).Movement
Character(1).ChangeStat.IsMuddled = Character(1).IsMuddled
Rem Start the Main Loop
do
if spaceKey() = 1 then End
GoSub SortSpeed
`GoSub DrawGUI
loop
SortSpeed:
`Declare Speed Array, maybe a list later on.
SpeedInfo(0).Speed = Character(0).ChangeStat.Speed
SpeedInfo(0).Name = Character(0).Name
SpeedInfo(1).Speed = Character(1).ChangeStat.Speed
SpeedInfo(1).Name = Character(1).Name
If SpeedInfo(0).Speed < SpeedInfo(1).Speed
TempName As String
TempSpeed As Integer
Rem Put Lower number in temporary variable
TempName = SpeedInfo(0).Name
TempSpeed = SpeedInfo(0).Speed
Rem Swap higher variable for lower variable
SpeedInfo(0).Name = SpeedInfo(1).Name
SpeedInfo(0).Speed = SpeedInfo(1).Speed
SpeedInfo(1).Name = TempName
SpeedInfo(1).Speed = TempSpeed
EndIf
Print SpeedInfo(0).Name
Print SpeedInfo(1).Name
Wait Key
Return