mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-17 05:20:01 -04:00
Added Games
This commit is contained in:
parent
ed88ef11c0
commit
faa05290b8
271 changed files with 79295 additions and 5 deletions
82
views/archive/gopher/js/app.js
Normal file
82
views/archive/gopher/js/app.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
// var mainState = {
|
||||
// preload: function () {
|
||||
// game.load.spritesheet('car', '../assets/gopher-drive-loop.png', 63, 59, 2);
|
||||
// game.load.image('railBot', '../assets/bottom-rail.png');
|
||||
// game.load.image('road', '../assets/road-tile.png');
|
||||
// game.stage.smoothed = false;
|
||||
// },
|
||||
//
|
||||
// create: function () {
|
||||
// game.stage.backgroundColor = '#72c5cf';
|
||||
//
|
||||
// //1st num indicates the starting x tilePosition
|
||||
// //2nd num indicates the starting y tilePosition
|
||||
// //3rd num indicates the x (length) of repetition
|
||||
// //4th num indicates the y (height) of repetition
|
||||
// this.railBot = game.add.tileSprite(0, 385, 600, 0, 'railBot');
|
||||
//
|
||||
// game.physics.startSystem(Phaser.Physics.ARCADE);
|
||||
//
|
||||
// this.car = game.add.sprite(30, 280, "car");
|
||||
//
|
||||
// this.car.animations.add('drive', [0,1], 8, true);
|
||||
//
|
||||
// this.car.animations.play('drive');
|
||||
//
|
||||
// // this.car = game.add.sprite(30, 280, 'car');
|
||||
//
|
||||
// this.physics.arcade.enable(this.car);
|
||||
//
|
||||
// // this.car.anchor.setTo(-0.2, 0.5);
|
||||
//
|
||||
// this.car.body.collideWorldBounds = true;
|
||||
//
|
||||
// cursors = game.input.keyboard.createCursorKeys();
|
||||
//
|
||||
// // this.timer = game.time.events.loop(100, this.addRowOfRoads, this);
|
||||
//
|
||||
// this.road = game.add.group();
|
||||
// },
|
||||
//
|
||||
// update: function () {
|
||||
// this.railBot.tilePosition.x = 0.5;
|
||||
//
|
||||
// this.car.body.velocity.x = 0;
|
||||
//
|
||||
// if(cursors.right.isDown){
|
||||
// this.car.body.velocity.x = 100;
|
||||
// }
|
||||
//
|
||||
// else if (cursors.left.isDown){
|
||||
// this.car.body.velocity.x = -300;
|
||||
// }
|
||||
//
|
||||
// else if (cursors.right.isDown && this.car.body.y < this.window) {
|
||||
// this.car.body.velocity.x = 0;
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// addOneRoad: function(x, y){
|
||||
// var road = game.add.sprite(x, y, 'road');
|
||||
//
|
||||
// this.road.add(road);
|
||||
//
|
||||
// game.physics.arcade.enable(road);
|
||||
//
|
||||
// road.body.velocity.x = -300;
|
||||
//
|
||||
// road.checkWorldBounds = true;
|
||||
// road.outOfBoundsKill = true;
|
||||
// },
|
||||
//
|
||||
// addRowOfRoads: function(){
|
||||
// this.addOneRoad(600, 220);
|
||||
// },
|
||||
//
|
||||
// };
|
||||
//
|
||||
// var game = new Phaser.Game(600, 432, Phaser.AUTO, 'ld29', null, false, false);
|
||||
//
|
||||
// game.state.add('main', mainState);
|
||||
//
|
||||
// game.state.start('main');
|
53
views/archive/gopher/js/main.js
Normal file
53
views/archive/gopher/js/main.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
var game;
|
||||
var character;
|
||||
var npcSpawnRate = 1.8;
|
||||
var coinSpawnRate = 1;
|
||||
var availLanes = [233, 289, 345];
|
||||
var availNpcGophers =
|
||||
[
|
||||
[0, 1],
|
||||
[2, 3],
|
||||
[4, 5],
|
||||
[6, 7],
|
||||
[8, 9],
|
||||
[10, 11],
|
||||
[12, 13],
|
||||
[14, 15],
|
||||
[16, 17],
|
||||
[18, 19],
|
||||
];
|
||||
var score = 0;
|
||||
var cursors;
|
||||
var scoreText;
|
||||
var lives = 3;
|
||||
var count = 0;
|
||||
var timeElapsed = 0;
|
||||
|
||||
|
||||
var sky;
|
||||
var mtn;
|
||||
var city;
|
||||
var truck;
|
||||
var road;
|
||||
var bottomRail;
|
||||
var posts;
|
||||
var extras;
|
||||
var topRail;
|
||||
|
||||
window.onload = function(){
|
||||
if(screen.width>900){
|
||||
game = new Phaser.Game(600, 432, Phaser.CANVAS, "phaser-wrapper", null, false, false);
|
||||
}
|
||||
else{
|
||||
game = new
|
||||
Phaser.Game(window.innerWidth, window.innerHeight, Phaser.CANVAS, "phaser-wrapper");
|
||||
}
|
||||
game.state.add("StateTitle", StateTitle);
|
||||
game.state.add("StateMain", StateMain);
|
||||
game.state.add("StateChoice", StateChoice);
|
||||
game.state.add("StateTutorial", StateTutorial);
|
||||
game.state.add("StateOver", StateOver);
|
||||
|
||||
|
||||
game.state.start("StateTitle");
|
||||
};
|
4
views/archive/gopher/js/phaser.min.js
vendored
Normal file
4
views/archive/gopher/js/phaser.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
150
views/archive/gopher/js/stateChoice.js
Normal file
150
views/archive/gopher/js/stateChoice.js
Normal file
|
@ -0,0 +1,150 @@
|
|||
var StateChoice = {
|
||||
preload: function () {
|
||||
//Music and Sounds
|
||||
game.load.audio("select", "assets/music/BeepBox-Song3-compressed.m4a");
|
||||
|
||||
//Spritesheets for the 3 colored Gophers
|
||||
//Later put into 1 spritesheet
|
||||
game.load.spritesheet("racer", "assets/character-select-loops.png", 76, 72, 7);
|
||||
|
||||
game.load.image("background", "assets/bg-color.png");
|
||||
game.load.image("city", "assets/city-re-colored.png");
|
||||
game.load.image("sky", "assets/clouds-re-colored.png");
|
||||
game.load.image("mtn", "assets/mountains-recolored.png");
|
||||
game.load.image("select", "assets/character-select-bg.png");
|
||||
|
||||
//sample test button
|
||||
game.load.spritesheet("confirmButton", "assets/buttons-sprite.png", 111, 24, 4);
|
||||
game.load.spritesheet("neon", "assets/neon-sign.png", 120, 30, 13);
|
||||
|
||||
game.load.spritesheet("buttons", "assets/on-off-buttons.png", 59, 41, 2);
|
||||
game.load.spritesheet("blueMarquee", "assets/blue-crawl.png", 50, 12, 45);
|
||||
game.load.spritesheet("pinkMarquee", "assets/pink-crawl.png", 50, 12, 45);
|
||||
game.load.spritesheet("purpleMarquee", "assets/purple-crawl.png", 50, 12, 45);
|
||||
// game.load.spritesheet("neonCnfrm", "assets/neon-sign.png", )
|
||||
|
||||
},
|
||||
|
||||
create: function () {
|
||||
this.camera.reset();
|
||||
|
||||
//MUSIC
|
||||
this.selectSong = game.add.audio("select");
|
||||
//Watched youtube video, need to check docs for .play params
|
||||
this.selectSong.play('', 0, 1, true);
|
||||
|
||||
//BACKGROUND
|
||||
this.background = game.add.tileSprite(0, 0, 600, 432, "background");
|
||||
|
||||
this.sky = game.add.tileSprite(0, 10, 600, 78, "sky");
|
||||
this.mtn = game.add.tileSprite(0, 250, 600, 131, "mtn");
|
||||
this.city = game.add.tileSprite(0, 290, 600, 90, "city");
|
||||
this.select = game.add.tileSprite(0, 0, 600, 432, "select");
|
||||
|
||||
//MARQUEE
|
||||
//Blue
|
||||
this.blueMarquee = game.add.sprite(game.world.bounds.height - 282, game.world.centerY-16, "blueMarquee");
|
||||
this.blueMarquee.anchor.set(0.5, 0.5);
|
||||
this.blueMarquee.animations.add("blueCrawl", [],15, true);
|
||||
this.blueMarquee.animations.play("blueCrawl");
|
||||
//Pink
|
||||
this.pinkMarquee = game.add.sprite(game.world.bounds.height - 132, game.world.centerY-16, "pinkMarquee");
|
||||
this.pinkMarquee.anchor.set(0.5, 0.5);
|
||||
this.pinkMarquee.animations.add("pinkCrawl", [],13, true);
|
||||
this.pinkMarquee.animations.play("pinkCrawl");
|
||||
//Purple
|
||||
this.purpleMarquee = game.add.sprite(game.world.bounds.height + 18, game.world.centerY-16, "purpleMarquee");
|
||||
this.purpleMarquee.anchor.set(0.5, 0.5);
|
||||
this.purpleMarquee.animations.add("purpleCrawl", [],10, true);
|
||||
this.purpleMarquee.animations.play("purpleCrawl");
|
||||
|
||||
//Choose Racer1
|
||||
this.pickRacer1 = game.add.button(game.world.bounds.height - 282, game.world.centerY+105,
|
||||
"buttons", this.racerStart.bind(this, "blue"), this);
|
||||
this.pickRacer1.anchor.set(0.5, 0.5);
|
||||
|
||||
//Choose Racer2
|
||||
this.pickRacer2 = game.add.button(game.world.bounds.height - 132, game.world.centerY+105,
|
||||
"buttons", this.racerStart.bind(this, "pink"), this);
|
||||
this.pickRacer2.anchor.set(0.5, 0.5);
|
||||
|
||||
//Choose Racer3
|
||||
this.pickRacer3 = game.add.button(game.world.bounds.height + 18, game.world.centerY+105,
|
||||
"buttons", this.racerStart.bind(this, "purple"), this);
|
||||
this.pickRacer3.anchor.set(0.5, 0.5);
|
||||
|
||||
this.buttons = {
|
||||
"blue": this.pickRacer1,
|
||||
"pink": this.pickRacer2,
|
||||
"purple": this.pickRacer3
|
||||
};
|
||||
|
||||
//BLACK AND WHITE GOPHERS
|
||||
//Blue
|
||||
this.blue = game.add.sprite(game.world.bounds.height - 282, game.world.centerY+40, "racer");
|
||||
this.blue.frame = 1;
|
||||
this.blue.animations.add("blue", [1, 2],9, true);
|
||||
this.blue.anchor.set(0.5, 0.5);
|
||||
this.blue.animations.play("blue");
|
||||
|
||||
//Pink
|
||||
this.PinkGopher = game.add.sprite(game.world.bounds.height - 132, game.world.centerY+40, "racer");
|
||||
this.PinkGopher.frame = 3;
|
||||
this.PinkGopher.animations.add("pink", [3, 4],9, true);
|
||||
this.PinkGopher.anchor.set(0.5, 0.5);
|
||||
this.PinkGopher.animations.play("pink");
|
||||
|
||||
//Purple
|
||||
this.PurpleGopher = game.add.sprite(game.world.bounds.height + 18, game.world.centerY+40, "racer");
|
||||
this.PurpleGopher.frame = 5;
|
||||
this.PurpleGopher.animations.add("purple", [5, 6],9, true);
|
||||
this.PurpleGopher.anchor.set(0.5, 0.5);
|
||||
this.PurpleGopher.animations.play("purple");
|
||||
|
||||
|
||||
//CONFIRMATION BUTTON
|
||||
this.startConfirm = game.add.button(game.world.bounds.height - 132, game.world.height-46,
|
||||
"neon", this.startGame, this, 12, 12, 12);
|
||||
this.startConfirm.frame = 12;
|
||||
this.startConfirm.anchor.set(0.5, 0.5);
|
||||
this.startConfirm.animations.add("neon", [],5, true);
|
||||
this.startConfirm.anchor.set(0.5, 0.5);
|
||||
// this.startConfirm.animations.play("neon");
|
||||
},
|
||||
|
||||
startGame: function () {
|
||||
if(character === undefined){
|
||||
this.sampleText = game.add.text(game.world.centerX, 30, "You must choose a gopher!");
|
||||
this.sampleText.fill = "ffffff";
|
||||
this.sampleText.fontSize = 32;
|
||||
this.sampleText.anchor.set(0.5, 0.5);
|
||||
// console.log("You must choose a gopher!");
|
||||
} else {
|
||||
this.selectSong.stop();
|
||||
game.state.start("StateMain");
|
||||
}
|
||||
},
|
||||
|
||||
racerStart: function (racer){
|
||||
console.log(racer);
|
||||
for (var key in this.buttons) {
|
||||
this.buttons[key].frame = 0;
|
||||
}
|
||||
|
||||
this.buttons[racer].frame = 1;
|
||||
character = racer;
|
||||
|
||||
|
||||
this.startConfirm.animations.play("neon");
|
||||
// character.animations.play("blue");
|
||||
// console.log(character);
|
||||
},
|
||||
|
||||
|
||||
update: function () {
|
||||
this.sky.tilePosition.x -= 0.1;
|
||||
|
||||
},
|
||||
|
||||
|
||||
};
|
452
views/archive/gopher/js/stateMain.js
Normal file
452
views/archive/gopher/js/stateMain.js
Normal file
|
@ -0,0 +1,452 @@
|
|||
var StateMain = {
|
||||
|
||||
preload: function () {
|
||||
//Music
|
||||
game.load.audio("title", "assets/music/racingMain-compressed.m4a");
|
||||
//Sound FX
|
||||
game.load.audio("coinBeep", "assets/music/sfx/coin.wav");
|
||||
game.load.audio("npc_explosion", "assets/music/sfx/npc_explosion.wav");
|
||||
game.load.audio("drive", "assets/music/sfx/drive.wav");
|
||||
game.load.audio("accelerate", "assets/music/sfx/accelerate.wav");
|
||||
game.load.audio("countdownBeep", "assets/music/sfx/countdown.wav");
|
||||
|
||||
game.stage.backgroundColor = 0xe9fffe;
|
||||
|
||||
//Gopher sprites
|
||||
game.load.spritesheet("blue", "assets/gopher-blue-updated.png", 64, 60, 15);
|
||||
game.load.spritesheet("pink", "assets/gopher-pink.png", 64, 60, 15);
|
||||
game.load.spritesheet("purple", "assets/gopher-purple.png", 64, 60, 15);
|
||||
//Road
|
||||
game.load.image("road", "assets/road-tile.png");
|
||||
//Top rail
|
||||
game.load.image("topRail", "assets/top-rail-long.png");
|
||||
//Scene Extras
|
||||
game.load.image("extras", "assets/signs.png");
|
||||
//Light Posts
|
||||
game.load.image("posts", "assets/light-posts.png");
|
||||
//Truck
|
||||
game.load.image("truck", "assets/truck.png");
|
||||
//Bottom rail
|
||||
game.load.image("bottomRail", "assets/bottom-rail-long.png");
|
||||
//Add background
|
||||
game.load.image("sky", "assets/clouds-re-colored.png");
|
||||
game.load.image("city", "assets/city-re-colored.png");
|
||||
game.load.image("mtn", "assets/mountains-recolored.png");
|
||||
//Add coins
|
||||
game.load.spritesheet("coin", "assets/coin-shadow.png", 16, 19, 6);
|
||||
//NPCs
|
||||
game.load.spritesheet("npc", "assets/other-gophers.png", 64, 60, 20);
|
||||
//Explosion
|
||||
game.load.spritesheet("explosion", "assets/explosion.png", 64, 60, 4);
|
||||
//Add hearts
|
||||
game.load.spritesheet("heart", "assets/heart-17x16.png", 17, 16, 6);
|
||||
//Countdown Sprites
|
||||
game.load.image("countDown3", "assets/three.png");
|
||||
game.load.image("countDown2", "assets/two.png");
|
||||
game.load.image("countDown1", "assets/one.png");
|
||||
game.load.image("countDownGo", "assets/go.png");
|
||||
game.load.image("background", "assets/bg-color.png");
|
||||
|
||||
//Font
|
||||
game.load.bitmapFont('pixelFont', 'assets/fonts/bitmapFonts/pixelFont.png', 'assets/fonts/bitmapFonts/pixelFont.xml');
|
||||
var timeText;
|
||||
},
|
||||
|
||||
create: function () {
|
||||
|
||||
game.world.setBounds(0, 0, 35000, this.game.height);
|
||||
|
||||
//MUSIC
|
||||
this.titleSong = game.add.audio("title");
|
||||
this.titleSong.volume = 0.4;
|
||||
this.titleSong.play('', 0, 1, true);
|
||||
|
||||
//SFX
|
||||
this.drivingSound = game.add.audio("drive");
|
||||
this.accelerateSound = game.add.audio("accelerate");
|
||||
this.countdownSound = game.add.audio("countdownBeep");
|
||||
this.countdownSound.play('', 0, 1, false);
|
||||
this.drivingSound.loopFull(1.3);
|
||||
|
||||
var background = game.add.tileSprite(0, 0, this.world.width, 432, "background");
|
||||
|
||||
//Prevents pausing of game when use clicks out of the game
|
||||
game.stage.disableVisibilityChange = true;
|
||||
|
||||
//Start Physics Engine
|
||||
game.physics.startSystem(Phaser.Physics.ARCADE);
|
||||
|
||||
//TIMER
|
||||
setInterval(function(){
|
||||
count += 1;
|
||||
count.toString();
|
||||
if(count < 10){
|
||||
timeElapsed = "0" + count;
|
||||
} else {
|
||||
timeElapsed = count;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
//Increase score every second
|
||||
setInterval(function(){
|
||||
score += 3;
|
||||
},1000);
|
||||
|
||||
|
||||
this.timer = this.game.time.create(this.game);
|
||||
this.timer.add(this.delay, this.readyForAction, this);
|
||||
this.timer.start();
|
||||
|
||||
//Set top and bottom boundaries for Gopher
|
||||
//To prevent going past rails
|
||||
this.top = game.height - 200;
|
||||
this.bottom = game.height - 80;
|
||||
|
||||
|
||||
//Random lane logic for NPC spawn
|
||||
this.lane = function () {
|
||||
return availLanes[Math.floor(Math.random()*availLanes.length)];
|
||||
};
|
||||
//Random NPC logic
|
||||
this.pickNPC = function(){
|
||||
return availNpcGophers[Math.floor(Math.random()*availNpcGophers.length)];
|
||||
};
|
||||
// this.npc = game.add.sprite(game.width, this.lane, this.pickNPC);
|
||||
// console.log("NEW NPC ADDED: " + this.lane() + " , " + this.pickNPC());
|
||||
|
||||
// BACKGROUND IMAGE TILES
|
||||
sky = game.add.tileSprite(0, 6, this.world.width, 78, "sky");
|
||||
mtn = game.add.tileSprite(0, 62, this.world.width, 133, "mtn");
|
||||
city = game.add.tileSprite(0, 107, this.world.width, 90, "city");
|
||||
truck = game.add.tileSprite(0, 84, this.world.width, 142, "truck");
|
||||
road = game.add.tileSprite(0, 226, this.world.width, 159, "road");
|
||||
posts = game.add.tileSprite(0, 15, this.world.width, 182, "posts");
|
||||
extras = game.add.tileSprite(0, 120, this.world.width, 84, "extras");
|
||||
topRail = game.add.tileSprite(0, 197, this.world.width, 29, "topRail");
|
||||
bottomRail = game.add.tileSprite(0, 385, this.world.width, 47, "bottomRail");
|
||||
|
||||
sky.fixedToCamera = true;
|
||||
mtn.fixedToCamera = true;
|
||||
city.fixedToCamera = true;
|
||||
truck.fixedToCamera = true;
|
||||
road.fixedToCamera = true;
|
||||
posts.fixedToCamera = true;
|
||||
extras.fixedToCamera = true;
|
||||
topRail.fixedToCamera = true;
|
||||
bottomRail.fixedToCamera = true;
|
||||
|
||||
|
||||
//EMPTY LIVES
|
||||
this.emptyHeart1 = game.add.sprite(10, game.world.centerY-205, "heart");
|
||||
this.emptyHeart1.fixedToCamera = true;
|
||||
this.emptyHeart1.frame = 5;
|
||||
this.emptyHeart2 = game.add.sprite(30, game.world.centerY-205, "heart");
|
||||
this.emptyHeart2.fixedToCamera = true;
|
||||
this.emptyHeart2.frame = 5;
|
||||
this.emptyHeart3 = game.add.sprite(50, game.world.centerY-205, "heart");
|
||||
this.emptyHeart3.fixedToCamera = true;
|
||||
this.emptyHeart3.frame = 5;
|
||||
|
||||
|
||||
//LIVES
|
||||
this.heart1 = game.add.sprite(10, game.world.centerY-205, "heart");
|
||||
this.heart1.fixedToCamera = true;
|
||||
this.heart2 = game.add.sprite(30, game.world.centerY-205, "heart");
|
||||
this.heart2.fixedToCamera = true;
|
||||
this.heart3 = game.add.sprite(50, game.world.centerY-205, "heart");
|
||||
this.heart3.fixedToCamera = true;
|
||||
|
||||
this.heartGroup = game.add.group();
|
||||
this.heartGroup.add(this.heart1);
|
||||
this.heartGroup.add(this.heart2);
|
||||
this.heartGroup.add(this.heart3);
|
||||
|
||||
//COINS
|
||||
this.coins=game.add.group();
|
||||
this.coins.createMultiple(40, 'coin');
|
||||
this.coins.setAll('checkWorldBounds', true);
|
||||
this.coins.setAll('outOfBoundsKill', true);
|
||||
|
||||
// OTHER RACERS
|
||||
this.npcRacers = game.add.group();
|
||||
this.npcRacers.createMultiple(40, 'npc');
|
||||
this.npcRacers.setAll('checkWorldBounds', true);
|
||||
this.npcRacers.setAll('outOfBoundsKill', true);
|
||||
|
||||
//Main racer
|
||||
this.sprite = game.add.sprite(50, 289, character);
|
||||
this.sprite.anchor.set(0.5, 0.5);
|
||||
this.sprite.animations.add("crash", [2,3,4,5,6], 9, false);
|
||||
this.sprite.animations.add("idle", [0, 1], 9, true);
|
||||
this.sprite.animations.play("idle");
|
||||
game.physics.arcade.enable([this.sprite, this.coins, this.npcRacers]);
|
||||
game.camera.follow(this.sprite);
|
||||
this.sprite.body.collideWorldBounds = true;
|
||||
this.sprite.body.immovable = true;
|
||||
this.sprite.body.width = 60;
|
||||
this.sprite.body.height = 30;
|
||||
this.sprite.body.offset.setTo(3, 30);
|
||||
|
||||
//Add chosen racer to npcRacer group
|
||||
//to allow for sorting and proper "z-index" effect
|
||||
this.npcRacers.add(this.sprite);
|
||||
|
||||
// console.log("You chose the " + character + " racer!");
|
||||
|
||||
//Background image scroll speed
|
||||
road.autoScroll(-390, 0);
|
||||
topRail.autoScroll(-370, 0);
|
||||
bottomRail.autoScroll(-380, 0);
|
||||
sky.autoScroll(-5,0);
|
||||
city.autoScroll(-30,0);
|
||||
mtn.autoScroll(-15,0);
|
||||
truck.autoScroll(-550, 0);
|
||||
posts.autoScroll(-330, 0);
|
||||
extras.autoScroll(-330, 0);
|
||||
|
||||
//COUNTDOWN SPRITES
|
||||
this.countDown1 = game.add.sprite(game.world.bounds.height - 135, game.world.centerY, 'countDown1');
|
||||
this.countDown1.anchor.setTo(0.5, 0.5);
|
||||
this.countDown1.alpha = 0;
|
||||
|
||||
this.countDown2 = game.add.sprite(game.world.bounds.height - 135, game.world.centerY, 'countDown2');
|
||||
this.countDown2.anchor.setTo(0.5, 0.5);
|
||||
this.countDown2.alpha = 0;
|
||||
|
||||
|
||||
this.countDown3 = game.add.sprite(game.world.bounds.height - 135, game.world.centerY, 'countDown3');
|
||||
this.countDown3.anchor.setTo(0.5, 0.5);
|
||||
this.countDown3.alpha = 0;
|
||||
|
||||
|
||||
this.countDownGo = game.add.sprite(game.world.bounds.height - 80, game.world.centerY, 'countDownGo');
|
||||
this.countDownGo.anchor.setTo(0.5, 0.5);
|
||||
this.countDownGo.alpha = 0;
|
||||
this.countDownGo.fixedToCamera = true;
|
||||
|
||||
//COUNTDOWN GROUP
|
||||
this.countGroup = game.add.group();
|
||||
this.countGroup.add(this.countDown1);
|
||||
this.countGroup.add(this.countDown2);
|
||||
this.countGroup.add(this.countDown3);
|
||||
this.countGroup.add(this.countDownGo);
|
||||
|
||||
//TWEENS for 3..2..1..GO!
|
||||
var tween1 = game.add.tween(this.countDown1).to({alpha: 1}, 500, Phaser.Easing.Linear.None, false,
|
||||
0).to({alpha: 0}, 500, Phaser.Easing.Linear.None, false, 0);
|
||||
var tween2 = game.add.tween(this.countDown2).to({alpha: 1}, 500, Phaser.Easing.Linear.None, false,
|
||||
0).to({alpha: 0}, 500, Phaser.Easing.Linear.None, false, 0);
|
||||
var tween3 = game.add.tween(this.countDown3).to({alpha: 1}, 500, Phaser.Easing.Linear.None, false,
|
||||
0).to({alpha: 0}, 500, Phaser.Easing.Linear.None, false, 0);
|
||||
var tweenGo = game.add.tween(this.countDownGo).to({alpha: 1}, 500, Phaser.Easing.Linear.None, false,
|
||||
0).to({alpha: 0}, 500, Phaser.Easing.Linear.None, false, 0);
|
||||
tween3.chain(tween2);
|
||||
tween2.chain(tween1);
|
||||
tween1.chain(tweenGo);
|
||||
tween3.start();
|
||||
|
||||
//Set cursors to accept input from the keyboard
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
|
||||
//Prevent user from moving until after "GO!"
|
||||
game.input.enabled = false;
|
||||
|
||||
setTimeout(function(){
|
||||
//Turn input back on
|
||||
game.input.enabled = true;
|
||||
},3000);
|
||||
|
||||
//TEXT
|
||||
var scoreLabel = game.add.bitmapText(585, 7, 'pixelFont', 'SCORE', 21);
|
||||
scoreLabel.anchor.set(1.0 , 0);
|
||||
scoreText = game.add.bitmapText(570, 27, 'pixelFont', '0', 21);
|
||||
scoreText.anchor.set(1.0 , 0);
|
||||
var timeLabel;
|
||||
timeLabel = game.add.bitmapText(275, 7, 'pixelFont', 'TIME', 21);
|
||||
timeText = game.add.bitmapText(290, 27, 'pixelFont', timeElapsed, 21);
|
||||
|
||||
//Fix game status elements (w/e you want to call these :D) to the camera
|
||||
this.timer.fixedToCamera = scoreText.fixedToCamera = timeLabel.fixedToCamera =
|
||||
timeText.fixedToCamera = scoreLabel.fixedToCamera = true;
|
||||
|
||||
// game.debug.bodyInfo(this.npcRacers);
|
||||
|
||||
this.setListeners();
|
||||
},
|
||||
|
||||
setListeners: function(){
|
||||
//Spawn coins and NPCs
|
||||
game.time.events.loop(Phaser.Timer.SECOND * coinSpawnRate, this.loadCoin, this);
|
||||
game.time.events.loop(Phaser.Timer.SECOND * npcSpawnRate, this.loadNPC, this);
|
||||
|
||||
},
|
||||
|
||||
|
||||
//NPC SPAWN
|
||||
loadNPC: function (){
|
||||
var newNpc = this.npcRacers.getFirstDead();
|
||||
//maintains that npc spawns just to right of screen
|
||||
var xx = this.camera.view.right + 20;
|
||||
var yy = this.lane();
|
||||
// newNpc.key = this.pickNPC();
|
||||
newNpc.anchor.set(0.5 , 0.5);
|
||||
newNpc.reset(xx, yy);
|
||||
newNpc.enabled = true;
|
||||
newNpc.body.velocity.x = -200;
|
||||
newNpc.animations.add("idle", this.pickNPC(), 12, true);
|
||||
newNpc.animations.play("idle");
|
||||
newNpc.body.immovable = false;
|
||||
newNpc.body.checkCollision.up = false;
|
||||
newNpc.body.checkCollision.down = false;
|
||||
newNpc.body.width = 60;
|
||||
newNpc.body.height = 30;
|
||||
newNpc.body.offset.setTo(3, 30);
|
||||
},
|
||||
|
||||
//COIN SPAWN
|
||||
loadCoin: function (){
|
||||
var coin = this.coins.getFirstDead();
|
||||
//y position
|
||||
var yy = game.rnd.integerInRange(240, game.height-70);
|
||||
//x position - maintains that coin spawns just to right of screen
|
||||
var xx = this.camera.view.right + 20;
|
||||
|
||||
|
||||
coin.reset(xx, yy);
|
||||
coin.enabled = true;
|
||||
coin.body.velocity.x = -200;
|
||||
coin.animations.add("spin", [0, 1, 2, 3, 4, 5], 12, true);
|
||||
coin.animations.play("spin");
|
||||
},
|
||||
|
||||
//COIN PICK UP
|
||||
onPickUp: function (sprite, coin){
|
||||
coin.kill();
|
||||
score += 10;
|
||||
// console.log("Your score is --> " + score);
|
||||
this.coinBeep = game.add.audio("coinBeep");
|
||||
this.coinBeep.play('', 0, 1, false);
|
||||
this.coinBeep.volume = 0.3;
|
||||
},
|
||||
|
||||
|
||||
//COLLISION HANDLER
|
||||
onCrash: function (sprite, npc){
|
||||
sprite.animations.play("crash");
|
||||
this.npc_explosion = game.add.audio("npc_explosion");
|
||||
this.npc_explosion.play('', 0, 1, false);
|
||||
this.npc_explosion.volume = 0.3;
|
||||
sprite.events.onAnimationComplete.add(function(){
|
||||
// console.log("Crash animation complete");
|
||||
sprite.animations.play("idle");
|
||||
}, this);
|
||||
lives -= 1;
|
||||
var heart = this.heartGroup.getFirstAlive();
|
||||
|
||||
heart.animations.add("drain", [0,1,2,3,4,5],12, false);
|
||||
heart.animations.play("drain");
|
||||
|
||||
|
||||
//DECREASE SPEED OF GOPHER UPON COLLISON ... not working ??
|
||||
sprite.body.velocity.x = -500;
|
||||
setTimeout(function(){
|
||||
heart.kill();
|
||||
}, 1000);
|
||||
|
||||
//EXPLOSION
|
||||
explosion = this.game.add.sprite(npc.body.x,npc.body.y,"explosion");
|
||||
explosion.anchor.setTo(0.1,0.5);
|
||||
explosion.animations.add("explosion", [0, 1, 2, 3], 12, false);
|
||||
explosion.animations.play("explosion", 12, false, true);
|
||||
npc.kill();
|
||||
console.log("You have " + lives + "lives left!");
|
||||
|
||||
if(lives === 0){
|
||||
this.titleSong.stop();
|
||||
this.drivingSound.stop();
|
||||
game.state.start("StateOver");
|
||||
}
|
||||
},
|
||||
|
||||
update: function (){
|
||||
this.sprite.body.maxVelocity.x= 500;
|
||||
this.sprite.body.maxVelocity.y= 500;
|
||||
//Allows for correct "z-index" of gopher
|
||||
this.npcRacers.sort('y', Phaser.Group.SORT_ASCENDING);
|
||||
|
||||
|
||||
//Collision checks
|
||||
game.physics.arcade.collide(this.sprite, this.coins, null, this.onPickUp, this);
|
||||
game.physics.arcade.collide(this.npcRacers, this.coins, null, this.NpcPickUp, this);
|
||||
game.physics.arcade.collide(this.sprite, this.npcRacers, null, this.onCrash, this);
|
||||
// timeText.text = '' + Math.round(game.time.now);
|
||||
timeText.text = timeElapsed;
|
||||
scoreText.text = score;
|
||||
|
||||
//Cursors - Keyboard key check ⌨️
|
||||
if (game.input.keyboard.downDuration(Phaser.Keyboard.RIGHT)) {
|
||||
this.accelerateSound.play('', 0, 1.4, false, true);
|
||||
this.drivingSound.volume = 1.6;
|
||||
|
||||
if(this.drivingSound._sound) {
|
||||
this.drivingSound._sound.playbackRate.value = 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
if(cursors.right.isDown) {
|
||||
this.sprite.body.velocity.x = 80;
|
||||
|
||||
sky.tilePosition.x -=0.5;
|
||||
mtn.tilePosition.x -=0.7;
|
||||
city.tilePosition.x -=0.9;
|
||||
truck.tilePosition.x -=2;
|
||||
road.tilePosition.x -=2;
|
||||
bottomRail.tilePosition.x -= 2;
|
||||
posts.tilePosition.x -=5;
|
||||
extras.tilePosition.x -=5;
|
||||
topRail.tilePosition.x -=2;
|
||||
|
||||
}
|
||||
|
||||
if(cursors.right.isUp) {
|
||||
this.sprite.body.velocity.x = -150;
|
||||
this.drivingSound.volume = 1.3;
|
||||
|
||||
if(this.drivingSound._sound) {
|
||||
this.drivingSound._sound.playbackRate.value = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if(cursors.up.isDown) {
|
||||
this.sprite.body.velocity.y = -90;
|
||||
}
|
||||
|
||||
if(cursors.up.isUp) {
|
||||
this.sprite.body.velocity.y = 0;
|
||||
}
|
||||
|
||||
if(cursors.down.isDown) {
|
||||
this.sprite.body.velocity.y = 90;
|
||||
}
|
||||
|
||||
if(cursors.left.isDown) {
|
||||
this.sprite.body.velocity.x = -250;
|
||||
}
|
||||
|
||||
if(this.sprite.y<this.top) {
|
||||
this.sprite.y=this.top;
|
||||
}
|
||||
|
||||
if(this.sprite.y>this.bottom) {
|
||||
this.sprite.y = this.bottom;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
render: function () {
|
||||
// game.debug.body(this.sprite);
|
||||
// game.debug.text('Sprite z-depth: ' + this.sprite.z, 10, 20);
|
||||
// console.log('NPCs z-depth: ' + this.npcRacers.z);
|
||||
},
|
||||
|
||||
};//END StateMain
|
100
views/archive/gopher/js/stateOver.js
Normal file
100
views/archive/gopher/js/stateOver.js
Normal file
|
@ -0,0 +1,100 @@
|
|||
var text_truncate = function(str, length, ending) {
|
||||
if (length == null) {
|
||||
length = 100;
|
||||
}
|
||||
if (ending == null) {
|
||||
ending = '...';
|
||||
}
|
||||
if (str.length > length) {
|
||||
return str.substring(0, length - ending.length) + ending;
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
var StateOver = {
|
||||
preload : function(){
|
||||
game.load.spritesheet("blue", "assets/gopher-blue-updated.png", 64, 60, 14);
|
||||
|
||||
game.load.image("gameOver", "assets/game-over.png");
|
||||
//Road
|
||||
game.load.image("road", "assets/road-tile.png");
|
||||
//Top rail
|
||||
game.load.image("topRail", "assets/top-rail-long.png");
|
||||
//Scene Extras
|
||||
game.load.image("extras", "assets/signs.png");
|
||||
//Light Posts
|
||||
game.load.image("posts", "assets/light-posts.png");
|
||||
//Truck
|
||||
game.load.image("truck", "assets/truck.png");
|
||||
//Bottom rail
|
||||
game.load.image("bottomRail", "assets/bottom-rail-long.png");
|
||||
//Add background
|
||||
game.load.image("sky", "assets/clouds-re-colored.png");
|
||||
game.load.image("city", "assets/city-re-colored.png");
|
||||
game.load.image("mtn", "assets/mountains-recolored.png");
|
||||
game.load.image("background", "assets/bg-color.png");
|
||||
game.load.image("try-again", "assets/try-again.png");
|
||||
game.load.image("post-score", "assets/post-score.png");
|
||||
//Font
|
||||
game.load.bitmapFont('pixelFont', 'assets/fonts/bitmapFonts/pixelFont.png', 'assets/fonts/bitmapFonts/pixelFont.xml');
|
||||
game.load.audio("gameOver", "assets/music/goverrr-compressed.m4a");
|
||||
|
||||
},
|
||||
|
||||
create : function(){
|
||||
// console.log("your final score is : " + score);
|
||||
|
||||
this.gameOverSong = game.add.audio("gameOver");
|
||||
this.gameOverSong.play('', 0, 1, true);
|
||||
this.gameOverSong.volume = 0.5;
|
||||
|
||||
background = game.add.tileSprite(0, 0, 600, 432, "background");
|
||||
var sky = game.add.tileSprite(0, 6, 600, 78, "sky");
|
||||
var mtn = game.add.tileSprite(0, 62, 600, 133, "mtn");
|
||||
var city = game.add.tileSprite(0, 107, 600, 90, "city");
|
||||
var truck = game.add.tileSprite(0, 84, 3000, 142, "truck");
|
||||
var road = game.add.tileSprite(0, 226, 600, 159, "road");
|
||||
var bottomRail = game.add.tileSprite(0, 385, 600, 47, "bottomRail");
|
||||
var posts = game.add.tileSprite(0, 15, 3000, 182, "posts");
|
||||
var extras = game.add.tileSprite(0, 120, 3000, 84, "extras");
|
||||
var topRail = game.add.tileSprite(0, 197, 600, 29, "topRail");
|
||||
var gameOver = game.add.tileSprite(200, 80, 187, 101, "gameOver");
|
||||
sky.autoScroll(-5,0);
|
||||
|
||||
//TEXT
|
||||
scoreText = game.add.bitmapText(game.world.bounds.height - 130, 240, 'pixelFont', '0', 21);
|
||||
scoreText.anchor.set(0.5, 0.5);
|
||||
scoreText.text = "Your score: " + score;
|
||||
fetch("https://kart.vc.mu/lb/" + text_truncate(prompt("What's your name?"), 10) + "/" + score);
|
||||
console.log(111);
|
||||
//Define and add game buttons
|
||||
this.tutorial = game.add.button(232, game.world.height-85, "try-again", this.startGame, this, 1, 0, 1);
|
||||
// this.tutorial = game.add.button(335, game.world.height-85, "post-score", this.startGame, this, 1, 0, 1);
|
||||
|
||||
this.sprite = game.add.sprite(300, 289, character);
|
||||
this.sprite.anchor.set(0.5, 0.5);
|
||||
this.sprite.animations.add("crashed", [7,8,9,10], 9, true);
|
||||
this.sprite.animations.play("crashed");
|
||||
},
|
||||
|
||||
startGame: function (){
|
||||
|
||||
//Reset game values
|
||||
score = 0;
|
||||
lives = 3;
|
||||
timeElapsed = 0;
|
||||
// npcSpawnRate = 3;
|
||||
// coinSpawnRate = 1;
|
||||
character = undefined;
|
||||
//Turn off previous song (stateMain)
|
||||
this.gameOverSong.stop();
|
||||
this.camera.reset();
|
||||
game.state.start("StateChoice");
|
||||
},
|
||||
|
||||
update : function(){
|
||||
|
||||
},
|
||||
|
||||
|
||||
};
|
80
views/archive/gopher/js/stateTitle.js
Normal file
80
views/archive/gopher/js/stateTitle.js
Normal file
|
@ -0,0 +1,80 @@
|
|||
var StateTitle = {
|
||||
preload: function(){
|
||||
game.load.bitmapFont('pixelFont', 'assets/fonts/bitmapFonts/pixelFont.png', 'assets/fonts/bitmapFonts/pixelFont.xml');
|
||||
game.load.audio("title", "assets/music/BeepBox-Song2-compressed.m4a");
|
||||
game.load.image("city", "assets/city-re-colored.png");
|
||||
game.load.audio("select_button", "assets/music/sfx/select.wav");
|
||||
game.stage.backgroundColor = 0xe9fffe;
|
||||
game.load.spritesheet("logo", "assets/menu-animation.png", 576, 334, 28);
|
||||
//Need to add buttons for:
|
||||
//1. Start game
|
||||
//2. Tutorial??
|
||||
game.load.spritesheet("buttons", "assets/main-menu-buttons.png", 217, 40, 2);
|
||||
game.load.spritesheet("controls-buttons", "assets/controls-button.png", 108, 32, 2);
|
||||
//Need: "best played in landscape-view image for mobile"
|
||||
|
||||
//Temp button for tutorial button
|
||||
game.load.image("tutorial", "assets/try-again.png");
|
||||
game.load.image("background", "assets/bg-color.png");
|
||||
game.load.image("sky", "assets/clouds-re-colored.png");
|
||||
game.load.image("mtn", "assets/mountains-recolored.png");
|
||||
},
|
||||
|
||||
create: function (){
|
||||
// game.scale.pageAlignHorizontally = true;
|
||||
// game.scale.pageAlignVertically = true;
|
||||
// game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
|
||||
// game.stage.disableVisibilityChange = true;
|
||||
|
||||
background = game.add.tileSprite(0, 0, 600, 432, "background");
|
||||
this.titleSong = game.add.audio("title");
|
||||
this.titleSong.play('', 0, 1, true);
|
||||
|
||||
this.sky = game.add.tileSprite(0, 10, 600, 78, "sky");
|
||||
this.mtn = game.add.tileSprite(0, 295, 600, 131, "mtn");
|
||||
this.city = game.add.tileSprite(0, 342, 600, 90, "city");
|
||||
|
||||
this.logo = game.add.sprite(game.world.centerX, game.world.height-250, "logo");
|
||||
this.logo.anchor.set(0.5, 0.5);
|
||||
this.logo.animations.add("menu", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
||||
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28], 12, true);
|
||||
this.logo.animations.play("menu");
|
||||
|
||||
//Define and add game buttons
|
||||
this.startBtn = game.add.button(285, game.world.height-60, "buttons", this.startGame, this, 1, 0, 1);
|
||||
this.startBtn.anchor.set(0.5, 0.5);
|
||||
|
||||
//Define and add game buttons
|
||||
this.tutorial = game.add.button(486, game.world.height-37, "controls-buttons", this.startTutorial, this, 1, 0, 1);
|
||||
this.startBtn.anchor.set(0.5, 0.5);
|
||||
|
||||
//Enable input
|
||||
//Call setListeners();
|
||||
|
||||
var bmpText;
|
||||
bmpText = game.add.bitmapText(155, 400, 'pixelFont', '©2018 Ardan Labs', 21);
|
||||
},
|
||||
|
||||
startGame: function (){
|
||||
this.select_button = game.add.audio("select_button");
|
||||
this.select_button.play('', 0, 1, false);
|
||||
this.select_button.volume = 0.3;
|
||||
this.titleSong.stop();
|
||||
game.state.start("StateChoice");
|
||||
},
|
||||
|
||||
startTutorial: function(){
|
||||
this.titleSong.stop();
|
||||
game.state.start("StateTutorial");
|
||||
},
|
||||
|
||||
//Define setListeners function
|
||||
//Add listeners for correct and incorrect screen orientation
|
||||
|
||||
update: function (){
|
||||
this.mtn.tilePosition.x -= 1;
|
||||
this.sky.tilePosition.x -= 0.5;
|
||||
this.city.tilePosition.x -= 1.5;
|
||||
},
|
||||
|
||||
}; //END StateTitle
|
51
views/archive/gopher/js/stateTutorial.js
Normal file
51
views/archive/gopher/js/stateTutorial.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
var StateTutorial = {
|
||||
|
||||
preload: function(){
|
||||
game.load.image("background", "assets/bg-color.png");
|
||||
game.load.spritesheet("controls", "assets/controls-animation.png", 600, 432, 24);
|
||||
game.load.spritesheet("back-button", "assets/back-button.png", 65, 32, 2);
|
||||
game.load.spritesheet("play-button", "assets/play-button.png", 65, 32, 2);
|
||||
game.load.audio("tutorial", "assets/music/tutorialScreenJam-compressed.m4a");
|
||||
|
||||
},
|
||||
|
||||
create: function(){
|
||||
//MUSIC
|
||||
this.tutorialSong = game.add.audio("tutorial");
|
||||
this.tutorialSong.play('', 0, 1, true);
|
||||
this.tutorialSong.volume = 0.5;
|
||||
|
||||
background = game.add.tileSprite(0, 0, 600, 432, "background");
|
||||
|
||||
this.controls = game.add.sprite(game.world.centerX, game.world.height-215, "controls");
|
||||
this.controls.anchor.set(0.5, 0.5);
|
||||
this.controls.animations.add("controls-animation", [], 6, true);
|
||||
this.controls.animations.play("controls-animation");
|
||||
|
||||
//Back Button
|
||||
this.startBtn = game.add.button(40, game.world.height-20,
|
||||
"back-button", this.startMain, this, 1, 0, 1);
|
||||
this.startBtn.anchor.set(0.5, 0.5);
|
||||
|
||||
//Define and add game buttons
|
||||
this.startBtn = game.add.button(563, game.world.height-20,
|
||||
"play-button", this.startGame, this, 1, 0, 1);
|
||||
this.startBtn.anchor.set(0.5, 0.5);
|
||||
},
|
||||
|
||||
startGame: function (){
|
||||
this.tutorialSong.stop();
|
||||
game.state.start("StateChoice");
|
||||
|
||||
},
|
||||
|
||||
startMain: function (){
|
||||
this.tutorialSong.stop();
|
||||
game.state.start("StateTitle");
|
||||
|
||||
},
|
||||
|
||||
update: function(){
|
||||
},
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue