Path: blob/main/public/games/files/gopher-kart/js/app.js
1036 views
// var mainState = {1// preload: function () {2// game.load.spritesheet('car', '../assets/gopher-drive-loop.png', 63, 59, 2);3// game.load.image('railBot', '../assets/bottom-rail.png');4// game.load.image('road', '../assets/road-tile.png');5// game.stage.smoothed = false;6// },7//8// create: function () {9// game.stage.backgroundColor = '#72c5cf';10//11// //1st num indicates the starting x tilePosition12// //2nd num indicates the starting y tilePosition13// //3rd num indicates the x (length) of repetition14// //4th num indicates the y (height) of repetition15// this.railBot = game.add.tileSprite(0, 385, 600, 0, 'railBot');16//17// game.physics.startSystem(Phaser.Physics.ARCADE);18//19// this.car = game.add.sprite(30, 280, "car");20//21// this.car.animations.add('drive', [0,1], 8, true);22//23// this.car.animations.play('drive');24//25// // this.car = game.add.sprite(30, 280, 'car');26//27// this.physics.arcade.enable(this.car);28//29// // this.car.anchor.setTo(-0.2, 0.5);30//31// this.car.body.collideWorldBounds = true;32//33// cursors = game.input.keyboard.createCursorKeys();34//35// // this.timer = game.time.events.loop(100, this.addRowOfRoads, this);36//37// this.road = game.add.group();38// },39//40// update: function () {41// this.railBot.tilePosition.x = 0.5;42//43// this.car.body.velocity.x = 0;44//45// if(cursors.right.isDown){46// this.car.body.velocity.x = 100;47// }48//49// else if (cursors.left.isDown){50// this.car.body.velocity.x = -300;51// }52//53// else if (cursors.right.isDown && this.car.body.y < this.window) {54// this.car.body.velocity.x = 0;55// }56// },57//58// addOneRoad: function(x, y){59// var road = game.add.sprite(x, y, 'road');60//61// this.road.add(road);62//63// game.physics.arcade.enable(road);64//65// road.body.velocity.x = -300;66//67// road.checkWorldBounds = true;68// road.outOfBoundsKill = true;69// },70//71// addRowOfRoads: function(){72// this.addOneRoad(600, 220);73// },74//75// };76//77// var game = new Phaser.Game(600, 432, Phaser.AUTO, 'ld29', null, false, false);78//79// game.state.add('main', mainState);80//81// game.state.start('main');828384