Skip to content

Commit

Permalink
#34: All weapons and magic is now hurting remote players
Browse files Browse the repository at this point in the history
  • Loading branch information
wpernath committed Sep 11, 2022
1 parent 1f6bb45 commit 2aeca01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions melonjs-client/src/main/client/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const CONFIG = {
//baseURL: "http://localhost:8080/",

// Use a real IP address if you want to do multiplayer testing
baseURL: "http://192.168.2.198:8080/",
//baseURL: "http://192.168.2.171:8080/",
//baseURL: "http://192.168.2.198:8080/",
baseURL: "http://192.168.2.171:8080/",
},

dev: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class MPLocalPlayerSprite extends BasePlayerSprite {
let bY = mapY + dy;

if ( this.spell == null && this.throwMagicSpell(bX, bY, dx, dy)) {
this.spell.tint.copy(this.color);
GlobalGameState.magicBolts--;
action.dx = dx;
action.dy = dy;
Expand Down Expand Up @@ -131,6 +132,7 @@ export class MPLocalPlayerSprite extends BasePlayerSprite {
if (input.isKeyPressed("damage")) {
if( GlobalGameState.magicFirespins > 0 ) {
this.throwMagicFireSpin(mapX, mapY);
this.spell.tint.copy(this.color);
GlobalGameState.magicFirespins--;
action.magicFirespin = true;
MultiplayerManager.get().sendAction(action);
Expand All @@ -140,6 +142,7 @@ export class MPLocalPlayerSprite extends BasePlayerSprite {
if (input.isKeyPressed("magic-barrier")) {
if( GlobalGameState.magicProtections > 0 ) {
this.throwMagicProtectionCircle(mapX, mapY);
this.spell.tint.copy(this.color);
GlobalGameState.magicProtections--;
action.magicProtectionCircle = true;
MultiplayerManager.get().sendAction(action);
Expand All @@ -149,6 +152,7 @@ export class MPLocalPlayerSprite extends BasePlayerSprite {
if (input.isKeyPressed("magic-nebula")) {
if( GlobalGameState.magicNebulas > 0 ) {
this.throwMagicNebula(mapX, mapY);
this.spell.tint.copy(this.color);
GlobalGameState.magicNebulas--;
action.magicNebula = true;
MultiplayerManager.get().sendAction(action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,34 @@ export class MPRemotePlayerSprite extends BasePlayerSprite {
}
else if( message.magicBolt ) {
this.throwMagicSpell(message.x, message.y, message.dx, message.dy, false);
this.spell.body.collisionType = my_collision_types.REMOTE_PROJECTILE;
this.spell.body.setCollisionMask(collision.types.PLAYER_OBJECT | collision.types.ENEMY_OBJECT);
this.spell.tint.copy(this.color);
this.spell.thrownByPlayer = this.player;
}
else if( message.chestCollected ) {

}
else if (message.magicNebula) {
this.throwMagicNebula(message.x, message.y, false);
this.spell.body.collisionType = my_collision_types.REMOTE_PROJECTILE;
this.spell.body.setCollisionMask(collision.types.PLAYER_OBJECT | collision.types.ENEMY_OBJECT);
this.spell.tint.copy(this.color);
this.spell.thrownByPlayer = this.player;
}
else if (message.magicProtectionCircle) {
this.throwMagicProtectionCircle(message.x, message.y, false);
this.spell.body.collisionType = my_collision_types.REMOTE_PROJECTILE;
this.spell.body.setCollisionMask(collision.types.PLAYER_OBJECT | collision.types.ENEMY_OBJECT);
this.spell.tint.copy(this.color);
this.spell.thrownByPlayer = this.player;
}
else if (message.magicFirespin) {
this.throwMagicFireSpin(message.x, message.y, false);
this.spell.body.collisionType = my_collision_types.REMOTE_PROJECTILE;
this.spell.body.setCollisionMask(collision.types.PLAYER_OBJECT | collision.types.ENEMY_OBJECT);
this.spell.tint.copy(this.color);
this.spell.thrownByPlayer = this.player;
}
else if (message.bombPlaced) {
let bomb = new BombEntity(this.pos.x, this.pos.y);
Expand Down Expand Up @@ -76,7 +92,8 @@ export class MPRemotePlayerSprite extends BasePlayerSprite {
this.flicker(GlobalGameState.playerInvincibleTime, () => {
this.invincible = false;
});
} else if (other.body.collisionType === collision.types.PROJECTILE_OBJECT) {
}
else if (other.body.collisionType === collision.types.PROJECTILE_OBJECT) {
// a remote player is touched by our bomb
if (other.isExploding) {
this.invincible = true;
Expand Down

0 comments on commit 2aeca01

Please sign in to comment.