Compare commits
No commits in common. "master" and "c419d37d4e1006d408abb2b16695b8f26961b85f" have entirely different histories.
master
...
c419d37d4e
51
client.js
51
client.js
@ -7,27 +7,15 @@ export class Client {
|
|||||||
room;
|
room;
|
||||||
index;
|
index;
|
||||||
packageIndex = 0;
|
packageIndex = 0;
|
||||||
state = {
|
|
||||||
x: 0,
|
|
||||||
y: -887.56,
|
|
||||||
z: 0,
|
|
||||||
rotationX: 0,
|
|
||||||
rotationY: 0,
|
|
||||||
rotationZ: 0,
|
|
||||||
animation: 'Running',
|
|
||||||
nickname: `${this.index}#${this.packageIndex++}`,
|
|
||||||
characterKey: 'male',
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(index) {
|
constructor(index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.delta = { x: Math.floor(Math.random() * 2 - 1) * 3, z: Math.floor(Math.random() * 2 - 1) * 3};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async joinRoom() {
|
async joinRoom() {
|
||||||
this.client = new Colyseus.Client('wss://forwinmeta.sequenxe.com/api/socket');
|
this.client = new Colyseus.Client('wss://api-meta.sequenxe.com/socket');
|
||||||
|
|
||||||
this.room = await this.client.joinOrCreate("MyRoom");
|
this.room = await this.client.joinOrCreate("my_room");
|
||||||
this.room.onStateChange((state) => {
|
this.room.onStateChange((state) => {
|
||||||
if (this.index !== 0) {
|
if (this.index !== 0) {
|
||||||
return;
|
return;
|
||||||
@ -41,27 +29,16 @@ export class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testOnce() {
|
testOnce() {
|
||||||
this.state.x = this.delta.x + this.state.x;
|
this.room.send("updatePlayer", {
|
||||||
this.state.z = this.delta.z + this.state.z;
|
x: +Math.random().toFixed(1),
|
||||||
|
y: +Math.random().toFixed(1),
|
||||||
if(this.state.x < -800) {
|
z: +Math.random().toFixed(1),
|
||||||
this.delta.x = Math.random() * 5 + 5;
|
rotationX: +Math.random().toFixed(1),
|
||||||
this.state.x += this.delta.x;
|
rotationY: +Math.random().toFixed(1),
|
||||||
} else if(this.state.x > 800) {
|
rotationZ: +Math.random().toFixed(1),
|
||||||
this.delta.x = -(Math.random() * 5 + 5);
|
animation: Math.random().toFixed(1),
|
||||||
this.state.x += this.delta.x;
|
nickname: Math.random().toFixed(1),
|
||||||
};
|
characterKey: `${this.index}#${this.packageIndex++}`,
|
||||||
if(this.state.z < -800) {
|
});
|
||||||
this.delta.z = Math.random() * 5 + 5;
|
|
||||||
this.state.z += this.delta.z;
|
|
||||||
} else if(this.state.z > 800) {
|
|
||||||
this.delta.z = -(Math.random() * 5 + 5);
|
|
||||||
this.state.z += this.delta.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this.state.nickname = `${this.index}#${this.packageIndex++}`;
|
|
||||||
|
|
||||||
|
|
||||||
this.room.send("updatePlayer", this.state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user