Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Isabel Anguera committed Jun 12, 2020
2 parents 908ed37 + 8dff6a9 commit d6d5d39
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -19,7 +19,8 @@
],
"main": "src/index_p5.js",
"sideEffects": [
"./src/index.p5.js"
"./src/index.p5.js",
"./src/party_debug.css"
],
"engines": {
"node": "14.1.0"
Expand All @@ -37,7 +38,7 @@
"serve": "PORT=${PORT:-6020} deepstream start",
"test": "echo \"No test specified\" && exit 0",
"netlify": "npm run build && cp -r dist public",
"prepublishOnly": "npm run build && npm run pack",
"prerelease": "npm run build && npm run pack",
"release": "np",
"pack": "npm run build && ln -s public/examples && zip p5.party.zip -r dist -r examples && rm -r examples && unzip -l p5.party.zip"
},
Expand Down
9 changes: 9 additions & 0 deletions public/examples/hello_cdn/README.md
@@ -0,0 +1,9 @@
# hello_cdn

This is hello_party but using a cdn.

This example shows how to connect to a party server, load a shared data object, and read and write to it. It also shows how to share a p5 color.

- **click** to move the dot

> Open this example in two browser windows at once!
18 changes: 18 additions & 0 deletions public/examples/hello_cdn/index.html
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<head>
<link rel="stylesheet" href="../sketch.css" />
</head>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.0.0/p5.min.js"></script>

<!-- Using the latest version -->
<script src="https://unpkg.com/p5.party@latest/dist/p5.party.js"></script>
<!-- Using a specific version -->
<!-- <script src="https://unpkg.com/p5.party@0.3.2/dist/p5.party.js"></script> -->

<script src="index.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions public/examples/hello_cdn/index.js
@@ -0,0 +1,31 @@
let shared;
function preload() {
partyConnect(
"wss://deepstream-server-1.herokuapp.com",
"hello_party",
"main"
);
shared = partyLoadShared("shared");
}

function setup() {
createCanvas(400, 400);
noStroke();

// set defaults on shared data
shared.x = shared.x || 0;
shared.y = shared.y || 0;
}

function mousePressed(e) {
// write shared dataa
shared.x = mouseX;
shared.y = mouseY;
}

function draw() {
background("#ffcccc");
fill("#000066");
// read shared data
ellipse(shared.x, shared.y, 100, 100);
}

0 comments on commit d6d5d39

Please sign in to comment.