Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mario map scroller to es6 #381

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 52 additions & 42 deletions public/src/tilemap/mario map scroller.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,65 @@
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'phaser-example',
pixelArt: true,
scene: {
preload: preload,
create: create,
update: update
class Example extends Phaser.Scene
{
constructor ()
{
super();

}
};

var controls;
preload ()
{

var game = new Phaser.Game(config);
this.load.tilemapTiledJSON('map1', 'assets/tilemaps/maps/super-mario.json');
this.load.image('tiles1', 'assets/tilemaps/tiles/super-mario.png');
this.load.tilemapTiledJSON('map3', 'assets/tilemaps/maps/super-mario-3.json');
this.load.image('tiles3', 'assets/tilemaps/tiles/super-mario-3.png');

function preload ()
{
this.load.tilemapTiledJSON('map1', 'assets/tilemaps/maps/super-mario.json');
this.load.image('tiles1', 'assets/tilemaps/tiles/super-mario.png');
}

this.load.tilemapTiledJSON('map3', 'assets/tilemaps/maps/super-mario-3.json');
this.load.image('tiles3', 'assets/tilemaps/tiles/super-mario-3.png');
}
create ()
{

let map1 = this.make.tilemap({key:'map1'});
let tileset1 = map1.addTilesetImage('SuperMarioBros-World1-1','tiles1');
let layer1 = map1.createLayer('World1',tileset1,0,0);

function create ()
{
var map1 = this.make.tilemap({ key: 'map1' });
var tileset1 = map1.addTilesetImage('SuperMarioBros-World1-1', 'tiles1');
var layer1 = map1.createLayer('World1', tileset1, 0, 0);
let map2 = this.add.tilemap('map3');
let tileset2 = map2.addTilesetImage('SuperMarioBrosMap1-3_bank.png', 'tiles3');
let layer2 = map2.createLayer('ShoeBox Tile Grab', tileset2, 700, 300);

var map2 = this.add.tilemap('map3');
var tileset2 = map2.addTilesetImage('SuperMarioBrosMap1-3_bank.png', 'tiles3');
var layer2 = map2.createLayer('ShoeBox Tile Grab', tileset2, 700, 300);
let cursors = this.input.keyboard.createCursorKeys();

var cursors = this.input.keyboard.createCursorKeys();
let controlConfig =

{
camera: this.cameras.main,
left: cursors.left,
right: cursors.right,
speed: 0.5

var controlConfig = {
camera: this.cameras.main,
left: cursors.left,
right: cursors.right,
speed: 0.5
};
}

controls = new Phaser.Cameras.Controls.FixedKeyControl(controlConfig);
this.controls = new Phaser.Cameras.Controls.FixedKeyControl(controlConfig);

this.cameras.main.setBounds(0, 0, layer2.x + layer2.width + 600, 0);

this.cameras.main.setBounds(0, 0, layer2.x + layer2.width + 600, 0);
}
}

function update (time, delta)
{
controls.update(delta);
update (time,delta)
{

this.controls.update(delta);

}
}

const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'phaser-example',
scene: Example
};

const game = new Phaser.Game(config);