Commit 86a6f22e authored by wildfirecode's avatar wildfirecode

1

parent 273206fa
File added
var config = { (function () {
type: Phaser.WEBGL, var config = {
width: 800, type: Phaser.WEBGL,
height: 600, width: 800,
parent: 'phaser-example', height: 600,
pixelArt: true, parent: 'phaser-example',
physics: { pixelArt: true,
default: 'matter', physics: {
matter: { default: 'matter',
gravity: { matter: {
y: 0 gravity: {
}, y: 0
debug: true },
debug: true
}
},
scene: {
create: create,
update: update
} }
}, };
scene: { var controls;
create: create, var game = new Phaser.Game(config);
update: update function create() {
} var worldWidth = 1600;
}; var worldHeight = 1200;
this.matter.world.setBounds(0, 0, worldWidth, worldHeight);
var controls; // Create loads of random bodies
for (var i = 0; i < 100; i++) {
var game = new Phaser.Game(config); var x = Phaser.Math.Between(0, worldWidth);
var y = Phaser.Math.Between(0, worldHeight);
function create () if (Math.random() < 0.7) {
{ var sides = Phaser.Math.Between(3, 14);
var worldWidth = 1600; var radius = Phaser.Math.Between(8, 50);
var worldHeight = 1200; this.matter.add.polygon(x, y, sides, radius, { restitution: 0.9 });
}
this.matter.world.setBounds(0, 0, worldWidth, worldHeight); else {
var width = Phaser.Math.Between(16, 128);
// Create loads of random bodies var height = Phaser.Math.Between(8, 64);
for (var i = 0; i < 100; i++) this.matter.add.rectangle(x, y, width, height, { restitution: 0.9 });
{ }
var x = Phaser.Math.Between(0, worldWidth);
var y = Phaser.Math.Between(0, worldHeight);
if (Math.random() < 0.7)
{
var sides = Phaser.Math.Between(3, 14);
var radius = Phaser.Math.Between(8, 50);
this.matter.add.polygon(x, y, sides, radius, { restitution: 0.9 });
}
else
{
var width = Phaser.Math.Between(16, 128);
var height = Phaser.Math.Between(8, 64);
this.matter.add.rectangle(x, y, width, height, { restitution: 0.9 });
} }
this.matter.add.mouseSpring();
var cursors = this.input.keyboard.createCursorKeys();
var controlConfig = {
camera: this.cameras.main,
left: cursors.left,
right: cursors.right,
up: cursors.up,
down: cursors.down,
zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q),
zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E),
acceleration: 0.06,
drag: 0.0005,
maxSpeed: 1.0
};
controls = new Phaser.Cameras.Controls.Smoothed(controlConfig);
this.input.keyboard.on('KEY_DOWN_Z', function (event) {
this.cameras.main.rotation += 0.01;
}, 0, this);
this.input.keyboard.on('KEY_DOWN_X', function (event) {
this.cameras.main.rotation -= 0.01;
}, 0, this);
var cam = this.cameras.main;
var gui = new dat.GUI();
var p1 = gui.addFolder('Pointer');
p1.add(this.input, 'x').listen();
p1.add(this.input, 'y').listen();
p1.open();
var help = {
line1: 'Cursors to move',
line2: 'Q & E to zoom',
line3: 'Z & X to rotate',
};
var f1 = gui.addFolder('Camera');
f1.add(cam, 'x').listen();
f1.add(cam, 'y').listen();
f1.add(cam, 'scrollX').listen();
f1.add(cam, 'scrollY').listen();
f1.add(cam, 'rotation').min(0).step(0.01).listen();
f1.add(cam, 'zoom', 0.1, 2).step(0.1).listen();
f1.add(help, 'line1');
f1.add(help, 'line2');
f1.add(help, 'line3');
f1.open();
} }
function update(time, delta) {
this.matter.add.mouseSpring(); controls.update(delta);
var cursors = this.input.keyboard.createCursorKeys();
var controlConfig = {
camera: this.cameras.main,
left: cursors.left,
right: cursors.right,
up: cursors.up,
down: cursors.down,
zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q),
zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E),
acceleration: 0.06,
drag: 0.0005,
maxSpeed: 1.0
};
controls = new Phaser.Cameras.Controls.Smoothed(controlConfig);
this.input.keyboard.on('KEY_DOWN_Z', function (event) {
this.cameras.main.rotation += 0.01;
}, 0, this);
this.input.keyboard.on('KEY_DOWN_X', function (event) {
this.cameras.main.rotation -= 0.01;
}, 0, this);
var cam = this.cameras.main;
gui = new dat.GUI();
var p1 = gui.addFolder('Pointer');
p1.add(this.input, 'x').listen();
p1.add(this.input, 'y').listen();
p1.open();
var help = {
line1: 'Cursors to move',
line2: 'Q & E to zoom',
line3: 'Z & X to rotate',
} }
})();
var f1 = gui.addFolder('Camera');
f1.add(cam, 'x').listen();
f1.add(cam, 'y').listen();
f1.add(cam, 'scrollX').listen();
f1.add(cam, 'scrollY').listen();
f1.add(cam, 'rotation').min(0).step(0.01).listen();
f1.add(cam, 'zoom', 0.1, 2).step(0.1).listen();
f1.add(help, 'line1');
f1.add(help, 'line2');
f1.add(help, 'line3');
f1.open();
}
function update (time, delta)
{
controls.update(delta);
}
(function(){
var config = {
type: Phaser.WEBGL,
width: 800,
height: 600,
parent: 'phaser-example',
pixelArt: true,
physics: {
default: 'matter',
matter: {
gravity: {
y: 0
},
debug: true
}
},
scene: {
create: create,
update: update
}
};
var controls;
var game = new Phaser.Game(config);
function create ()
{
var worldWidth = 1600;
var worldHeight = 1200;
this.matter.world.setBounds(0, 0, worldWidth, worldHeight);
// Create loads of random bodies
for (var i = 0; i < 100; i++)
{
var x = Phaser.Math.Between(0, worldWidth);
var y = Phaser.Math.Between(0, worldHeight);
if (Math.random() < 0.7)
{
var sides = Phaser.Math.Between(3, 14);
var radius = Phaser.Math.Between(8, 50);
this.matter.add.polygon(x, y, sides, radius, { restitution: 0.9 });
}
else
{
var width = Phaser.Math.Between(16, 128);
var height = Phaser.Math.Between(8, 64);
this.matter.add.rectangle(x, y, width, height, { restitution: 0.9 });
}
}
this.matter.add.mouseSpring();
var cursors = this.input.keyboard.createCursorKeys();
var controlConfig = {
camera: this.cameras.main,
left: cursors.left,
right: cursors.right,
up: cursors.up,
down: cursors.down,
zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q),
zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E),
acceleration: 0.06,
drag: 0.0005,
maxSpeed: 1.0
};
controls = new Phaser.Cameras.Controls.Smoothed(controlConfig);
this.input.keyboard.on('KEY_DOWN_Z', function (event) {
this.cameras.main.rotation += 0.01;
}, 0, this);
this.input.keyboard.on('KEY_DOWN_X', function (event) {
this.cameras.main.rotation -= 0.01;
}, 0, this);
var cam = this.cameras.main;
var gui = new dat.GUI();
var p1 = gui.addFolder('Pointer');
p1.add(this.input, 'x').listen();
p1.add(this.input, 'y').listen();
p1.open();
var help = {
line1: 'Cursors to move',
line2: 'Q & E to zoom',
line3: 'Z & X to rotate',
}
var f1 = gui.addFolder('Camera');
f1.add(cam, 'x').listen();
f1.add(cam, 'y').listen();
f1.add(cam, 'scrollX').listen();
f1.add(cam, 'scrollY').listen();
f1.add(cam, 'rotation').min(0).step(0.01).listen();
f1.add(cam, 'zoom', 0.1, 2).step(0.1).listen();
f1.add(help, 'line1');
f1.add(help, 'line2');
f1.add(help, 'line3');
f1.open();
}
function update (time, delta)
{
controls.update(delta);
}
})();
\ No newline at end of file
var config = { (function () {
type: Phaser.AUTO, var config = {
width: 800, type: Phaser.AUTO,
height: 600, width: 800,
backgroundColor: '#1b1464', height: 600,
parent: 'phaser-example', backgroundColor: '#1b1464',
physics: { parent: 'phaser-example',
default: 'matter', physics: {
matter: { default: 'matter',
debug: true, matter: {
gravity: { debug: true,
y: 0.3 gravity: {
}, y: 0.3
},
}
},
scene: {
preload: preload,
create: create
} }
}, };
scene: { var game = new Phaser.Game(config);
preload: preload, function preload() {
create: create this.load.image('platform', 'assets/sprites/platform.png');
} }
}; function create() {
var text = this.add.text(100, 0, 'Phaser 3', { font: '32px Arial', fill: '#00ff00' });
var game = new Phaser.Game(config); var text2 = this.add.text(100, -100, 'Phaser 3', { font: '32px Arial', fill: '#ffff00' });
var matterText = this.matter.add.gameObject(text, { shape: { type: 'polygon', sides: 8, radius: 64 } }).setFrictionAir(0.001).setBounce(0.9);
function preload () var matterText2 = this.matter.add.gameObject(text2).setFrictionAir(0.001).setBounce(0.9);
{ this.matter.add.image(350, 450, 'platform', null, { isStatic: true }).setScale(2, 0.5).setAngle(10);
this.load.image('platform', 'assets/sprites/platform.png'); }
} })();
function create ()
{
var text = this.add.text(100, 0, 'Phaser 3', { font: '32px Arial', fill: '#00ff00' });
var text2 = this.add.text(100, -100, 'Phaser 3', { font: '32px Arial', fill: '#ffff00' });
var matterText = this.matter.add.gameObject(text, { shape: { type: 'polygon', sides: 8, radius: 64 } }).setFrictionAir(0.001).setBounce(0.9);
var matterText2 = this.matter.add.gameObject(text2).setFrictionAir(0.001).setBounce(0.9);
this.matter.add.image(350, 450, 'platform', null, { isStatic: true }).setScale(2, 0.5).setAngle(10);
}
(function () {
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#1b1464',
parent: 'phaser-example',
physics: {
default: 'matter',
matter: {
debug: true,
gravity: {
y: 0.3
},
}
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload() {
this.load.image('platform', 'assets/sprites/platform.png');
}
function create() {
var text = this.add.text(100, 0, 'Phaser 3', { font: '32px Arial', fill: '#00ff00' });
var text2 = this.add.text(100, -100, 'Phaser 3', { font: '32px Arial', fill: '#ffff00' });
var matterText = this.matter.add.gameObject(text, { shape: { type: 'polygon', sides: 8, radius: 64 } }).setFrictionAir(0.001).setBounce(0.9);
var matterText2 = this.matter.add.gameObject(text2).setFrictionAir(0.001).setBounce(0.9);
this.matter.add.image(350, 450, 'platform', null, { isStatic: true }).setScale(2, 0.5).setAngle(10);
}
})();
\ No newline at end of file
declare var dat
\ No newline at end of file
This diff is collapsed.
{
"compilerOptions": {
"target": "es5",
"module": "none",
"skipLibCheck": true
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment