Skip to content

Commit

Permalink
fix: make the pixi.js game render better with rendering pixelated and…
Browse files Browse the repository at this point in the history
… by rounding the main sprite position
  • Loading branch information
manticorp committed Oct 17, 2024
1 parent bad6d4e commit 8e34e4b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
22 changes: 0 additions & 22 deletions docs/examples/html/lootbox_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,8 @@ const game = new Game(app);

await game.init();

// const loots = [];

// run.on('pointerdown', () => {
// console.log('Clicked Down');
// const idle = new PIXI.AnimatedSprite(spritesheet.animations.idle);
// idle.animationSpeed = 1 / 6;
// idle.play();
// app.stage.addChild(idle);
// idle.x = run.x;
// idle.y = run.y;
// loots.push(idle);
// });

// Add a ticker callback to move the sprite back and forth
let elapsed = 0.0;
app.ticker.add((ticker) => {
game.loop();
// elapsed += ticker.deltaTime;
// run.x = 0.0 + Math.pow(Math.cos(elapsed / 100.0), 2) * (640.0 - 64);
// loots.forEach(l => {
// l.y += 4;
// if (l.y > 360) {
// app.stage.removeChild(l);
// loots.splice(loots.indexOf(l), 1);
// }
// });
});
1 change: 1 addition & 0 deletions docs/examples/html/lootbox_game/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class Game {
// The application will create a canvas element for you that you
// can then insert into the DOM
document.getElementById('app').appendChild(this.app.canvas);
this.app.canvas.style.imageRendering = 'pixelated';

this.controller = new Controller();
this.ul = new UltraLoot();
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/html/lootbox_game/mover.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export default class Mover {
}

if (this.sprite) {
this.sprite.x = this.position.x;
this.sprite.y = this.position.y;
this.sprite.x = Math.round(this.position.x);
this.sprite.y = Math.round(this.position.y);
}

this.nanCheck();
Expand Down

0 comments on commit 8e34e4b

Please sign in to comment.