Skip to content

Commit

Permalink
dfg
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Jul 10, 2022
1 parent c8bcdd9 commit f38d4eb
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 17 deletions.
12 changes: 6 additions & 6 deletions classes/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,24 @@ class Player {
var levelMult = this.speedLevel == 1 ? 1.5 : this.speedLevel == 2 ? 2 : 3;
if(!this.mouseMove) {
if(this.controller.left) {
this.pos.x -= tickDiff * 0.15 * this.speed * this.speedMultiplier * levelMult;
this.pos.x -= tickDiff * 0.18 * this.speed * this.speedMultiplier * levelMult;
}
if(this.controller.right) {
this.pos.x += tickDiff * 0.15 * this.speed * this.speedMultiplier * levelMult;
this.pos.x += tickDiff * 0.18 * this.speed * this.speedMultiplier * levelMult;
}
if(this.controller.up) {
this.pos.y -= tickDiff * 0.15 * this.speed * this.speedMultiplier * levelMult;
this.pos.y -= tickDiff * 0.18 * this.speed * this.speedMultiplier * levelMult;
}
if(this.controller.down) {
this.pos.y += tickDiff * 0.15* this.speed * this.speedMultiplier * levelMult;
this.pos.y += tickDiff * 0.18* this.speed * this.speedMultiplier * levelMult;
}
} else

if(this.mouseMove) {
var speed = this.speed * this.speedMultiplier * levelMult;

this.pos.x += Math.cos(this.lookAngle) * speed * tickDiff * 0.15 * this.force;
this.pos.y += Math.sin(this.lookAngle) * speed * tickDiff * 0.15 * this.force;
this.pos.x += Math.cos(this.lookAngle) * speed * tickDiff * 0.18 * this.force;
this.pos.y += Math.sin(this.lookAngle) * speed * tickDiff * 0.18 * this.force;
}

const clamp = (min, max, value) => Math.max(min, Math.min(max, value));
Expand Down
2 changes: 1 addition & 1 deletion classes/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Room {
this.bridges.push(new Bridge(this.islands[0], this.islands[4], 150));
this.bridges.push(new Bridge(this.islands[0], this.islands[5], 150));

this.bridges.push(new Bridge(this.islands[1], this.islands[2], 200));
this.bridges.push(new Bridge(this.islands[1], this.islands[2], 150));
this.bridges.push(new Bridge(this.islands[2], this.islands[4], 150));
this.bridges.push(new Bridge(this.islands[4], this.islands[5], 150));
this.bridges.push(new Bridge(this.islands[5], this.islands[3], 150));
Expand Down
3 changes: 3 additions & 0 deletions helpers/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module.exports = {
// start socket.io server and cache io value
io = new Server(server, {
cors: { origin: "*" },
pingTimeout: 180000,
pingInterval: 25000,
transports: ["websocket"]
});
return io;
},
Expand Down
2 changes: 1 addition & 1 deletion helpers/levels.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const levels = [10, 25, 50, 100, 250, 450, 750, 900, 1000, 2000];
const levels = [5, 10, 25, 50, 100, 150, 200, 300, 400, 500];
// debugging levels
// const levels = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ io.on("connection", async (socket) => {
var player = new Player(name, socket.id, socket, mouseMove);
player.team = team;
roomlist.getAllRooms()[0].addPlayer(player);
console.log(socket.id +" joined!")
}

if(thetoken == process.env.bot) return joinThemIn();
Expand Down Expand Up @@ -117,11 +118,12 @@ io.on("connection", async (socket) => {
socket.on("ping", (fn) => {
fn(); // Simply execute the callback on the client
})
socket.on("disconnect", async () => {
socket.on("disconnect", async (why) => {
var room = roomlist.getRoomByPlayerId(socket.id);
if(room) {
room.removePlayer(socket.id);
}
console.log(socket.id +" disconnected because "+why);
});
});

Expand All @@ -135,7 +137,7 @@ setInterval(() => {
if(Date.now() - secondStart > 1000) {
// console.log("tps: " + tps);
actps = tps;
console.log("TPS", actps)
// console.log("TPS", actps)
tps = 0;
secondStart = Date.now();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"phaser": "^3.55.2",
"phaser3-rex-plugins": "^1.1.71",
"point-in-polygon": "^1.1.0",
"socket.io": "^4.2.0",
"socket.io": "^4.5.1",
"socket.io-client": "^4.5.1",
"ts-loader": "^9.3.0",
"typescript": "^4.6.4",
Expand Down
15 changes: 11 additions & 4 deletions src/GameScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ this.lastKnownMyDisplayWidth = 0;
ease: "Linear",
onComplete: () => {
this.titleMusic.stop();
this.teamPicker.destroy();

start();
},
Expand All @@ -291,6 +292,7 @@ this.lastKnownMyDisplayWidth = 0;
ease: "Linear",
onComplete: () => {
this.titleMusic.stop();
this.teamPicker.destroy();

start();
// console.log("team");
Expand All @@ -309,9 +311,9 @@ this.lastKnownMyDisplayWidth = 0;
this.uiCam.fadeIn(100)
this.cameras.main.ignore(this.loadingText);
this.loadingText.setFontSize(this.canvas.width / 20);
this.socket = io();
// this.socket.emit("go", this.name, team, this.mobile?true:false);
this.socket.emit("go", this.name, team, true, thetoken);
this.socket = io(undefined, {transports: ["websocket"]});
this.socket.emit("go", this.name, team, this.mobile?true:false, thetoken);
// this.socket.emit("go", this.name, team, true, thetoken);

this.team = `${team}`;

Expand Down Expand Up @@ -517,10 +519,13 @@ this.minimap.setVisible(false);
alpha: 0,
duration: 500,
onComplete: () => {

try {
this.players.get(id).destroy();

this.players.delete(id);
} catch(e) {
console.log("vdgj")
}
},
});

Expand Down Expand Up @@ -880,6 +885,7 @@ this.minimap.setVisible(false);
ease: "Linear",
onComplete: () => {
this.titleMusic.stop();
this.teamPicker.destroy();

start();
// console.log("team");
Expand All @@ -904,6 +910,7 @@ this.minimap.setVisible(false);
ease: "Linear",
onComplete: () => {
this.titleMusic.stop();
this.teamPicker.destroy();

start();
// console.log("team");
Expand Down
8 changes: 6 additions & 2 deletions src/components/TeamBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ export default class TeamBox extends Phaser.GameObjects.Container {
// this.text.x += this.image.displayWidth;

this.image.x -= this.text.displayWidth / 2;


try {
this.rect.setInteractive();
} catch(e) {
console.log(e)
}


})
Expand All @@ -71,7 +75,7 @@ export default class TeamBox extends Phaser.GameObjects.Container {
preUpdate() {
// console.log("ClassPicker update");
// console.log(Date.now() - this.lastUpdate, Date.now() - this.lastRefresh)
if(Date.now() - this.lastUpdate > 500 && Date.now() - this.lastRefresh > 500 && this.rect && this.rect.visible ) {
if(Date.now() - this.lastUpdate > 1000 && Date.now() - this.lastRefresh > 1000 && this.rect && this.rect.visible ) {
// console.log("Hiding");
this.lastUpdate = Date.now();

Expand Down

0 comments on commit f38d4eb

Please sign in to comment.