(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jiboProgrammingChallenge = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ /// <reference path="../typings/index.d.ts" /> "use strict"; const PIXI = require('pixi.js'); const renderer = new PIXI.WebGLRenderer(1280, 720); document.body.appendChild(renderer.view); // You need to create a root container that will hold the scene you want to draw. const stage = new PIXI.Container(); // Declare a global variable for our sprite so that the animate function can access it. let bunny = null; // load the texture we need PIXI.loader.add('bunny', 'images/bunny.jpeg').load(function (loader, resources) { // This creates a texture from a 'bunny.png' image. bunny = new PIXI.Sprite(resources.bunny.texture); // Setup the position and scale of the bunny bunny.position.x = 400; bunny.position.y = 300; bunny.scale.x = 2; bunny.scale.y = 2; // Add the bunny to the scene we are building. stage.addChild(bunny); // kick off the animation loop (defined below) animate(); }); function animate() { // start the timer for the next animation loop requestAnimationFrame(animate); // each frame we spin the bunny around a bit bunny.rotation += 0.01; // this is the main render call that makes pixi draw your container and its children. renderer.render(stage); } },{"pixi.js":undefined}]},{},[1])(1)
updateSize(width, height) { this.width = width; this.height = height; this._renderer.view.style.width = this.width + "px"; this._renderer.view.style.height = this.height + "px"; this._renderer.resize(this.width, this.height); }
function animate() { // start the timer for the next animation loop requestAnimationFrame(animate); // each frame we spin the bunny around a bit bunny.rotation += 0.01; // this is the main render call that makes pixi draw your container and its children. renderer.render(stage); }
resize() { // update vars this.sceneWidth = window.innerWidth this.sceneHeight = window.innerHeight // update renderer this.renderer.resize(this.sceneWidth, this.sceneHeight) }
update( delta ) { this.components.forEach( c => { if( c.entity.hasComponent( 'position' ) ) { c.disc.x = c.entity.getComponent( 'position' ).position.x; c.disc.y = c.entity.getComponent( 'position' ).position.y; } } ); this.renderer.render( this.stage ); }
draw() { this.renderer.render(this.scene) }
render() { this._renderer.render(this._container); }