Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Change maggot to doge #154

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dest/css/pixi-examples.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dest/css/pixi-examples.min.css.map

Large diffs are not rendered by default.

Binary file removed examples/assets/maggot.png
Binary file not shown.
Binary file removed examples/assets/maggot_tiny.png
Binary file not shown.
Binary file added examples/assets/pixi_doge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions examples/js/demos-basic/particle-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,44 @@ const sprites = new PIXI.ParticleContainer(10000, {
app.stage.addChild(sprites);

// create an array to store all the sprites
const maggots = [];
const doges = [];

const totalSprites = app.renderer instanceof PIXI.Renderer ? 10000 : 100;

for (let i = 0; i < totalSprites; i++) {
// create a new Sprite
const dude = PIXI.Sprite.from('examples/assets/maggot_tiny.png');
const dude = PIXI.Sprite.from('examples/assets/pixi_doge.png');

// set the anchor point so the texture is centerd on the sprite
dude.anchor.set(0.5);

// different maggots, different sizes
// different doges, different sizes
dude.scale.set(0.8 + Math.random() * 0.3);

// scatter them all
dude.x = Math.random() * app.screen.width;
dude.y = Math.random() * app.screen.height;

dude.tint = Math.random() * 0x808080;
// dude.tint = Math.random() * 0x808080;

// create a random direction in radians
dude.direction = Math.random() * Math.PI * 2;

// this number will be used to modify the direction of the sprite over time
dude.turningSpeed = Math.random() - 0.8;

// create a random speed between 0 - 2, and these maggots are slooww
// create a random speed between 0 - 2, and these doges are slooww
dude.speed = (2 + Math.random() * 2) * 0.2;

dude.offset = Math.random() * 100;

// finally we push the dude into the maggots array so it it can be easily accessed later
maggots.push(dude);
// finally we push the dude into the doges array so it it can be easily accessed later
doges.push(dude);

sprites.addChild(dude);
}

// create a bounding box box for the little maggots
// create a bounding box box for the little doges
const dudeBoundsPadding = 100;
const dudeBounds = new PIXI.Rectangle(
-dudeBoundsPadding,
Expand All @@ -61,15 +61,15 @@ let tick = 0;

app.ticker.add(() => {
// iterate through the sprites and update their position
for (let i = 0; i < maggots.length; i++) {
const dude = maggots[i];
for (let i = 0; i < doges.length; i++) {
const dude = doges[i];
dude.scale.y = 0.95 + Math.sin(tick + dude.offset) * 0.05;
dude.direction += dude.turningSpeed * 0.01;
dude.x += Math.sin(dude.direction) * (dude.speed * dude.scale.y);
dude.y += Math.cos(dude.direction) * (dude.speed * dude.scale.y);
dude.rotation = -dude.direction + Math.PI;

// wrap the maggots
// wrap the doges
if (dude.x < dudeBounds.x) {
dude.x += dudeBounds.width;
} else if (dude.x > dudeBounds.x + dudeBounds.width) {
Expand Down
58 changes: 29 additions & 29 deletions examples/js/filters-basic/displacement-map-crawlies.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ const bounds = new PIXI.Rectangle(
app.screen.width + padding * 2,
app.screen.height + padding * 2,
);
const maggots = [];
const doges = [];

for (let i = 0; i < 20; i++) {
const maggot = PIXI.Sprite.from('examples/assets/maggot.png');
maggot.anchor.set(0.5);
container.addChild(maggot);
const doge = PIXI.Sprite.from('examples/assets/pixi_doge.png');
doge.anchor.set(0.5);
container.addChild(doge);

maggot.direction = Math.random() * Math.PI * 2;
maggot.speed = 1;
maggot.turnSpeed = Math.random() - 0.8;
doge.direction = Math.random() * Math.PI * 2;
doge.speed = 1;
doge.turnSpeed = Math.random() - 0.8;

maggot.x = Math.random() * bounds.width;
maggot.y = Math.random() * bounds.height;
doge.x = Math.random() * bounds.width;
doge.y = Math.random() * bounds.height;

maggot.scale.set(1 + Math.random() * 0.3);
maggot.original = new PIXI.Point();
maggot.original.copyFrom(maggot.scale);
maggots.push(maggot);
doge.scale.set(1 + Math.random() * 0.3);
doge.original = new PIXI.Point();
doge.original.copyFrom(doge.scale);
doges.push(doge);
}

const displacementSprite = PIXI.Sprite.from('examples/assets/pixi-filters/displace.png');
Expand Down Expand Up @@ -76,27 +76,27 @@ let count = 0;
app.ticker.add(() => {
count += 0.05;

for (let i = 0; i < maggots.length; i++) {
const maggot = maggots[i];
for (let i = 0; i < doges.length; i++) {
const doge = doges[i];

maggot.direction += maggot.turnSpeed * 0.01;
maggot.x += Math.sin(maggot.direction) * maggot.speed;
maggot.y += Math.cos(maggot.direction) * maggot.speed;
doge.direction += doge.turnSpeed * 0.01;
doge.x += Math.sin(doge.direction) * doge.speed;
doge.y += Math.cos(doge.direction) * doge.speed;

maggot.rotation = -maggot.direction - Math.PI / 2;
maggot.scale.x = maggot.original.x + Math.sin(count) * 0.2;
doge.rotation = -doge.direction - Math.PI / 2;
doge.scale.x = doge.original.x + Math.sin(count) * 0.2;

// wrap the maggots around as the crawl
if (maggot.x < bounds.x) {
maggot.x += bounds.width;
} else if (maggot.x > bounds.x + bounds.width) {
maggot.x -= bounds.width;
// wrap the doges around as the crawl
if (doge.x < bounds.x) {
doge.x += bounds.width;
} else if (doge.x > bounds.x + bounds.width) {
doge.x -= bounds.width;
}

if (maggot.y < bounds.y) {
maggot.y += bounds.height;
} else if (maggot.y > bounds.y + bounds.height) {
maggot.y -= bounds.height;
if (doge.y < bounds.y) {
doge.y += bounds.height;
} else if (doge.y > bounds.y + bounds.height) {
doge.y -= bounds.height;
}
}
});
58 changes: 29 additions & 29 deletions examples/js/plugin-picture/displacement.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,24 @@ const bounds = new PIXI.Rectangle(
app.screen.width + padding * 2,
app.screen.height + padding * 2,
);
const maggots = [];
const doges = [];

for (let i = 0; i < 20; i++) {
const maggot = PIXI.Sprite.from('https://pixijs.io/examples/examples/assets/maggot.png');
maggot.anchor.set(0.5);
container.addChild(maggot);
const doge = PIXI.Sprite.from('examples/assets/pixi_doge.png');
doge.anchor.set(0.5);
container.addChild(doge);

maggot.direction = Math.random() * Math.PI * 2;
maggot.speed = 1;
maggot.turnSpeed = Math.random() - 0.8;
doge.direction = Math.random() * Math.PI * 2;
doge.speed = 1;
doge.turnSpeed = Math.random() - 0.8;

maggot.x = Math.random() * bounds.width;
maggot.y = Math.random() * bounds.height;
doge.x = Math.random() * bounds.width;
doge.y = Math.random() * bounds.height;

maggot.scale.set(1 + Math.random() * 0.3);
maggot.original = new PIXI.Point();
maggot.original.copyFrom(maggot.scale);
maggots.push(maggot);
doge.scale.set(1 + Math.random() * 0.3);
doge.original = new PIXI.Point();
doge.original.copyFrom(doge.scale);
doges.push(doge);
}
const displacementContainer = new PIXI.Container();
const displacementTexture = PIXI.Texture.from('https://pixijs.io/examples/examples/assets/pixi-filters/displace.png');
Expand Down Expand Up @@ -160,27 +160,27 @@ let count = 0;
app.ticker.add(() => {
count += 0.05;

for (let i = 0; i < maggots.length; i++) {
const maggot = maggots[i];
for (let i = 0; i < doges.length; i++) {
const doge = doges[i];

maggot.direction += maggot.turnSpeed * 0.01;
maggot.x += Math.sin(maggot.direction) * maggot.speed;
maggot.y += Math.cos(maggot.direction) * maggot.speed;
doge.direction += doge.turnSpeed * 0.01;
doge.x += Math.sin(doge.direction) * doge.speed;
doge.y += Math.cos(doge.direction) * doge.speed;

maggot.rotation = -maggot.direction - Math.PI / 2;
maggot.scale.x = maggot.original.x + Math.sin(count) * 0.2;
doge.rotation = -doge.direction - Math.PI / 2;
doge.scale.x = doge.original.x + Math.sin(count) * 0.2;

// wrap the maggots around as the crawl
if (maggot.x < bounds.x) {
maggot.x += bounds.width;
} else if (maggot.x > bounds.x + bounds.width) {
maggot.x -= bounds.width;
// wrap the doges around as the crawl
if (doge.x < bounds.x) {
doge.x += bounds.width;
} else if (doge.x > bounds.x + bounds.width) {
doge.x -= bounds.width;
}

if (maggot.y < bounds.y) {
maggot.y += bounds.height;
} else if (maggot.y > bounds.y + bounds.height) {
maggot.y -= bounds.height;
if (doge.y < bounds.y) {
doge.y += bounds.height;
} else if (doge.y > bounds.y + bounds.height) {
doge.y -= bounds.height;
}
}
});