diff --git a/scripts/team.js b/scripts/team.js new file mode 100644 index 0000000..db68387 --- /dev/null +++ b/scripts/team.js @@ -0,0 +1,67 @@ +/* + * 3DCycles - A lightcycle game. + * Copyright (C) 2019-2020 Glen Harpring + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +class Team +{ + hasPlayer(id) + { + for(var i=this.members.length-1;i>=0;--i) + { + if(this.members[i] == id) return true; + } + return false; + } + spawn(respawn=true,update=true) + { + // Player 0 spawns in center, 1 on right, 2 on left, 3 on right, 4 on left, etc + if(this.members.length > 0) + { + var t = cdir(this.dir); + var addx = (t[0]*settings.SPAWN_WINGMEN_SIDE)+(t[1]*settings.SPAWN_WINGMEN_BACK), + addy = (t[1]*settings.SPAWN_WINGMEN_SIDE)+(t[0]*settings.SPAWN_WINGMEN_BACK); + this.members[0].spawn({ + x: this.x, y: this.y, z: this.z, dir: this.dir + },respawn,update); + for(var i=1;i