Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
4 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |