Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ig.module(
- 'game.main'
- )
- .requires(
- 'impact.game',
- 'impact.font',
- 'impact.debug.debug',
- 'plugins.packed-textures',
- 'plugins.tween-lite',
- 'plugins.menu',
- 'plugins.pause',
- 'plugins.pause-focus',
- 'game.entities.actor-player',
- 'game.entities.object-pickupBulletTime',
- 'game.entities.object-pu-miniship',
- 'game.entities.object-pu-life',
- 'game.screens.start-screen',
- 'game.menus'
- )
- .defines(function(){
- window.RType = ig.Game.extend({
- font: new ig.Font ('media/fonts/04b03.font.png' ),
- backdrop: new ig.Image('media/backgrounds/tempBG.png' ),
- grid: new ig.Image('media/backgrounds/tempBG.png' ),
- scanlines: new ig.Image('media/backgrounds/scan-lines.png' ),
- lifeSprite: new ig.Image('media/ui/ship_lifebar.png' ),
- statMatte: new ig.Image('media/ui/stat-matte.png' ),
- transTextBG: new ig.Image('media/ui/transTextBG.png' ),
- transTextBG_Lg: new ig.Image('media/ui/transTextBG_Lg.png' ),
- bulletTimeSprite: new ig.Image('media/ui/BulletTimeDisplayBar1.png' ),
- stage38Music: new ig.Sound('media/Music/Stage38.mp3', true ),
- stage38Music: new ig.Sound('media/Music/Stage38.ogg', true ),
- stage38Music: new ig.Sound('media/Music/Stage38.*', true ),
- entitiesKilled: 0,
- maxEntites: 6,
- currentEntities: 0,
- hudOffsetX: 20,
- hudOffsetY: 20,
- menu: null,
- mode: 0,
- /*******************************************
- * Init
- *******************************************/
- init: function () {
- this.inputControls();
- this.setGame();
- },
- /*******************************************
- * Update
- *******************************************/
- update: function() {
- this.parent();
- this.backgroundMaps[0].scroll.x += 30 * ig.system.tick;
- if (!this.menu && (ig.input.pressed('menu'))) {
- this.toggleMenu();
- }
- if (this.menu) {
- this.backgroundMaps[0].scroll.x += 100 * ig.system.tick;
- this.menu.update();
- if ( ig.input.pressed('shoot') && ig.input.mouse.x > ig.system.width - 154 && ig.input.mouse.y > ig.system.height - 56) {
- window.location = 'http://impactjs.com/';
- }
- if (!(this.menu instanceof GameOverMenu)) {
- return;
- }
- }
- },
- /*******************************************
- * Draw
- *******************************************/
- draw: function () {
- ig.system.clear(this.clearColor);
- this.backdrop.draw(0, 0);
- for (var i = 0; i < this.backgroundMaps.length; i++) {
- this.backgroundMaps[i].draw();
- }
- this.scanlines.draw(0, 0);
- for (var i = 0; i < this.entities.length; i++) {
- this.entities[i].draw();
- }
- /* HUD in top-left corner
- ************************/
- // Draws transparent background behind text
- this.transTextBG_Lg.draw(this.hudOffsetX -9, this.hudOffsetY - 13);
- // Draws lifebar
- this.font.draw("Lives", this.hudOffsetX + 7, this.hudOffsetY - 4);
- for (var i = 0; i < this.stats.lives; i++)
- this.lifeSprite.draw(((this.lifeSprite.width + 1) * i) + this.hudOffsetX +4, this.hudOffsetY + 4);
- // Draws bullet time bar
- this.font.draw("Bullet Time", this.hudOffsetX +7, this.hudOffsetY + 22);
- for (var i = 0; i < this.bulletTime.current; i++)
- this.bulletTimeSprite.draw(((this.bulletTimeSprite.width + 4) * i) + this.hudOffsetX +7, this.hudOffsetY + 32);
- /* HUD in top-right corner
- ************************/
- // Draws transparent background behind text
- this.transTextBG_Lg.draw(ig.system.width - this.transTextBG_Lg.width - 9, this.hudOffsetY - 13);
- // Draws score
- this.font.draw("Current Score", ig.system.width - this.transTextBG_Lg.width + 5, this.hudOffsetY - 4);
- this.font.draw(this.stats.kills * 100, ig.system.width - this.transTextBG_Lg.width + 5, this.hudOffsetY + 10);
- // Draw kills until boss
- this.font.draw("Kills untill boss", ig.system.width - this.transTextBG_Lg.width + 5, this.hudOffsetY + 25);
- this.font.draw(-this.stats.kills + this.bossSpawnKills.easy, ig.system.width - this.transTextBG_Lg.width + 5, this.hudOffsetY + 39);
- },
- /******************************************
- * Input Controls
- ******************************************/
- inputControls: function(){
- ig.input.bind(ig.KEY.A, 'left' );
- ig.input.bind(ig.KEY.LEFT_ARROW, 'left' );
- ig.input.bind(ig.KEY.D, 'right' );
- ig.input.bind(ig.KEY.RIGHT_ARROW,'right' );
- ig.input.bind(ig.KEY.W, 'up' );
- ig.input.bind(ig.KEY.UP_ARROW, 'up' );
- ig.input.bind(ig.KEY.S, 'down' );
- ig.input.bind(ig.KEY.DOWN_ARROW, 'down' );
- ig.input.bind(ig.KEY.C, 'shoot' );
- ig.input.bind(ig.KEY.TAB, 'switch' );
- ig.input.bind(ig.KEY.X, 'slowTime' );
- ig.input.bind(ig.KEY.Q, 'spawnCompanion');
- ig.input.bind(ig.KEY.MOUSE1, 'shoot' );
- ig.input.bind(ig.KEY.MOUSE2, 'rightClick' );
- ig.input.bind(ig.KEY.V, 'shootTest' );
- ig.input.bind(ig.KEY.SPACE, 'pause' );
- ig.input.bind(ig.KEY.ESC, 'menu' );
- },
- /******************************************
- * gameOver
- * Called by player when lived = 0
- ******************************************/
- gameOver: function () {
- ig.finalStats = ig.game.stats;
- ig.system.setGame(StaffRollScreen);
- ig.game.currentEntities = 0;
- EntityPickupBulletTime.prototype.currentBulletTime = 2;
- },
- /*****************************************
- * toggleMenu
- ******************************************/
- toggleMenu: function () {
- if (this.mode == RType.MODE.TITLE) {
- if (this.menu instanceof TitleMenu) {
- this.menu = new PauseMenu();
- } else {
- this.menu = new TitleMenu();
- }
- } else {
- if (this.menu) {
- ig.system.canvas.style.cursor = '';
- this.menu = null;
- } else {
- this.menu = new PauseMenu();
- }
- }
- },
- /*******************************************
- * setGame
- *******************************************/
- setGame: function () {
- window.scrollTo(0, 0);
- ig.music.add(this.stage38Music, 'stage38Music');
- ig.music.next();
- ig.music.play('stage38Music');
- ig.music.loop = true;
- this.menu = null;
- var bgmap = new ig.BackgroundMap(620, [
- [1]], this.grid);
- bgmap.repeat = true;
- this.backgroundMaps.push(bgmap);
- this.player = ig.game.spawnEntity(EntityActorPlayer, ig.system.width / 2, ig.system.height / 2);
- this.enemySpawner = ig.game.spawnEntity(EntityActorEnemySpawner, ig.system.width / 2, ig.system.height / 2);
- this.mode = RType.MODE.game;
- },
- /*******************************************
- * setTitle
- *******************************************/
- setTitle: function () {
- this.reset();
- this.mode = RType.MODE.TITLE;
- this.menu = new TitleMenu();
- },
- });
- /*******************************************
- * CREDITS SCREEN
- *******************************************/
- StaffRollScreen = ig.Game.extend({
- instructText: new ig.Font ('media/fonts/04b03.font.png' ),
- background: new ig.Image('media/backgrounds/StaffRoll.png' ),
- staffRollMusic: new ig.Sound('media/Music/Staff Roll 1.mp3' ),
- staffRollMusic: new ig.Sound('media/Music/Staff Roll 1.ogg' ),
- staffRollMusic: new ig.Sound('media/Music/Staff Roll 1.*' ),
- init: function () {
- // Loads music, then begins to play track
- ig.music.add(this.staffRollMusic, 'staffRollMusic');
- ig.music.play('staffRollMusic');
- ig.input.bind(ig.KEY.SPACE, 'start');
- ig.input.bind(ig.KEY.ENTER, 'start');
- },
- /*******************************************
- * Update
- *******************************************/
- update: function () {
- if (ig.input.pressed('start') || ig.input.pressed('click')) {
- ig.system.setGame(StartScreen);
- }
- this.parent();
- },
- /*******************************************
- * Draw
- *******************************************/
- draw: function () {
- this.parent();
- ig.music.play('StaffRoll');
- this.background.draw(0, 0);
- var x = ig.system.width / 2,
- y = ig.system.height / 2;
- this.instructText.draw('Thanks for playing!', x, y, ig.Font.ALIGN.CENTER);
- this.instructText.draw('Press SpaceBar or Enter to continue', x, y + 40, ig.Font.ALIGN.CENTER);
- this.instructText.draw('All music property of YouTube user Kevvviiinnn', x, y - 80, ig.Font.ALIGN.CENTER);
- this.instructText.draw('Developer: Dave Voyles - @DaveVoyles | www.DavidVoyles.Wordpress.com', x, y - 70, ig.Font.ALIGN.CENTER);
- }
- });
- /*******************************************
- * Instructions Screen
- *******************************************/
- InstructionsScreen = ig.Game.extend({
- backgroundInstructions: new ig.Image('media/backgrounds/instructScreen.png'),
- instructText: new ig.Font('media/fonts/04b03.font.png' ),
- init: function () {
- ig.input.bind(ig.KEY.SPACE, 'start');
- ig.input.bind(ig.KEY.ENTER, 'start');
- },
- /*******************************************
- * Update
- *******************************************/
- update: function () {
- if (ig.input.pressed('start') || ig.input.pressed('click')) {
- ig.system.setGame(MyGame);
- }
- this.parent();
- },
- /*******************************************
- * Draw
- *******************************************/
- draw: function () {
- this.parent();
- ig.music.play('StaffRoll');
- this.backgroundInstructions.draw(0, 0);
- var x = ig.system.width / 2;
- y = ig.system.height / 2;
- this.instructText.draw('Press SpaceBar, Enter, or touch to continue', x, y - 100, ig.Font.ALIGN.CENTER);
- }
- });
- window.RType.MODE = {
- TITLE: 0,
- GAME: 1,
- GAME_OVER: 2,
- SCORES: 3
- };
- //if (ig.ua.mobile) {
- //Disable sound for all mobile devices
- ig.Sound.enabled = false;
- //}
- ig.main( '#canvas', RType, 60, 924, 650, 1 );
- });
RAW Paste Data