123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|724|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Players Swapping?

Wed, 12 Mar 2014, 09:48
Hotshot
For example, you have 25 players, 11 first team players, 7 Backup players, 7 Youth young players

Of course I will be using players skill for each positions(goalkeeper,defence,midfield,attack)


When come Team selections, for example, if I have better goalkeeper in backup Team then I want to swap my backup goalkeeper for first team goalkeeper but how would I do in code?

Is to do with Arrays that I can swap over? for example if I am doing text base with players name of using arrays to swap over and questions I would like ask is how?


Wed, 12 Mar 2014, 10:13
Jayenkai
To "swap" two things, you actually need three.
You can imagine this as being two items in your hands, and needing a nearby desk to place one onto, in order to swap the items in your hands.

1. Create (or find) a "Temporary" item.
(Imagine this is your "desk")
if you're using a Type, make a new type. If an array, find an empty slot.

2. Copy everything from Object 1 into the Temporary object.
(You're placing the object from your left hand onto the desk)
Make sure you include all the elements, or sub-array parts.

3. Copy everything from Object 2 over to Object 1.
(You're moving the object from your right hand into your left hand.)
Make sure you copy across all the bits and pieces.

4. Copy everything from the Temporary object over to Object 2.
(You're picking up the item from the desk, with your right hand)
Again, ensure you get all the pieces of information.

5. Empty the Temporary object, delete if necessary.


-=-=-
''Load, Next List!''
Wed, 12 Mar 2014, 13:06
Hotshot
I am not good on type but it seem like sort of bubble sort array where if person want swap somethings like

player_Name(i)=temp(i)
temp(i)=Player_Name(i)
swap=true

could you make basic text 3 player name of swapping player as I would be able to learn from it because I have never done it before

Wed, 12 Mar 2014, 13:29
Jayenkai
More like, if you want to swap Player(i) and Player(j)

Temp=player(i)
Player(i)=Player(j)
Player(j)=temp


-=-=-
''Load, Next List!''
Wed, 12 Mar 2014, 14:19
spinal



https://chris-taylor.github.io/blog/2013/02/25/xor-trick/

-=-=-
Check out my excellent homepage!
Wed, 12 Mar 2014, 15:25
rockford
That's different Spinal. Not seen that one before

I used to do what Jay does - three different variables a,b,c. GLBasic now has a command that speeds this up a little so I now just use "SWAP a,b", but it's essentially the same.

Hotshot: If you had the values within a range (eg a high score) then you'd use bubblesorting with the swap method to move scores up the list depending on their value.
Wed, 12 Mar 2014, 15:25
Hotshot
I got a problem....how do I select on player then click on swap boxed to swap who I want. It is same game that I used play on Amiga called Ultimate Soccer Manager

I am trying to create somethings like this


Hence why I thought simple button is good idea but dont have clue on how to select the players thought