Releases: quinton-ashley/p5play
v3.15
3.15.8
Fix for #275
3.15.7
Fixed group to group overlap checks.
3.15.5
If a sprite is added to a group that was previously removed with group.remove()
, users will get this warning.
"Adding a sprite to a group that was removed. Use group.removeAll()
to remove all of a group's sprites without removing the group itself. Restoring the group in p5play's memory."
This provides backwards compatibility with previous version of p5play where group.remove
and group.removeAll
were exactly the same.
3.15.3
Fixed #270 problem with instance mode cause I acidentally used touches
instead of this.touches
in __ontouchstart
I also added _ontouchmove
to make dragging sprites work.
3.15.2
Fixed sprite to group contact callback input params being ordered wrong only if group sprites were added to the group after the contact was set.
3.15.1
Includes bug fixes for all known issues!
Fixes #262, #265, #266, #267, #269, #270, #271, #272, #273, #274
I pretty much re-implemented how p5play handles contacts (collisions and overlaps) for better performance, which is why this update took 2 months to finish. 😅
sprite.mouse
now functions properly on mobile touchscreen devices.
Another important change is that setting a sprite's collider type to "none" does not remove its overlap sensors. Any projects that took advantage of that erroneous behavior can additionally use the sprite.removeSensors()
function.
Also I did a lot of little updates to p5play.org. The homepage videos play automatically on mobile now, I made them play based on whether they're observed, not based on the mouse hover position.
v3.14
3.14.13
Fix for rotated text images with centered text alignment.
I also noticed text image caching fixes rotation jitter.
3.14.12
pixelPerfect
implementation should check the dimensions (width and height) of a sprite's current animation frame, not the dimensions of its collider when calculating the pixel perfect position for images with odd side lengths. For example, an image with a width of 5 should have its x position rounded to the nearest integer + 0.5 so that the image can be displayed pixel perfectly.
3.14.10
Proper fix for #256
I didn't consider that if group sprites with no colliders are set to overlap on a group level, at the time addDefaultSensors
is called sprite._angle
would not exist. I switched the order of those lines in the Sprite constructor to make it work. I also never considered that the sprite needs to maintain its velocity vector as well, so I added that too.
3.14.9
Properly fixed #261 createTextImage
now returns a p5.Image
with correct sizing.
Also fixed p5play.palettes
not being assigned the default color palette.
Fixed mouse.dragging
. Also now sprite.mouse.hovering
and sprite.mouse.pressing
are strictly true only if the mouse is currently pressing on the sprite, so if the sprite moves they'll be false. sprite.mouse.dragging
is still suitably sticky, even if the mouse stops hovering directly over the sprite during the drag, it'll still drag.
3.14.4
Better fix for #256
3.14.2
p5.js actually sets textLeading
to be 1.25x textSize
by default, so I needed to adjust the position of text images to accommodate that. Also upgraded q5 to have the same behavior.
I also added the version number to the top of the file, haha I always forget.
3.14.0
Added not just a 2x or 5x, but a ridiculous 90x performance increase for rendering rotated text! All thanks to the new text image cache system. This feature is enabled by default, simply use the text
function as you normally would and p5play handles the rest behind the scenes.
Why does VSCode autocompletion only work inside the p5.js setup function?
https://github.com/quinton-ashley/p5play/wiki/FAQ#why-does-vscode-auto-completion-only-work-inside-the-p5js-setup-function
v3.13
3.13.5
Added group.velocity
alias for group.vel
.
Fixed a small mistake made in v3.13.0, group sprites should inherit group.speed
.
3.13.4
Sprites made with the GroupSprite
constructor new group.Sprite()
now have auto-completion! Same with Subgroup
groups.
3.13.2
Added types for input devices so that they can get auto-completions in VSCode too! #254
I also added contro.leftTrigger
and contro.rightTrigger
getters, thanks to discord user @ Metamere
Fixed #255
3.13.1
Removed all private (underscored) properties and methods from p5play.d.ts.
3.13.0
BIG update! Auto-complete in VSCode is here!
To add auto-completion to an existing project use npm or bun to install @types/p5 and p5play and add this jsconfig.json
file to your project folder:
{
"compilerOptions": {
"target": "ESNext"
},
"include": ["*.js", "**/*.js", "node_modules/@types/p5/global.d.ts", "node_modules/p5play/p5play.d.ts"]
}
Optionally, you can use the new p5play-vscode extension to create a new p5play project that will have auto-complete enabled. Huge thanks to @ Yog for his research and work on the extension.
This update to p5play adds a p5play.d.ts file to the p5play npm package.
This update also includes:
- fix for sprites not inheriting the name of an animation from a group animation (including when used with the Tiles constructor)
v3.12
Use these links in your projects to always get the latest version of p5play:
https://p5play.org/v3/planck.min.js
https://p5play.org/v3/p5play.js
3.12.5
The dimensions of a sprite that's created from a group with defined dimensions can now be overridden in the sprite's constructor, as users would expect.
let g = new Group();
g.d = 20;
// inherits diameter of 20
new g.Sprite(60, 60);
// overrides with diameter of 40
new g.Sprite(10, 10, 40);
3.12.4
planck.js bug 263 was fixed, p5play now uses v1 beta16
3.12.3
Workaround fix for an error found in v1 beta15 of planck. piqnt/planck.js#263
3.12.0
The offsetA
and offsetB
properties of DistanceJoint
and HingeJoint
were not properly implemented. @ Raj noticed that changing the offsets would change the positions of the attached sprites, which is not desirable! Also, sprite rotation is now accounted for when drawing joints with offset attachment points. I had previously announced that joints were finalized but the problem was that I tested joints with sprites that were too small for me to see the problems with changing the joint's offsets. Now they are good!
Added mouse.visible
, a boolean property for easily hiding the mouse, and mouse.cursor
which can be used to change the mouse's style. Will make a documentation page demoing this.
kb
letter key properties are now available in upper case, in addition to lower case. When using functions like kb.pressing()
the key name can be case insensitive, but special keys now uses camelCase
property names instead of PascalCase
.
v3.11
Use these links in your projects to always get the latest version of p5play:
https://p5play.org/v3/planck.min.js
https://p5play.org/v3/p5play.js
3.11.8
Keyboard letter input will not be case sensitive.
See the updated learn page:
https://p5play.org/learn/input_devices.html?page=1
3.11.5
Fixed kb
input detection for letter keys when users are pressing shift.
For other keys like "enter" and "arrowUp", kb
properties now use camelCase instead of PascalCase which is typical for JS properties, though the input functions, like kb.pressing
are still not case sensitive for these keys. I also added a few aliases such as "option" for "alt", "command" and "windows" for "meta", "ctrl" for "control", etc.
Also updated planck to v1.0 beta15
3.11.3
Fixed pixelPerfect
and upgraded planck.js to v1 beta 13.
3.11.2
Fixed param check for applyForce
and applyForceScaled
.
Also fixed renderStats
sprite count when sprites are drawn manually in the p5.js draw loop.
3.11.1
Upgraded planck.js to v1.0 beta10 which features huge performance improvements! Huge thanks to the lead developer of planck, Ali Shakiba!
3.11.0
Check out the updated page on "Advanced Movement"!
https://p5play.org/learn/sprite.html?page=15
This release included a breaking change to the applyForce
function, as recommended by @ Raj Raizada. It no longer scales the applied force to the sprite's mass. I also created the bearing
property and attractTo
function.
v3.10
Use these links in your projects to always get the latest version of p5play:
https://p5play.org/v3/planck.min.js
https://p5play.org/v3/p5play.js
3.10.12
Made renderStats
render above all other content drawn on the canvas no matter where it's placed in the p5.js draw
function, just cause that's how everyone would want to use it and then they don't have to fuss with manually drawing sprites before renderStats
.
Google Analytics will only load its script once per page now, no matter how many instances of p5play are on a page.
3.10.11
Added Google Analytics tracking so I can see how the library is being used. 🕵️♂️
Updated the EULA: "You consent to p5play using Google Analytics to track how the p5play library is used."
Also the Tiles
constructor will now ignore an initial new line character in its first parameter input string. This is so users can use backticks like this:
new Tiles(`
ggg
sssgg
sssssgg
`, 100, 100);
Instead of having to use it like this for the tile sprites to appear at the specified position.
new Tiles(`ggg
sssgg
sssssgg
`, 100, 100);
3.10.10
Changing camera.zoom
recalculates the camera's visible boundaries, as it should.
3.10.9
Fixed issue with sprites not being visible if their collider was set to none and they had overlap sensors.
3.10.8
The default camera
position (centered) is now set when the canvas is created, instead of in frame 1 of pre draw. This is a better way and also enables p5play to be compatible with p5.SceneManager.
3.10.6
Fixed problem with canvas.resize
not working with p5.js
3.10.5
Implemented resizeCanvas
and canvas.resize
https://p5play.org/learn/canvas.html?page=2
3.10.1
Fixed bug (regression) that caused inter-group collisions/overlaps to trigger their callback function twice.
3.10.0
I've made some important bug fixes in v3.9 so I thought it'd be good to do another minor version bump to v3.10. 🎆
Also in this update, I took out a lot of deprecated functions I had added warnings to months ago. I removed the Netcode
class as well, since it will only be useful for multiplayer games in the future and doesn't need to be part of the base p5play.js file. It will be included in p5play-pro.js as part of my upcoming release of p5play Pro features. p5play.min.js is now only 86kb.
Additionally, I fixed a critical bug 🐛 that was found by discord user rajraizada ! Big thanks to him!
If you always set a sprite's dimensions using the Sprite
constructor or using group inheritance, you don't have to worry about the ramifications of this bug fix. This bug fix had no negative affects on any p5play.org examples.
TLDR: The default mass of a sprite is now the same whether its dimensions are set in the Sprite
constructor or defined after the sprite gets created. Check out the updated "Physical Attributes" Learn page for a concise explanation of sprite.mass
.
Here's an in-depth explanation of what the problem was.
In p5play v3 all Sprite
constructor parameters are optional. This flexibility primarily exists to make p5play easier to learn for beginners, since after learning how to use the constructor most people would prefer using it to create sprites faster. But my intention was to make setting the sprite's position and dimensions later equivalent to setting them in the constructor. I've always promised that in the documentation.
However, Raj noticed that when setting a sprite's width and height after it was created without dimension parameters, the sprite's mass didn't change from the default 50x50 box collider sprite mass. That was not good, a big oversight!
Yet, when a sprite's dimensions change after they've already been defined by the user, the mass of the sprite should not change. This is because p5play doesn't make the assumption that any additional matter is theoretically being added to the sprite as its dimension changes. That's because in the real world, stretching or squishing an object doesn't change its mass.
function setup() {
new Canvas(400, 400);
spriteA = new Sprite();
log(spriteA.mass); // logs the default sprite's 50x50 box collider mass of ~3.461
spriteA.w = 20;
spriteA.h = 100;
log(spriteA.mass); // mass changes when the sprite's size is initially defined
spriteA.h = 200;
log(spriteA.mass); // mass doesn't change because the size of the sprite was already set
spriteB = new Sprite(100, 200, 20, 100);
log(spriteB.mass); // nearly the same as spriteA
spriteB.h = 200;
log(spriteB.mass); // mass doesn't change because the size of the sprite was already set
}
function draw() {
background(255);
}
v3.9
Use these links in your projects to always get the latest version of p5play:
https://p5play.org/v3/planck.min.js
https://p5play.org/v3/p5play.js
3.9.4
Skip drawing sensors unless sprite.debug
is true.
3.9.3
Finalized implementing RopeJoint
! Will make a Learn page for it soon.
Changing a sprite's collider type will remove all the joints attached to that collider. A console warning appears if users try to change the collider of a sprite that has joints. The sprite's collider type should be set before any joints are added to it or removing joints should be done explicitly with sprite.joints.removeAll()
3.9.2
Fixed issue with sprites with none colliders having rotation
set to NaN
3.9.0
Finalized the implementation of GlueJoint, DistanceJoint, WheelJoint, HingeJoint, and SliderJoint!
v3.8
3.8.46
p5play's new Canvas
no longer applies styles to all canvases, just in the .p5Canvas
class. Also pixelated preset styling is now only applied to a canvas using its individual id.
3.8.45
Fix for a regression introduced by v3.8.37 two weeks ago. The algorithm in the Sprite
constructor can now accurately search for animations if a sprite inherits from multiple groups that have animations with the same names. I forgot how important the order of the sprite.groups
array is because the function that finds animations needs to start with the lowest subgroup that the sprite is part of and then end with searching for the animation in the allSprites
group.
3.8.44
Quick fix for #249 but I will implement a better fix that'll be available in v3.9
3.8.43
I realized the spriteArt page didn't have a color table or any kind of illustration of the default color palette. Whoops!
I decided to update the default color palette in p5play so it now has a color for each letter of the alphabet! (even the letters that don't really have a color commonly associated with them) Then I improved the Learn reference page for the spriteArt function by adding a sketch that illustrates what color each letter represents.
The custom color palette section is now last and I give a brief intro level explanation of what a JavaScript Object is.
https://p5play.org/learn/sprite.html?page=3
3.8.39
Actually fixed joint.springiness
lol
3.8.38
The contro.released
function now properly detects when game controller buttons are released. Thanks to Discord user @Tezumie for reporting that issue.
3.8.37
When sprites are added to a group using group.push
or its alias group.add
, the sprite will now inherit the group's collision and overlap relationships with other sprites and groups. New group sprites will also inherit any previously set relations as well. Thanks to Discord user @day for reporting that issue.
Several issues with q5.js compatibility were also fixed recently.
3.8.36
Sensors are now sorted to be in the back of the sprite's fixture list when added. This ensures that physics attribute getters only get values from the sprite's most recently added collider, unless it had its colliders removed.
3.8.35
Fixed a pretty major oversight in regards to the contact system, which was demonstrated to me by Discord user @day. In previous versions, for example colliding
checks would not return a truthy frame value on the first frame of collision, when collides
returns true. Also when sprites collide and stop colliding on the same exact frame, usually due to colliding with other sprites on that frame, collides
wouldn't return true like it should. Now it all works just like the input system (ex. presses, pressing, pressed), as described in the docs!
3.8.33
Fixed a bug with group collisions not calling their callbacks if it also had contacts with another group, such as allSprites.
3.8.32
Bug fixes and fixes for my previous bug fixes... whoops! v3.9 is coming soon.
3.8.25
RevoluteJoint was renamed to HingeJoint
. Added SliderJoint
(wrapper for PrismaticJoint). Renamed maxTorque and torque to maxPower
and power
.
3.8.23
GlueJoint, DistanceJoint, WheelJoint, and RevoluteJoint classes have been added to p5play! The implementation of these joints and an additional joint will be finalized in v3.9.
3.8.21
Implemented proper mouse dragging detection. Also if a sprite is above multiple sprites that are overlapping, the mouse is only considered to be hovering over the sprite on the highest layer.
3.8.18
Fixed sprite.moveTowards
not reseting velocity to zero if the sprite is so close to the target position that it shouldn't move.
3.8.13
Move and rotate functions no longer throw an error if given null arguments, the sprite simply won't move. Enabling this usage will give users more flexibility. I think it'll be especially beneficial for testing multiplayer games in the future.
I've added a new global variable, netcode
, which is an instance of the p5play Netcode
class. It contains utility functions like spriteToBinary
and binaryToSprite
that will enable online multiplayer. I am not finished with it yet, but I'm publishing the code in case anyone has feedback or wants to collaborate with me on it!
3.8.9
Fixed move
and moveTo
not working properly if tileSize
was not 1.
3.8.8
The move
, moveTo
, rotate
, and rotateTo
sprite functions all return a Promise that resolves to true when the movement is finished.
But, if the sprite's movement is interrupted by a new movement or a collision that significantly changes the sprite's trajectory, the promise will resolve to false.
I also fixed a bug that caused sprite.offset
to not be maintained when changing the sprite's collider type.
3.8.5
Added cavas.w
/canvas.width
and canvas.h
/canvas.height
which you should use instead of the p5.js instance width
and height
variables, which are not specific enough and can lead to confusion. I changed all the p5play docs to use canvas.w
and canvas.h
.
3.8.3
Replaced sprite.offsetCenter
with a sprite.offset
object that has x and y properties. It can be changed for a whole group of sprites using group.offset
. Added support for other group object props like mirror and scale.
3.8.0
I added a offsetCenter
function that enables users to offset the center of a sprite. Also the rotateTo
and rotateTowards
functions can now use angles, as suggested by @ busch! I updated the examples:
https://p5play.org/learn/sprite.html?page=7
These functions can still accept position objects with x and y coordinates. However, if you want to provide position coordinates as numbers, then speed must be specified in the function as well.
v3.7
3.7.13
Sensors can be added to a sprite with a collider type of "none". I also added a new function addSensor
which adds overlap sensors to a sprite. I added removeColliders
and removeSensors
but these functions completely remove colliders/sensors so in most cases it's better to use collision functions like collides
to disable, without entirely removing, overlap sensors, and vice versa, use overlap functions like overlaps
to disable colliders.
3.7.11
Bug fix for group collisions and overlaps. Sprites could not begin contact with a group on the same frame as ending contact with another sprite in the same group.
3.7.10
User's can now set the camera's position in the p5.js setup function.
3.7.8
In previous versions there was no way to disable an overlap between sprites/groups, without changing the sprite's collider type. A student of @bobby S. suggested that overlaps could be disabled by explicitly checking for a collision and vice versa. Now why hadn't I thought of that!? 🧠 🧐
Check out the new "ghost ability" example! 👻
https://p5play.org/learn/sprite.html?page=6
3.7.7
I added a new "made with p5play" intro loading screen, similar to Unity's. But don't worry, it won't show up when you're developing with p5play in VSCode or any popular online code editor. I wanted to keep the loading screen simple but at least making it more interesting and professional looking than p5.js' basic "...loading" text.
What better way to unveil this new feature than with two of my favorite projects that were made with p5play: @axiom's "Squirrel" art and @Nitmay's "Red Remover" game!
https://quinton-ashley.github.io/Squirrel/Code/index.html
https://thegamebox.ca/redremover.html
3.7.6
I added a new sprite property called pixelPerfect for displaying sprites at integer coordinates, while retaining the precise position of the sprite's collider. Useful for pixel art games! 👾
3.7.3
Bug fix. Adding an image/animation to a sprite that has no specified dimensions should change it's dimensions.
3.7.2
Bug fix for when a sprite's dimensions are not defined in the constructor, then the user would expect the mass to change after they define the sprite's dimensions.
3.7.0
Performance improvements!
Collision and overlap handling in p5play (not talking about the physics solver here) is now faster. Behind the scenes of functions like overlaps
I was using JS Map. Each sprite and group had a map, and these maps used, as keys, the sprites/groups that the sprite/group overlapped with. But, I found out that getting and setting object properties that use integers as keys is nearly twice as fast! So now each sprite and group have unique ids for use in these objects.
Also now when a sprite gets removed that was previously colliding or overlapping with another sprite, it will still trigger collided
and overlapped
callbacks if it has any.
v3.6
3.6.9
Fixed culling bug and the last p5play compatibility issue with q5.js! (at least as far as I've tested)
3.6.8
Major bug fixes for testing group collisions. Also group.push (and its alias group.add) can now accept multiple sprites and returns the new length of the group just like Array.push does. Thanks to @calebfoss for reporting these problems!
3.6.7
Fixed rotateTo
bug that caused sprites to spin infinitely. q5.js is now used on every page of p5play.org!
3.6.6
Fixed bug with sprite.scale not working. I'll add tests for this so it doesn't happen again.
3.6.5
Bug fixes. When a sprite's collider is switched to 'none' it now retains its current position and vector, as expected.
3.6.4
I updated the sprite movement page to include the new angleTo
function. Inspired by @ Andy Shaw#1876's issue report of performance problems with using moveTo
every frame.
https://p5play.org/learn/sprite.html?page=2
Also sprite.anis
and group.anis
objects now function like groups do for sprites, they can enact soft and dynamic inheritance on the animations they contain. Example reference page coming soon!
sprite.debug = true
now shows the outline of the sprite's collider over the sprite's image/animation. Suggested by @ Lil Bobbity Scribbler#3858 !
3.6.3
Added the ability to define a scale for a canvas with the "pixelated" preset.
new Canvas(256, 240, 'pixelated x2');
Also entering keyboard input functions now autocorrect number keys inputted as JS Numbers by converting them to a string.
kb.pressing(5)
3.6.1
Added the version number to the top of the file.
3.6.0
@everyone v3.6 includes some critical bug fixes for p5play when used in p5.js instance mode, that were introduced in recent versions of v3.5. I also added beta support for q5.js, a small and fast alternative to p5.js. https://github.com/quinton-ashley/q5.js
In addition, I've made some important changes, to features that were mostly undocumented, which give users a greater degree of control over the drawing, physics stepping, and updating of sprites. 🔃
Before, if any sprite was drawn manually in the p5.js draw loop with sprite.draw()
, then every other sprite will not automatically be drawn and must also be drawn manually. That's probably not what most people would expect. Also there was no way to update animations without also progressing time in the physics world. 🌐
To see how I fixed these problems, check out this new page in the advanced topics section:
https://p5play.org/learn/advanced.html?page=3
I also made some structural/naming improvements to help users known what functions rely on the physics world and which ones do not.
getSpriteAt
is now world.getSpriteAt
getSpritesAt
is now world.getSpritesAt
updateSprites
is now world.step
and allSprites.update
p5play.autoDrawSprites
is now a property of groups and sprites called autoDraw
p5play.autoUpdateSprites
is now a property of groups and sprites called autoUpdate
world.autoResetAnimation
is now a property of groups and sprites called resetAnimationsOnChange
world.palettes
is now p5play.palettes