And we have level/ground jitter fixed :) Starstruck is running again properly now too. Time to commit and remove lots of debug data.

This commit is contained in:
photonstorm
2014-02-05 16:54:58 +00:00
parent 84f0f00f49
commit 1af86771ba
7 changed files with 401 additions and 66 deletions
+20 -4
View File
@@ -25,6 +25,17 @@ var bg;
function create() {
$('#step').click(function(){
console.log('---- STEP', game.stepCount, '-------------------------------');
game.step();
});
$('#start').click(function(){
console.log('---- START DEBUGGING -------------------------------');
game.enableStep();
player.debug = true;
});
game.stage.backgroundColor = '#000000';
bg = game.add.tileSprite(0, 0, 800, 600, 'background');
@@ -43,12 +54,14 @@ function create() {
layer.resizeWorld();
game.physics.gravity.y = 260;
game.physics.gravity.y = 250;
game.physics.setBoundsToWorld();
player = game.add.sprite(32, 32, 'dude');
player.body.bounce.y = 0.2;
player.body.minVelocity.y = 5;
player.body.collideWorldBounds = true;
player.body.setSize(16, 32, 8, 16);
player.body.setRectangle(16, 32, 8, 16);
player.animations.add('left', [0, 1, 2, 3], 10, true);
player.animations.add('turn', [4], 20, true);
@@ -106,8 +119,10 @@ function update() {
}
}
if (jumpButton.isDown && player.body.touching.down && game.time.now > jumpTimer)
// if (jumpButton.isDown && player.body.touching.down && game.time.now > jumpTimer)
if (jumpButton.isDown && player.body.onFloor() && game.time.now > jumpTimer)
{
console.log('jump');
player.body.velocity.y = -250;
jumpTimer = game.time.now + 750;
}
@@ -116,6 +131,7 @@ function update() {
function render () {
// game.debug.renderSpriteBody(player);
game.debug.renderPhysicsBody(player.body);
game.debug.renderBodyInfo(player, 16, 24);
}
+1
View File
@@ -101,6 +101,7 @@
<div id="phaser-example"></div>
<input type="button" id="step" value="step" />
<input type="button" id="start" value="start" style="margin-left: 32px" />
<h2>work in progress examples</h2>
+334
View File
@@ -0,0 +1,334 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.spritesheet('gameboy', 'assets/sprites/gameboy_seize_color_40x60.png', 40, 60);
game.load.image('atari', 'assets/sprites/atari130xe.png');
}
var sprite;
var sprite2;
var sprite3;
var reverse = false;
function onBeginContact(a, b) {
console.log('Begin Contact between', a.name, 'and', b.name);
}
function onEndContact(a, b) {
console.log('End Contact between', a.name, 'and', b.name);
}
function create() {
game.stage.backgroundColor = '#124184';
test8();
}
function test8() {
$('#step').click(function(){
console.log('---- STEP', game.stepCount, '-------------------------------');
game.step();
});
game.physics.gravity.y = 200;
sprite = game.add.sprite(300, 300, 'atari');
sprite.name = 'atari';
sprite.body.collideWorldBounds = true;
sprite.body.bounce.setTo(0.2, 0.2);
sprite.body.minVelocity.setTo(5, 5);
sprite2 = game.add.sprite(350, 150, 'gameboy', 2);
sprite2.name = 'gameboy';
sprite2.body.collideWorldBounds = true;
sprite2.body.bounce.setTo(0.8, 0.8);
// sprite2.body.minVelocity.setTo(30, 30);
// sprite.debug = true;
// game.enableStep();
sprite2.events.onBeginContact.add(onBeginContact, this);
sprite2.events.onEndContact.add(onEndContact, this);
reverse = true;
// game.input.onDown.add(launch8, this);
}
function launch8() {
sprite2.body.velocity.x = -100;
sprite2.body.velocity.y = -200;
}
function test7() {
// A down into B
sprite = game.add.sprite(300, 400, 'atari');
sprite.name = 'atari';
sprite.body.collideWorldBounds = true;
sprite.body.bounce.setTo(1, 1);
sprite.body.checkCollision.up = false;
sprite2 = game.add.sprite(350, 100, 'gameboy', 2);
sprite2.name = 'gameboy';
sprite2.body.collideWorldBounds = true;
sprite2.body.bounce.setTo(1, 1);
// reverse = true;
game.input.onDown.add(launch7, this);
}
function launch7() {
sprite2.body.velocity.y = 100;
}
function test6() {
// Offset Down Collision false
sprite = game.add.sprite(100, 300, 'atari');
sprite.name = 'atari';
sprite.body.collideWorldBounds = true;
sprite.body.bounce.setTo(1, 1);
sprite.body.checkCollision.left = false;
sprite.body.checkCollision.right = false;
sprite2 = game.add.sprite(500, 330, 'gameboy', 2);
// sprite2 = game.add.sprite(500, 530, 'gameboy', 2);
sprite2.name = 'gameboy';
sprite2.body.collideWorldBounds = true;
sprite2.body.bounce.setTo(1, 1);
sprite3 = game.add.sprite(400, 100, 'gameboy', 0);
sprite3.name = 'gameboy2';
sprite3.body.collideWorldBounds = true;
sprite3.body.bounce.setTo(1, 1);
game.input.onDown.add(launch6, this);
}
function launch6() {
sprite.body.velocity.x = 100;
sprite2.body.velocity.x = -100;
sprite3.body.velocity.y = 100;
}
function test5() {
// Offset Down Collision false
sprite = game.add.sprite(360, 400, 'gameboy', 0);
sprite.name = 'red';
sprite.body.collideWorldBounds = true;
// sprite.body.bounce.setTo(0.9, 0.9);
sprite.body.checkCollision.up = false;
sprite2 = game.add.sprite(400, 200, 'gameboy', 2);
sprite2.name = 'green';
sprite2.body.collideWorldBounds = true;
// sprite2.body.checkCollision.down = false;
// sprite2.body.mass = 1;
sprite2.body.bounce.setTo(1, 1);
// sprite2.body.friction = 0;
game.input.onDown.add(launch5, this);
}
function launch5() {
// sprite.body.velocity.x = 200;
// sprite.body.velocity.y = -300;
// sprite2.body.velocity.x = -200;
sprite2.body.velocity.y = 200;
}
function test4() {
// Down Collision false
sprite = game.add.sprite(400, 400, 'gameboy', 0);
sprite.name = 'red';
sprite.body.collideWorldBounds = true;
sprite.body.bounce.setTo(0.9, 0.9);
sprite2 = game.add.sprite(400, 200, 'gameboy', 2);
sprite2.name = 'green';
sprite2.body.collideWorldBounds = true;
sprite2.body.checkCollision.down = false;
// sprite2.body.mass = 1;
// sprite2.body.bounce.setTo(1, 1);
// sprite2.body.friction = 0;
game.input.onDown.add(launch4, this);
}
function launch4() {
// sprite.body.velocity.x = 200;
sprite.body.velocity.y = -300;
// sprite2.body.velocity.x = -200;
// sprite2.body.velocity.y = -200;
}
function test3() {
// Top Collision false
sprite = game.add.sprite(400, 400, 'gameboy', 0);
sprite.name = 'red';
sprite.body.collideWorldBounds = true;
sprite.body.checkCollision.up = false;
sprite2 = game.add.sprite(400, 200, 'gameboy', 2);
sprite2.name = 'green';
sprite2.body.collideWorldBounds = true;
// sprite2.body.checkCollision.left = false;
sprite2.body.bounce.setTo(0.9, 0.9);
// sprite2.body.mass = 1;
// sprite2.body.bounce.setTo(1, 1);
// sprite2.body.friction = 0;
game.input.onDown.add(launch3, this);
}
function launch3() {
// sprite.body.velocity.x = 200;
// sprite.body.velocity.y = -300;
// sprite2.body.velocity.x = -200;
sprite2.body.velocity.y = 200;
}
function test2() {
// Left Collision false
sprite = game.add.sprite(200, 300, 'gameboy', 0);
sprite.name = 'red';
sprite.body.collideWorldBounds = true;
// sprite.body.checkCollision.right = false;
sprite.body.bounce.setTo(0.9, 0.9);
// sprite.body.friction = 0;
// sprite.scale.setTo(2, 2);
// sprite.body.mass = 2;
sprite2 = game.add.sprite(500, 300, 'gameboy', 2);
sprite2.name = 'green';
sprite2.body.collideWorldBounds = true;
sprite2.body.checkCollision.left = false;
// sprite2.body.bounce.setTo(0.9, 0.9);
// sprite2.body.mass = 1;
// sprite2.body.bounce.setTo(1, 1);
// sprite2.body.friction = 0;
game.input.onDown.add(launch2, this);
}
function launch2() {
sprite.body.velocity.x = 200;
// sprite.body.velocity.y = -300;
// sprite2.body.velocity.x = -200;
// sprite2.body.velocity.y = -200;
}
function test1() {
// Right Collision false
sprite = game.add.sprite(200, 300, 'gameboy', 0);
sprite.name = 'red';
sprite.body.collideWorldBounds = true;
sprite.body.checkCollision.right = false;
// sprite.body.bounce.setTo(0.9, 0.9);
// sprite.body.bounce.setTo(1, 1);
// sprite.body.friction = 0;
// sprite.scale.setTo(2, 2);
// sprite.body.mass = 2;
sprite2 = game.add.sprite(500, 300, 'gameboy', 2);
sprite2.name = 'green';
sprite2.body.collideWorldBounds = true;
sprite2.body.bounce.setTo(0.9, 0.9);
// sprite2.body.mass = 1;
// sprite2.body.bounce.setTo(1, 1);
// sprite2.body.friction = 0;
game.input.onDown.add(launch1, this);
}
function launch1() {
sprite2.body.velocity.x = -200;
}
function update() {
if (reverse)
{
game.physics.collide(sprite2, sprite);
}
else
{
game.physics.collide(sprite, sprite2);
}
if (sprite3)
{
game.physics.collide(sprite, sprite3);
}
}
function render() {
if (sprite)
{
game.debug.renderBodyInfo(sprite, 16, 24);
game.debug.renderBodyInfo(sprite2, 16, 240);
}
if (sprite)
{
game.debug.renderPhysicsBody(sprite.body);
}
if (sprite2)
{
game.debug.renderPhysicsBody(sprite2.body);
}
if (sprite3)
{
game.debug.renderPhysicsBody(sprite3.body);
}
}