diff --git a/.DS_Store b/.DS_Store
index 0ce6a1e8..a620e330 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/lang/en/learn/index.md b/lang/en/learn/index.md
index 206d302c..ad2a0bf5 100644
--- a/lang/en/learn/index.md
+++ b/lang/en/learn/index.md
@@ -1,6 +1,6 @@
# 0-0
-[**_Learn p5play: An Introduction to Object Oriented Programming_**](.) was written by Quinton Ashley, the creator of p5play v3. It's packed with beginner friendly reference documentation and interactive code examples.
+[**_Learn p5play: An Introduction to Object Oriented Programming_**](.) was written by Quinton Ashley, the creator of p5play v3. It's packed with beginner friendly reference documentation and interactive code examples!
# 0-1
diff --git a/lang/en/learn/sprite.md b/lang/en/learn/sprite.md
index e481ddfa..bfdbe517 100644
--- a/lang/en/learn/sprite.md
+++ b/lang/en/learn/sprite.md
@@ -1,6 +1,6 @@
# 0-0
-## Setup
+## Setup and Draw
The code inside the [q5.js](https://q5js.org) (or [p5.js](https://p5js.org)) `setup` function runs when the program starts. The `new Canvas()` constructor creates a section of the screen that the program can draw on.
diff --git a/learn/.DS_Store b/learn/.DS_Store
index aa22e5b3..cd5d60b7 100644
Binary files a/learn/.DS_Store and b/learn/.DS_Store differ
diff --git a/learn/animation.html b/learn/animation.html
index 5a6f46ac..a9f55c82 100644
--- a/learn/animation.html
+++ b/learn/animation.html
@@ -49,7 +49,7 @@
How to load animations
function setup() {
new Canvas(500, 160);
- cloudAni = loadAni('assets/cloud_breathing1.png', 9);
+ cloudAni = loadAni('assets/cloud_breathing1.webp', 9);
}
function draw() {
@@ -71,13 +71,13 @@ How to load animations
new Canvas(500, 160);
shapeShifterAni = loadAnimation(
- 'assets/asterisk.png',
- 'assets/triangle.png',
- 'assets/square.png',
- 'assets/cloud.png',
- 'assets/star.png',
- 'assets/mess.png',
- 'assets/monster.png'
+ 'assets/asterisk.webp',
+ 'assets/triangle.webp',
+ 'assets/square.webp',
+ 'assets/cloud.webp',
+ 'assets/star.webp',
+ 'assets/mess.webp',
+ 'assets/monster.webp'
);
shapeShifterAni.frameDelay = 10;
@@ -103,7 +103,7 @@ How to load animations
function setup() {
new Canvas(500, 200);
- splatAni = loadAnimation('assets/explode_sprite_sheet.png', { frameSize: [171, 158], frames: 11 });
+ splatAni = loadAnimation('assets/explode_sprite_sheet.webp', { frameSize: [342, 316], frames: 11 });
}
function draw() {
@@ -128,15 +128,18 @@ Animating
function setup() {
new Canvas(500, 160);
- ani = loadAni('assets/asterisk_explode0001.png', 11);
+ ani = loadAni('assets/asterisk_explode01.webp', 11);
}
function draw() {
clear();
- if (kb.presses('s')) ani.stop();
- if (kb.presses('p')) ani.play();
- if (kb.presses('o')) ani.play(0);
+ if (kb.presses('space')) {
+ if (ani.playing) ani.pause();
+ else ani.play();
+ }
+
+ if (kb.presses('p')) ani.play(0);
if (kb.presses('ArrowDown')) ani.frameDelay--;
if (kb.presses('ArrowUp')) ani.frameDelay++;
if (kb.presses('r')) ani.rewind();
@@ -185,8 +188,8 @@ Control a Sprite's Animation
new Canvas(500, 160);
ghost = new Sprite(250, 80, 120);
- ghost.addAni('fly', 'assets/ghost_walk01.png', 3);
- ghost.addAni('idle', 'assets/ghost_standing01.png', 7);
+ ghost.addAni('fly', 'assets/ghost_walk01.webp', 3);
+ ghost.addAni('idle', 'assets/ghost_standing01.webp', 7);
}
function draw() {
@@ -231,7 +234,7 @@ Groups with Animations
new Canvas(500, 160);
splats = new Group();
- splats.addAni('assets/asterisk_explode0001.png', 11);
+ splats.addAni('assets/asterisk_explode0001.webp', 11);
}
function draw() {
@@ -248,7 +251,8 @@ Groups with Animations
Sprite Sheets with Multiple Animations
To load multiple animations from the same sprite sheet image, first set the
- spriteSheet
property of the sprite or group.
+ spriteSheet
property of the sprite or group.
+
Next, use the addAnimations
/ addAnis
function. They accept an object
that uses animation names as keys and sprite sheet atlases as values.
Using an atlas object is way easier than manually specifying the coordinates of every frame!
@@ -256,12 +260,14 @@ Sprite Sheets with Multiple Anim
x
, y
, pos
, w
/width
,
h
/height
, size
/frameSize
, row
,
col
, frames
/frameCount
,
- delay
/frameDelay
, and rotation
.
+ delay
/frameDelay
, and rotation
.
+
In the "hero" example the size of the hero sprite is set to 32x32 pixels in the
- Sprite
constructor. That size is used as a multiplier to the row value given.
+ Sprite
constructor. That size is used as a multiplier to the row value given.
+
The ani.offset
property is used to adjust the position of an animation relative to
the sprite's position.
- Click this link to see the full questKid
+
Click this link to see the full questKid
sprite sheet used in the example.
If you'd like to truly appreciate p5play, compare the example code to anis
function preload() {
hero = new Sprite(125, 48, 32, 32);
- hero.spriteSheet = 'assets/questKid.png';
+ hero.spriteSheet = 'assets/questKid.webp';
hero.anis.offset.x = 2;
hero.anis.frameDelay = 32;
hero.anis.demoMode = true;
@@ -304,7 +310,8 @@ anis
}
function setup() {
- new Canvas(250, 96, 'pixelated x2');
+ new Canvas(250, 96);
+ displayMode('default', 'pixelated', 2)
allSprites.pixelPerfect = true;
}
@@ -323,7 +330,7 @@ anis
function preload() {
hero = new Sprite(62, 24, 32, 32);
- hero.spriteSheet = 'assets/questKid.png';
+ hero.spriteSheet = 'assets/questKid.webp';
hero.anis.offset.x = 2;
hero.anis.frameDelay = 8;
hero.friction = 0;
@@ -339,7 +346,8 @@ anis
}
function setup() {
- new Canvas(124, 48, 'pixelated x4');
+ new Canvas(124, 48);
+ displayMode('normal', 'pixelated', 4);
allSprites.pixelPerfect = true;
}
@@ -370,7 +378,7 @@ Animation Sequencing
function preload() {
hero = new Sprite(62, 24, 32, 32);
- hero.spriteSheet = 'assets/questKid.png';
+ hero.spriteSheet = 'assets/questKid.webp';
hero.anis.offset.x = 2;
hero.anis.offset.y = 2;
hero.anis.frameDelay = 8;
@@ -450,7 +458,7 @@ Advanced Animation Sequencing
function preload() {
hero = new Sprite(90, 24, 32, 32);
- hero.spriteSheet = 'assets/questKid.png';
+ hero.spriteSheet = 'assets/questKid.webp';
hero.anis.offset.x = 2;
hero.anis.offset.y = 2;
hero.anis.frameDelay = 8;
@@ -505,15 +513,15 @@ Advanced Animation Sequencing
-
-
-
+
+
-
-
+
+