Created
August 14, 2019 07:38
-
-
Save abzeede/f9c7b350e42d7e4f9f68e067dc3786bb to your computer and use it in GitHub Desktop.
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
// inital app | |
const app = new PIXI.Application({ | |
width: window.innerWidth, // set app width | |
height: window.innerHeight, // set app height | |
antialias: true, | |
transparent: false, | |
resolution: 1 | |
}); | |
// make background green | |
app.renderer.backgroundColor = "0x4caf50"; | |
// load flappy sprite | |
app.loader.add("flappy", "https://i.imgur.com/cben88F.png"); | |
// renderer function | |
app.loader.load((loader, resources) => { | |
// constant | |
const BIRD_SIZE = 80; | |
// init sprite | |
const bird = new PIXI.Sprite(resources.flappy.texture); | |
// setup | |
const basePosition = { | |
x: app.renderer.width / 2, | |
y: app.renderer.height / 2 | |
}; // center of the screen | |
let currentPos = { x: basePosition.x, y: basePosition.y }; | |
// create bird | |
bird.width = BIRD_SIZE; | |
bird.height = BIRD_SIZE; | |
bird.position.x = currentPos.x | |
bird.position.y = currentPos.y | |
// add bird to app screen | |
app.stage.addChild(bird); | |
}); | |
// append app screen to body | |
document.body.appendChild(app.view); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment