Skip to content

Instantly share code, notes, and snippets.

View Srushtika's full-sized avatar
:octocat:

Srushtika Neelakantam Srushtika

:octocat:
View GitHub Profile
@Srushtika
Srushtika / server.js
Last active June 9, 2020 13:37
Code snippet 7 - For multiplayer space invaders article
const envConfig = require("dotenv").config();
const express = require("express");
const Ably = require("ably");
const p2 = require("p2");
const app = express();
const ABLY_API_KEY = process.env.ABLY_API_KEY;
const CANVAS_HEIGHT = 750;
const CANVAS_WIDTH = 1400;
const SHIP_PLATFORM = 718;
@Srushtika
Srushtika / script.js
Created June 1, 2020 17:37
Code snippet 6 - For multiplayer space invaders article
let game = new Phaser.Game(config);
@Srushtika
Srushtika / script.js
Created June 1, 2020 17:23
Code snippet 5 - For multiplayer space invaders article
create() {
this.anims.create({
key: "explode",
frames: this.anims.generateFrameNumbers("explosion"),
frameRate: 20,
repeat: 0,
hideOnComplete: true
});
}
@Srushtika
Srushtika / script.js
Last active June 9, 2020 20:51
Code snippet 4 - For multiplayer space invaders article
preload() {
this.load.spritesheet(
"avatarA",
"https://cdn.glitch.com/f66772e3-bbf6-4f6d-b5d5-94559e3c1c6f%2FInvaderA_00%402x.png?v=1589228669385",
{
frameWidth: 48,
frameHeight: 32
}
);
this.load.spritesheet(
@Srushtika
Srushtika / script.js
Last active May 28, 2020 13:41
Code snippet 3 - For multiplayer space invaders article
class GameScene extends Phaser.Scene {
constructor() {
super("gameScene");
}
//load assets
preload(){
}
//init variables, define animations & sounds, and display assets
@Srushtika
Srushtika / script.js
Created May 28, 2020 12:22
Code snippet 2 - For multiplayer space invaders article
const config = {
width: 1400,
height: 750,
backgroundColor: "#FFFFF",
parent: "gameContainer",
scene: [GameScene],
physics: {
default: "arcade"
}
};
@Srushtika
Srushtika / index.html
Last active May 28, 2020 12:10
Code snippet 1 - 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"
[
{
"deviceId": "0001ETGYTW00GW0X476W5TVBFE",
"channel": "push:gmtest"
}
]
[
{
"id": "0001ETGYTW00GW0X476W5TVBFE",
"clientId": "id-q2li38voycq",
"platform": "ios",
"formFactor": "phone",
"metadata": {},
"deviceSecret": "4hcCuDNGW349NHokMgZcxo4zud1ASy8pnA1ETs3fsCE=",
"push": {
"recipient": {
[
{
"id": "0001ETGYTW00GW0X476W5TVBFE",
"clientId": "id-q2li38voycq",
"platform": "ios",
"formFactor": "phone",
"metadata": {},
"deviceSecret": "4hcCuDNGW349NHokMgZcxo4zud1ASy8pnA1ETs3fsCE=",
"push": {
"recipient": {