Skip to content

Instantly share code, notes, and snippets.

View Srushtika's full-sized avatar
:octocat:

Srushtika Neelakantam Srushtika

:octocat:
View GitHub Profile
//code from the lambda function
const request = require("request");
const axios = require("axios");
const ABLY_API_KEY = "<YOUR-ABLY-API-KEY>";
let textData = "";
let originalData;
let originalMessagePayload;
const publishMessageToAbly = async (textData, originalData, msgTimestamp) => {
@Srushtika
Srushtika / gameover.js
Created June 11, 2020 12:43
Code snippet 36 - For multiplayer space invaders article
let winner = localStorage.getItem("winner");
let firstRunnerUp = localStorage.getItem("firstRunnerUp");
let secondRunnerUp = localStorage.getItem("secondRunnerUp");
let totalPlayers = localStorage.getItem("totalPlayers");
document.getElementById("winner-announcement").innerHTML =
winner + " won the game!";
if (firstRunnerUp) {
document.getElementById("first-runnerup").innerHTML =
@Srushtika
Srushtika / winner.js
Created June 11, 2020 12:42
Code snippet 35 - For multiplayer space invaders article
let winner = localStorage.getItem("winner");
let firstRunnerUp = localStorage.getItem("firstRunnerUp");
let secondRunnerUp = localStorage.getItem("secondRunnerUp");
let totalPlayers = localStorage.getItem("totalPlayers");
document.getElementById("winner-announcement").innerHTML =
winner + " won the game!";
if (firstRunnerUp) {
document.getElementById("first-runnerup").innerHTML =
@Srushtika
Srushtika / nickname.js
Last active June 11, 2020 22:00
Code snippet 34 - For multiplayer space invaders article
let nickname = "";
let nicknameInput = document.getElementById("nickname");
function setNickname() {
localStorage.clear()
nickname = nicknameInput.value;
localStorage.setItem("nickname", nickname);
}
if(nicknameInput){
@Srushtika
Srushtika / gameover.html
Created June 11, 2020 12:35
Code snippet 33 - For multiplayer space invaders article
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Space Invaders</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Multiplayer space invaders" />
<link
id="favicon"
@Srushtika
Srushtika / winner.html
Created June 11, 2020 12:34
Code snippet 32- For multiplayer space invaders article
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Space Invaders</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Multiplayer space invaders" />
<link
id="favicon"
@Srushtika
Srushtika / intro.html
Created June 11, 2020 12:33
Code snippet 31- For multiplayer space invaders article
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Space Invaders</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Multiplayer space invaders" />
<link
id="favicon"
@Srushtika
Srushtika / gameRoomFull.html
Created June 11, 2020 12:32
Code snippet 30 - For multiplayer space invaders article
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Space Invaders</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Multiplayer space invaders" />
<link
id="favicon"
@Srushtika
Srushtika / script.js
Created June 9, 2020 23:04
Code snippet 29 - For multiplayer space invaders article
publishMyDeathNews(bullet, avatar) {
if (amIalive) {
deadPlayerCh.publish("dead-notif", {
killerBulletId: bulletThatShotMe,
deadPlayerId: myClientId,
});
}
amIalive = false;
}
@Srushtika
Srushtika / explosion.js
Created June 9, 2020 22:59
Code snippet 28 - For multiplayer space invaders article
class Explosion extends Phaser.GameObjects.Sprite {
constructor(scene, x, y) {
super(scene, x, y, "explosion");
scene.add.existing(this);
this.play("explode");
}
}