Merged N+ physics in and tidied up the Docs folder and logos.

This commit is contained in:
Richard Davey
2013-08-11 12:15:53 +01:00
parent aff7d99a8a
commit c2d7fb7fab
108 changed files with 17900 additions and 2017 deletions
+10 -13
View File
@@ -231,7 +231,6 @@
<Content Include="input\world drag.js">
<DependentUpon>world drag.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="mobile\sprite test 1.ts" />
<TypeScriptCompile Include="misc\point1.ts" />
<Content Include="misc\color utils 1.ts" />
<Content Include="misc\color utils 2.ts" />
@@ -252,21 +251,23 @@
</Content>
<Content Include="misc\rectangle utils 1.ts" />
<Content Include="misc\rectangle utils 2.ts" />
<Content Include="mobile\sprite test 1.js">
<DependentUpon>sprite test 1.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="scrollzones\simple scrollzone.ts" />
<TypeScriptCompile Include="scrollzones\scroll window.ts" />
<TypeScriptCompile Include="scrollzones\region demo.ts" />
<TypeScriptCompile Include="scrollzones\parallax.ts" />
<TypeScriptCompile Include="scrollzones\ballscroller.ts" />
<TypeScriptCompile Include="physics\sprite bounds.ts" />
<TypeScriptCompile Include="physics\circle 1.ts" />
<Content Include="physics\circle 1.js">
<DependentUpon>circle 1.ts</DependentUpon>
</Content>
<Content Include="physics\sprite bounds.js">
<DependentUpon>sprite bounds.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="physics\temp2.ts" />
<Content Include="scrollzones\ballscroller.js">
<DependentUpon>ballscroller.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="scrollzones\blasteroids.ts" />
<Content Include="scrollzones\blasteroids.js">
<DependentUpon>blasteroids.ts</DependentUpon>
</Content>
<Content Include="scrollzones\parallax.js">
<DependentUpon>parallax.ts</DependentUpon>
</Content>
@@ -359,10 +360,6 @@
</Content>
<TypeScriptCompile Include="tilemaps\tiled tilemap.ts" />
<TypeScriptCompile Include="tilemaps\tiled layers.ts" />
<TypeScriptCompile Include="tilemaps\map draw.ts" />
<Content Include="tilemaps\map draw.js">
<DependentUpon>map draw.ts</DependentUpon>
</Content>
<Content Include="tilemaps\tiled layers.js">
<DependentUpon>tiled layers.ts</DependentUpon>
</Content>
@@ -446,8 +443,8 @@
</ItemGroup>
<ItemGroup>
<Folder Include="animation\" />
<Folder Include="mobile\" />
<Folder Include="particles\" />
<Folder Include="physics\" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
</Project>
-2
View File
@@ -31,10 +31,8 @@
function clickedIt() {
if (this.image.visible == true) {
game.stage.backgroundColor = '';
this.image.visible = false;
} else {
game.stage.backgroundColor = 'rgb(0,0,0)';
this.image.visible = true;
}
}
+3303 -568
View File
File diff suppressed because it is too large Load Diff
-38
View File
@@ -1,38 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari800xl.png');
game.load.start();
}
var atari;
function create() {
atari = game.add.sprite(200, 300, 'atari');
atari.texture.alpha = 0.5;
//atari.scale.setTo(1.5, 1.5);
//atari.physics.shape.setSize(150, 50);
//atari.physics.shape.offset.setTo(50, 25);
//atari.physics.gravity.setTo(0, 2);
atari.body.bounce.setTo(0.7, 0.7);
atari.body.drag.setTo(10, 10);
}
function update() {
atari.body.acceleration.x = 0;
atari.body.acceleration.y = 0;
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
atari.body.acceleration.x = -150;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
atari.body.acceleration.x = 150;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
atari.body.acceleration.y = -150;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
atari.body.acceleration.y = 150;
}
}
function render() {
atari.body.renderDebugInfo(16, 16);
Phaser.DebugUtils.renderSpritePhysicsBody(atari);
}
})();
-64
View File
@@ -1,64 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari800xl.png');
game.load.start();
}
var atari: Phaser.Sprite;
function create() {
atari = game.add.sprite(200, 300, 'atari');
atari.texture.alpha = 0.5;
//atari.scale.setTo(1.5, 1.5);
//atari.physics.shape.setSize(150, 50);
//atari.physics.shape.offset.setTo(50, 25);
//atari.physics.gravity.setTo(0, 2);
atari.body.bounce.setTo(0.7, 0.7);
atari.body.drag.setTo(10, 10);
}
function update() {
atari.body.acceleration.x = 0;
atari.body.acceleration.y = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
atari.body.acceleration.x = -150;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
atari.body.acceleration.x = 150;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
atari.body.acceleration.y = -150;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
atari.body.acceleration.y = 150;
}
}
function render() {
atari.body.renderDebugInfo(16, 16);
Phaser.DebugUtils.renderSpritePhysicsBody(atari);
}
})();
-50
View File
@@ -1,50 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari800xl.png');
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.start();
}
var atari;
var card;
function create() {
//atari = game.add.sprite(350, 100, 'atari');
//atari = game.add.sprite(350, 500, 'atari');
atari = game.add.sprite(0, 310, 'atari');
card = game.add.sprite(400, 300, 'card');
//card.body.immovable = true;
//atari.texture.alpha = 0.5;
//atari.scale.setTo(1.5, 1.5);
//atari.body.shape.setSize(150, 50);
//atari.body.shape.offset.setTo(50, 25);
//atari.body.gravity.setTo(0, 2);
atari.body.bounce.setTo(1, 1);
//atari.body.drag.setTo(10, 10);
card.body.bounce.setTo(0.7, 0.7);
//card.body.velocity.x = -50;
}
function update() {
atari.body.acceleration.x = 0;
atari.body.acceleration.y = 0;
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
atari.body.acceleration.x = -150;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
atari.body.acceleration.x = 150;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
atari.body.acceleration.y = -150;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
atari.body.acceleration.y = 150;
}
// collide?
game.collide(atari, card);
}
function render() {
atari.body.renderDebugInfo(16, 16);
card.body.renderDebugInfo(200, 16);
Phaser.DebugUtils.renderSpritePhysicsBody(atari);
Phaser.DebugUtils.renderSpritePhysicsBody(card);
}
})();
-81
View File
@@ -1,81 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari800xl.png');
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.start();
}
var atari: Phaser.Sprite;
var card: Phaser.Sprite;
function create() {
//atari = game.add.sprite(350, 100, 'atari');
//atari = game.add.sprite(350, 500, 'atari');
atari = game.add.sprite(0, 310, 'atari');
card = game.add.sprite(400, 300, 'card');
//card.body.immovable = true;
//atari.texture.alpha = 0.5;
//atari.scale.setTo(1.5, 1.5);
//atari.body.shape.setSize(150, 50);
//atari.body.shape.offset.setTo(50, 25);
//atari.body.gravity.setTo(0, 2);
atari.body.bounce.setTo(1, 1);
//atari.body.drag.setTo(10, 10);
card.body.bounce.setTo(0.7, 0.7);
//card.body.velocity.x = -50;
}
function update() {
atari.body.acceleration.x = 0;
atari.body.acceleration.y = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
atari.body.acceleration.x = -150;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
atari.body.acceleration.x = 150;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
atari.body.acceleration.y = -150;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
atari.body.acceleration.y = 150;
}
// collide?
game.collide(atari, card);
}
function render() {
atari.body.renderDebugInfo(16, 16);
card.body.renderDebugInfo(200, 16);
Phaser.DebugUtils.renderSpritePhysicsBody(atari);
Phaser.DebugUtils.renderSpritePhysicsBody(card);
}
})();
-139
View File
@@ -1,139 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/physics/advanced/Manager.ts" />
/// <reference path="../../Phaser/physics/advanced/shapes/Box.ts" />
/// <reference path="../../Phaser/physics/advanced/shapes/Circle.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.load.image('xatari', 'assets/sprites/atari800xl.png');
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.image('atari', 'assets/sprites/shinyball.png');
game.load.start();
}
var debug;
var atari;
var card;
var physics;
var circle;
var walls;
var t;
function create() {
//atari = game.add.sprite(200, 100, 'atari');
// need to get the physics bounds around the sprite center, regardless of origin
//atari.transform.origin.setTo(0.5, 0.5);
//card = game.add.sprite(500, 300, 'card');
physics = new Phaser.Physics.Advanced.Manager(game);
//Phaser.Physics.Advanced.Manager.debug = debug;
walls = new Phaser.Physics.Advanced.Body(null, Phaser.Types.BODY_STATIC, 0, 0);
walls.game = game;
//walls.addBox(250, 200, 500, 20, 0, 1, 1);
//staticBody.addShape(new ShapeBox(0, 0.2, 20.48, 0.4));
// * 0.02 p2m
// * 50 m2p
walls.addBox(0, 500, 1024, 20, 0, 1, 1);
//walls.transform.setRotation(game.math.degreesToRadians(4));
//walls.fixedRotation = true;
// position is in relation to the containing body! don't forget this
//ground = walls.addShape(new Phaser.Physics.Advanced.Shapes.Box(400, 500, 500, 20));
//walls.addShape(new Phaser.Physics.Advanced.ShapeBox(0, 0.2, 20.48, 0.4));
//walls.addShape(new Phaser.Physics.Advanced.ShapeBox(0, 15.16, 20.48, 0.4));
//walls.addShape(new Phaser.Physics.Advanced.ShapeBox(-10.04, 7.68, 0.4, 14.56));
//walls.addShape(new Phaser.Physics.Advanced.ShapeBox(10.04, 7.68, 0.4, 14.56));
//walls.resetMassData();
physics.space.addBody(walls);
// Add a circle
//circle = new Phaser.Physics.Advanced.Body(null, Phaser.Types.BODY_DYNAMIC, 200, 100);
//circle.game = game;
//circle.addCircle(32, 0, 0, 0.5);
//physics.space.addBody(circle);
t = new Phaser.Physics.Advanced.Body(null, Phaser.Types.BODY_DYNAMIC, 300, 100);
//t.fixedRotation = true;
t.game = game;
t.addBox(0, 0, 20, 20, 0.5, 1, 1);
//t.addCircle(32, 0, 0, 0.8);
//t.addTriangle(0, 0, 1, 1, 2, 2);
//t.addPoly([{ x: -0.8, y: 0.48 }, { x: -0.8, y: 0 }, { x: 0.8, y: 0 }, { x: 0.8, y: 0.32 }, { x: 0, y: 0.84 }, { x: -0.56, y: 0.84 }], 1, 1, 6);
//t.addPoly([{ x: -0.8, y: 0.48 }, { x: -0.8, y: 0 }, { x: 0.8, y: 0 }, { x: 0.8, y: 0.32 }, { x: 0, y: 0.84 }, { x: -0.56, y: 0.84 }], 0.5, 1, 1);
//t.transform.setRotation(game.math.degreesToRadians(45));
//t.fixedRotation = true;
physics.space.addBody(t);
game.input.onTap.add(step, this);
}
function step() {
physics.update();
}
function update() {
//if (physics.space.stepCount < 90)
//{
physics.update();
//}
//atari.x = physics.metersToPixels(circle.position.x);
//atari.y = physics.metersToPixels(circle.position.y);
//atari.rotation = physics.metersToPixels(circle.angle);
// force moves without rotating
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
circle.applyAngularImpulse(-0.02);
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
circle.applyAngularImpulse(0.02);
}
/*
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
circle.applyForceToCenter(new Phaser.Vec2(-8, 0));
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
circle.applyForceToCenter(new Phaser.Vec2(8, 0));
}
*/
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
circle.applyForceToCenter(new Phaser.Vec2(0, -10));
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
circle.applyForceToCenter(new Phaser.Vec2(0, 5));
}
//console.log(circle.velocity.x, circle.velocity.y);
//console.log('p', circle.position.x, circle.position.y);
}
function renderBounds(body) {
game.stage.context.fillStyle = 'rgba(0,255,200,0.2)';
game.stage.context.fillRect(body.bounds.x, body.bounds.y, body.bounds.width, body.bounds.height);
}
function renderCircle(shape) {
game.stage.context.beginPath();
game.stage.context.arc(shape.tc.x * 50, shape.tc.y * 50, shape.radius * 50, 0, Math.PI * 2, false);
if(shape.body.isAwake) {
game.stage.context.fillStyle = 'rgba(0,255,0, 0.3)';
} else {
game.stage.context.fillStyle = 'rgba(100,100,100, 0.1)';
}
game.stage.context.fill();
game.stage.context.closePath();
}
function drawPolygon(ctx, shape, lineWidth, fillStyle) {
var verts = shape.tverts;
var body = shape.body;
ctx.beginPath();
ctx.moveTo(body.position.x + verts[0].x * 50, body.position.y + verts[0].y * 50);
for(var i = 0; i < verts.length; i++) {
ctx.lineTo(body.position.x + verts[i].x * 50, body.position.y + verts[i].y * 50);
}
ctx.lineTo(body.position.x + verts[verts.length - 1].x * 50, body.position.y + verts[verts.length - 1].y * 50);
ctx.closePath();
ctx.fillStyle = fillStyle;
ctx.fill();
}
function render() {
//game.stage.context.fillStyle = 'rgb(255,255,0)';
//game.stage.context.fillText('x: ' + t.position.x + ' y: ' + t.position.y, 32, 32);
//game.stage.context.fillText('vx: ' + t.velocity.x + ' vy: ' + t.velocity.y, 32, 64);
//game.stage.context.fillText('x: ' + t.bounds.x + ' y: ' + t.bounds.y, 32, 32);
//game.stage.context.fillText('vx: ' + t.velocity.x + ' vy: ' + t.velocity.y, 32, 64);
//renderCircle(circle.shapes[0]);
//renderBounds(circle);
drawPolygon(game.stage.context, walls.shapes[0], 1, 'rgb(0,255,255)');
//drawPolygon(game.stage.context, walls.shapes[1], 1, 'rgb(0,255,255)');
//renderCircle(t.shapes[0]);
drawPolygon(game.stage.context, t.shapes[0], 1, 'rgb(255,255,255)');
//renderBounds(t);
}
})();
-206
View File
@@ -1,206 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/physics/advanced/Manager.ts" />
/// <reference path="../../Phaser/physics/advanced/shapes/Box.ts" />
/// <reference path="../../Phaser/physics/advanced/shapes/Circle.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
game.load.image('xatari', 'assets/sprites/atari800xl.png');
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.image('atari', 'assets/sprites/shinyball.png');
game.load.start();
}
var debug: HTMLTextAreaElement;
var atari: Phaser.Sprite;
var card: Phaser.Sprite;
var physics: Phaser.Physics.Advanced.Manager;
var circle: Phaser.Physics.Advanced.Body;
var walls: Phaser.Physics.Advanced.Body;
var t: Phaser.Physics.Advanced.Body;
function create() {
//atari = game.add.sprite(200, 100, 'atari');
// need to get the physics bounds around the sprite center, regardless of origin
//atari.transform.origin.setTo(0.5, 0.5);
//card = game.add.sprite(500, 300, 'card');
physics = new Phaser.Physics.Advanced.Manager(game);
//Phaser.Physics.Advanced.Manager.debug = debug;
walls = new Phaser.Physics.Advanced.Body(null, Phaser.Types.BODY_STATIC, 0, 0);
walls.game = game;
//walls.addBox(250, 200, 500, 20, 0, 1, 1);
//staticBody.addShape(new ShapeBox(0, 0.2, 20.48, 0.4));
// * 0.02 p2m
// * 50 m2p
walls.addBox(0, 500, 1024, 20, 0, 1, 1);
//walls.transform.setRotation(game.math.degreesToRadians(4));
//walls.fixedRotation = true;
// position is in relation to the containing body! don't forget this
//ground = walls.addShape(new Phaser.Physics.Advanced.Shapes.Box(400, 500, 500, 20));
//walls.addShape(new Phaser.Physics.Advanced.ShapeBox(0, 0.2, 20.48, 0.4));
//walls.addShape(new Phaser.Physics.Advanced.ShapeBox(0, 15.16, 20.48, 0.4));
//walls.addShape(new Phaser.Physics.Advanced.ShapeBox(-10.04, 7.68, 0.4, 14.56));
//walls.addShape(new Phaser.Physics.Advanced.ShapeBox(10.04, 7.68, 0.4, 14.56));
//walls.resetMassData();
physics.space.addBody(walls);
// Add a circle
//circle = new Phaser.Physics.Advanced.Body(null, Phaser.Types.BODY_DYNAMIC, 200, 100);
//circle.game = game;
//circle.addCircle(32, 0, 0, 0.5);
//physics.space.addBody(circle);
t = new Phaser.Physics.Advanced.Body(null, Phaser.Types.BODY_DYNAMIC, 300, 100);
//t.fixedRotation = true;
t.game = game;
t.addBox(0, 0, 20, 20, 0.5, 1, 1);
//t.addCircle(32, 0, 0, 0.8);
//t.addTriangle(0, 0, 1, 1, 2, 2);
//t.addPoly([{ x: -0.8, y: 0.48 }, { x: -0.8, y: 0 }, { x: 0.8, y: 0 }, { x: 0.8, y: 0.32 }, { x: 0, y: 0.84 }, { x: -0.56, y: 0.84 }], 1, 1, 6);
//t.addPoly([{ x: -0.8, y: 0.48 }, { x: -0.8, y: 0 }, { x: 0.8, y: 0 }, { x: 0.8, y: 0.32 }, { x: 0, y: 0.84 }, { x: -0.56, y: 0.84 }], 0.5, 1, 1);
//t.transform.setRotation(game.math.degreesToRadians(45));
//t.fixedRotation = true;
physics.space.addBody(t);
game.input.onTap.add(step, this);
}
function step() {
physics.update();
}
function update() {
//if (physics.space.stepCount < 90)
//{
physics.update();
//}
//atari.x = physics.metersToPixels(circle.position.x);
//atari.y = physics.metersToPixels(circle.position.y);
//atari.rotation = physics.metersToPixels(circle.angle);
// force moves without rotating
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
circle.applyAngularImpulse(-0.02);
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
circle.applyAngularImpulse(0.02);
}
/*
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
circle.applyForceToCenter(new Phaser.Vec2(-8, 0));
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
circle.applyForceToCenter(new Phaser.Vec2(8, 0));
}
*/
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
circle.applyForceToCenter(new Phaser.Vec2(0, -10));
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
circle.applyForceToCenter(new Phaser.Vec2(0, 5));
}
//console.log(circle.velocity.x, circle.velocity.y);
//console.log('p', circle.position.x, circle.position.y);
}
function renderBounds(body: Phaser.Physics.Advanced.Body) {
game.stage.context.fillStyle = 'rgba(0,255,200,0.2)';
game.stage.context.fillRect(body.bounds.x, body.bounds.y, body.bounds.width, body.bounds.height);
}
function renderCircle(shape) {
game.stage.context.beginPath();
game.stage.context.arc(shape.tc.x * 50, shape.tc.y * 50, shape.radius * 50, 0, Math.PI * 2, false);
if (shape.body.isAwake)
{
game.stage.context.fillStyle = 'rgba(0,255,0, 0.3)';
}
else
{
game.stage.context.fillStyle = 'rgba(100,100,100, 0.1)';
}
game.stage.context.fill();
game.stage.context.closePath();
}
function drawPolygon(ctx, shape, lineWidth, fillStyle) {
var verts = shape.tverts;
var body = shape.body;
ctx.beginPath();
ctx.moveTo(body.position.x + verts[0].x * 50, body.position.y + verts[0].y * 50);
for (var i = 0; i < verts.length; i++) {
ctx.lineTo(body.position.x + verts[i].x * 50, body.position.y + verts[i].y * 50);
}
ctx.lineTo(body.position.x + verts[verts.length - 1].x * 50, body.position.y + verts[verts.length - 1].y * 50);
ctx.closePath();
ctx.fillStyle = fillStyle;
ctx.fill();
}
function render() {
//game.stage.context.fillStyle = 'rgb(255,255,0)';
//game.stage.context.fillText('x: ' + t.position.x + ' y: ' + t.position.y, 32, 32);
//game.stage.context.fillText('vx: ' + t.velocity.x + ' vy: ' + t.velocity.y, 32, 64);
//game.stage.context.fillText('x: ' + t.bounds.x + ' y: ' + t.bounds.y, 32, 32);
//game.stage.context.fillText('vx: ' + t.velocity.x + ' vy: ' + t.velocity.y, 32, 64);
//renderCircle(circle.shapes[0]);
//renderBounds(circle);
drawPolygon(game.stage.context, walls.shapes[0], 1, 'rgb(0,255,255)');
//drawPolygon(game.stage.context, walls.shapes[1], 1, 'rgb(0,255,255)');
//renderCircle(t.shapes[0]);
drawPolygon(game.stage.context, t.shapes[0], 1, 'rgb(255,255,255)');
//renderBounds(t);
}
})();
+90
View File
@@ -0,0 +1,90 @@
/// <reference path="../../Phaser/_definitions.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.image('card', 'assets/sprites/mana_card.png');
}
var cells;
var b;
var c;
var t;
var ball;
var card;
function create() {
this.ball = game.add.sprite(0, 0, 'ball');
this.card = game.add.sprite(0, 0, 'card');
this.card.rotation = 30;
this.c = game.add.circle(200, 200, 16);
this.b = game.add.aabb(400, 200, 74, 128);
// pos is center, not upper-left
this.cells = [];
var tid;
for (var i = 0; i < 10; i++) {
if (i % 2 == 0) {
tid = Phaser.Physics.TileMapCell.TID_CONCAVEpn;
} else {
tid = Phaser.Physics.TileMapCell.TID_CONCAVEnn;
}
this.cells.push(game.add.cell(100 + (i * 100), 400, 50, 50, tid));
//this.cells.push(new TileMapCell(100 + (i * 100), 500, 50, 50).SetState(TileMapCell.TID_FULL));
//this.cells.push(new TileMapCell(100 + (i * 100), 500, 50, 50).SetState(TileMapCell.TID_CONCAVEpn));
}
}
function update() {
var fx = 0;
var fy = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
fx -= 0.2;
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
fx += 0.2;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
fy -= 0.2 + 0.2;
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
fy += 0.2;
}
// update circle
this.c.pos.x = this.c.oldpos.x + Math.min(20, Math.max(-20, this.c.pos.x - this.c.oldpos.x + fx));
this.c.pos.y = this.c.oldpos.y + Math.min(20, Math.max(-20, this.c.pos.y - this.c.oldpos.y + fy));
this.c.IntegrateVerlet();
// update box
this.b.pos.x = this.b.oldpos.x + Math.min(40, Math.max(-40, this.b.pos.x - this.b.oldpos.x + fx));
this.b.pos.y = this.b.oldpos.y + Math.min(40, Math.max(-40, this.b.pos.y - this.b.oldpos.y + fy));
this.b.IntegrateVerlet();
for (var i = 0; i < this.cells.length; i++) {
this.c.CollideCircleVsTile(this.cells[i]);
this.b.CollideAABBVsTile(this.cells[i]);
}
this.c.CollideCircleVsWorldBounds();
this.b.CollideAABBVsWorldBounds();
this.ball.transform.centerOn(this.c.pos.x, this.c.pos.y);
this.card.transform.centerOn(this.b.pos.x, this.b.pos.y);
}
function render() {
this.c.render(game.stage.context);
this.b.render(game.stage.context);
for (var i = 0; i < this.cells.length; i++) {
this.cells[i].render(game.stage.context);
}
}
})();
+113
View File
@@ -0,0 +1,113 @@
/// <reference path="../../Phaser/_definitions.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.image('card', 'assets/sprites/mana_card.png');
}
var cells;
var b: Phaser.Physics.AABB;
var c: Phaser.Physics.Circle;
var t: Phaser.Physics.TileMapCell;
var ball: Phaser.Sprite;
var card: Phaser.Sprite;
function create() {
this.ball = game.add.sprite(0, 0, 'ball');
this.card = game.add.sprite(0, 0, 'card');
this.card.rotation = 30;
this.c = game.add.circle(200, 200, 16);
this.b = game.add.aabb(400, 200, 74, 128);
// pos is center, not upper-left
this.cells = [];
var tid;
for (var i = 0; i < 10; i++)
{
if (i % 2 == 0)
{
tid = Phaser.Physics.TileMapCell.TID_CONCAVEpn;
}
else
{
tid = Phaser.Physics.TileMapCell.TID_CONCAVEnn;
}
this.cells.push(game.add.cell(100 + (i * 100), 400, 50, 50, tid));
//this.cells.push(new TileMapCell(100 + (i * 100), 500, 50, 50).SetState(TileMapCell.TID_FULL));
//this.cells.push(new TileMapCell(100 + (i * 100), 500, 50, 50).SetState(TileMapCell.TID_CONCAVEpn));
}
}
function update() {
var fx = 0;
var fy = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
fx -= 0.2;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
fx += 0.2;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
fy -= 0.2 + 0.2;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
fy += 0.2;
}
// update circle
this.c.pos.x = this.c.oldpos.x + Math.min(20, Math.max(-20, this.c.pos.x - this.c.oldpos.x + fx));
this.c.pos.y = this.c.oldpos.y + Math.min(20, Math.max(-20, this.c.pos.y - this.c.oldpos.y + fy));
this.c.IntegrateVerlet();
// update box
this.b.pos.x = this.b.oldpos.x + Math.min(40, Math.max(-40, this.b.pos.x - this.b.oldpos.x + fx));
this.b.pos.y = this.b.oldpos.y + Math.min(40, Math.max(-40, this.b.pos.y - this.b.oldpos.y + fy));
this.b.IntegrateVerlet();
for (var i = 0; i < this.cells.length; i++)
{
this.c.CollideCircleVsTile(this.cells[i]);
this.b.CollideAABBVsTile(this.cells[i]);
}
this.c.CollideCircleVsWorldBounds();
this.b.CollideAABBVsWorldBounds();
this.ball.transform.centerOn(this.c.pos.x, this.c.pos.y);
this.card.transform.centerOn(this.b.pos.x, this.b.pos.y);
}
function render() {
this.c.render(game.stage.context);
this.b.render(game.stage.context);
for (var i = 0; i < this.cells.length; i++)
{
this.cells[i].render(game.stage.context);
}
}
})();
-33
View File
@@ -1,33 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari800xl.png');
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.start();
}
var atari;
var card;
function create() {
atari = game.add.sprite(200, 310, 'atari');
card = game.add.sprite(500, 300, 'card');
atari.input.start(0);
atari.input.enableDrag();
card.input.start(0);
card.events.onInputDown.add(rotateIt, this);
}
function rotateIt() {
card.rotation += 10;
}
function update() {
}
function render() {
game.stage.context.save();
game.stage.context.strokeStyle = 'rgb(255,255,0)';
game.stage.context.strokeRect(atari.cameraView.x, atari.cameraView.y, atari.cameraView.width, atari.cameraView.height);
game.stage.context.strokeStyle = 'rgb(255,0,255)';
game.stage.context.strokeRect(card.cameraView.x, card.cameraView.y, card.cameraView.width, card.cameraView.height);
game.stage.context.restore();
}
})();
-54
View File
@@ -1,54 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari800xl.png');
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.start();
}
var atari: Phaser.Sprite;
var card: Phaser.Sprite;
function create() {
atari = game.add.sprite(200, 310, 'atari');
card = game.add.sprite(500, 300, 'card');
atari.input.start(0);
atari.input.enableDrag();
card.input.start(0);
card.events.onInputDown.add(rotateIt, this);
}
function rotateIt() {
card.rotation += 10;
}
function update() {
}
function render() {
game.stage.context.save();
game.stage.context.strokeStyle = 'rgb(255,255,0)';
game.stage.context.strokeRect(atari.cameraView.x, atari.cameraView.y, atari.cameraView.width, atari.cameraView.height);
game.stage.context.strokeStyle = 'rgb(255,0,255)';
game.stage.context.strokeRect(card.cameraView.x, card.cameraView.y, card.cameraView.width, card.cameraView.height);
game.stage.context.restore();
}
})();
+43
View File
@@ -0,0 +1,43 @@
/// <reference path="../../Phaser/_definitions.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
}
var fuji;
var tween;
var b;
function create() {
game.stage.backgroundColor = 'rgb(0,0,100)';
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
fuji.origin.setTo(0, 0.5);
fuji.rotation = 34;
b = new Phaser.Rectangle(fuji.transform.center.x, fuji.transform.center.y, fuji.width, fuji.height);
//game.add.tween(fuji).to({ rotation: 360 }, 20000, Phaser.Easing.Linear.None, true, 0, true);
}
function update() {
if (game.input.activePointer.justPressed()) {
//fuji.transform.centerOn(game.input.x, game.input.y);
fuji.x = game.input.x;
fuji.y = game.input.y;
}
b.x = fuji.transform.center.x - fuji.transform.halfWidth;
b.y = fuji.transform.center.y - fuji.transform.halfHeight;
}
function render() {
//Phaser.DebugUtils.renderSpriteWorldViewBounds(fuji);
//Phaser.DebugUtils.renderSpriteBounds(fuji);
Phaser.DebugUtils.renderSpriteCorners(fuji);
//Phaser.DebugUtils.renderSpriteWorldView(fuji, 32, 32);
Phaser.DebugUtils.renderRectangle(b, 'rgba(237,20,91,0.3)');
}
})();
+53
View File
@@ -0,0 +1,53 @@
/// <reference path="../../Phaser/_definitions.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
function preload() {
game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
}
var fuji: Phaser.Sprite;
var tween: Phaser.Tween;
var b: Phaser.Rectangle;
function create() {
game.stage.backgroundColor = 'rgb(0,0,100)';
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
fuji.origin.setTo(0, 0.5);
fuji.rotation = 34;
b = new Phaser.Rectangle(fuji.transform.center.x, fuji.transform.center.y, fuji.width, fuji.height);
//game.add.tween(fuji).to({ rotation: 360 }, 20000, Phaser.Easing.Linear.None, true, 0, true);
}
function update() {
if (game.input.activePointer.justPressed())
{
//fuji.transform.centerOn(game.input.x, game.input.y);
fuji.x = game.input.x;
fuji.y = game.input.y;
}
b.x = fuji.transform.center.x - fuji.transform.halfWidth;
b.y = fuji.transform.center.y - fuji.transform.halfHeight;
}
function render() {
//Phaser.DebugUtils.renderSpriteWorldViewBounds(fuji);
//Phaser.DebugUtils.renderSpriteBounds(fuji);
Phaser.DebugUtils.renderSpriteCorners(fuji);
//Phaser.DebugUtils.renderSpriteWorldView(fuji, 32, 32);
Phaser.DebugUtils.renderRectangle(b, 'rgba(237,20,91,0.3)');
}
})();