Hello.
I'm making a program for my friend who is running an RPG Adventure at his school. I'll explain the basis behind the program and then what the problem is.
Basically, before any battle, each player is required to roll a d12 and add their Battle Initiative Value (BIV) to the number rolled. They would then be ordered smallest to biggest and do their battle action(s) in that order.
What my friend wants is the program to do that. But, once the d12 has been rolled for each character and the BIV values added, he wants the program to delay for about 5 seconds and then move each character portrait in the order required.
For example:
Picture In this picture of my program so far, you can see that the Battle Order Roll has been done. The character Malthar has the lowest number, so he would need to be moved to where Creeper is, and then Talenthia to be moved to where Crystal is, etc.

What I need help with is how to do this as I am not sure how I can link the GroupBoxes to arrays or something.

Thanks

Lewis

Thanks for the link.
I have an idea of making the tags of the group boxes receiving the value that the label inside the group box holds. I would then arrange them in order with a sorting algorithm and then move the group boxes to their correct positions.

I have this bit of code with the arrays GroupBoxes and BattleOrderValues declared at the beginning of the program under private:

begin
  for cnt :=1 to 8 do
  begin
    GroupBoxes[cnt].Tag:=strtoint(BattleOrderValues[cnt].Caption);
end;
end;

I just need to work out how to do a sorting algorithm to put the numbers in smallest to largest order and then manipulate them to get the GroupBoxes in order.

there are a lot of shorting algorithm :D
One of them:

program direct_arrange;

{$APPTYPE CONSOLE}

uses
  SysUtils;

Const n=8;

Type MyArray = Array[1..n]Of Integer;

Var x:MyArray = (8,1,4,5,3,6,2,7); //our array,unsorted yet!!!!
    idx:Integer;


//direct arranging
Procedure Direct(Var m:MyArray);
Var i,j,k:Integer;
Begin
   For i:=1 To n-1 Do Begin
      For j:=i+1 To n Do Begin
         If (m[i]>m[j]) Then Begin // if bigger then exchange them
            k:=m[i];
            m[i]:=m[j];
            m[j]:=k;
         End;
      End;
   End;
End;


begin //main
  Direct(x);  //call our procedure
  For idx:=1 To n Do Write(x[idx],' '); //write the result
  ReadLn;
end.

//the results are: 1 2 3 4 5 6 7 8


{
-=Created by FlmingClaw 2009.06.11.=-
}

I wrote this console application that you look at the shorting procedure

Thanks a lot for the help. I have finally got the numbers sorted smallest to biggest.
I have a new problem now but I will see if I can get it sorted before asking here again.
I will mark this post as solved once the program is finished because if I do need help again, I'll post here.

This question has already been answered. Start a new discussion instead.