简体   繁体   中英

Representing players with 1..N coords in Java

my question is how would you do it to make a code as,

i need a list with players[unique] and for every player i got these coords [x, z]

but for every player there can be more than 1 coordinates[x,z]

i need to save it easly and i have to check the coords of the players every time they trigger an event...

so i have no idea where to start

my english aint good so i gonne try to draw it a little for you hehe

在此处输入图片说明

For every player, store the coordinates list in an ArrayList (where Point is a structure that holds the (x,y) coordinates--perhaps java.awt.Point). Make Point implement Serializable . (java.awt.Point already implements Serializable.) Also make the player class implement Serializable. Then it is easy to serialize and deserialize each player (or an ArrayList of them) using ObjectOutputStream / ObjectInputStream .

this one is resolved

made 2 classes Coordinate and Player and made in player an arraylist of coordinate

in the main class i make an arraylist of player...

Saving happens with xml

thx anyway for the help !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM