mirror of
https://github.com/wassname/phaser.git
synced 2026-07-31 12:40:07 +08:00
Preparing new tests
This commit is contained in:
@@ -1,113 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
var Physics = (function () {
|
||||
function Physics() {
|
||||
this.max_bodies = 512;
|
||||
this.max_vertices = 1024;
|
||||
this.max_edges = 1024;
|
||||
this.max_body_vertices = 64;
|
||||
this.max_body_edges = 64;
|
||||
this.vertices = [];
|
||||
this.edges = [];
|
||||
this.bodies = [];
|
||||
}
|
||||
Physics.prototype.updateForces = // Sets the force on each vertex to the gravity force. You could of course apply other forces like magnetism etc.
|
||||
function () {
|
||||
for(var i = 0; i < this.vertexCount; i++) {
|
||||
this.vertices[i].acceleration = this.gravity;
|
||||
}
|
||||
};
|
||||
Physics.prototype.updateVerlet = // Updates the vertex position
|
||||
function () {
|
||||
for(var i = 0; i < this.vertexCount; i++) {
|
||||
var v = this.vertices[i];
|
||||
var temp = v.position;
|
||||
//v.position.mutableAdd(
|
||||
//v.position += v.position - v.oldPosition + v.acceleration * this.timestep * this.timestep;
|
||||
}
|
||||
};
|
||||
Physics.prototype.updateEdges = function () {
|
||||
};
|
||||
Physics.prototype.iterateCollisions = function () {
|
||||
};
|
||||
Physics.prototype.detectCollision = function (body1, body2) {
|
||||
};
|
||||
Physics.prototype.processCollision = function () {
|
||||
};
|
||||
Physics.prototype.intervalDistance = function (minA, maxA, minB, maxB) {
|
||||
};
|
||||
Physics.prototype.bodiesOverlap = function (body1, body2) {
|
||||
};
|
||||
Physics.prototype.update = // CollisionInfo
|
||||
// depth, normal, edge, vertex
|
||||
function () {
|
||||
};
|
||||
Physics.prototype.render = function () {
|
||||
};
|
||||
Physics.prototype.addBody = function (body) {
|
||||
this.bodies.push(body);
|
||||
this.bodyCount = this.bodies.length;
|
||||
};
|
||||
Physics.prototype.addEdge = function (edge) {
|
||||
this.edges.push(edge);
|
||||
this.edgeCount = this.edges.length;
|
||||
};
|
||||
Physics.prototype.addVertex = function (vertex) {
|
||||
this.vertices.push(vertex);
|
||||
this.vertexCount = this.vertices.length;
|
||||
};
|
||||
Physics.prototype.findVertex = function (x, y) {
|
||||
};
|
||||
return Physics;
|
||||
})();
|
||||
var PhysicsBody = (function () {
|
||||
function PhysicsBody() {
|
||||
this.vertices = [];
|
||||
this.edges = [];
|
||||
}
|
||||
PhysicsBody.prototype.addEdge = function (edge) {
|
||||
};
|
||||
PhysicsBody.prototype.addVertex = function (vertex) {
|
||||
};
|
||||
PhysicsBody.prototype.projectToAxis = function (axis, min, max) {
|
||||
};
|
||||
PhysicsBody.prototype.calculateCenter = function () {
|
||||
};
|
||||
PhysicsBody.prototype.createBox = function (x, y, width, height) {
|
||||
};
|
||||
return PhysicsBody;
|
||||
})();
|
||||
var Vertex = (function () {
|
||||
function Vertex(body, posX, posY) {
|
||||
}
|
||||
return Vertex;
|
||||
})();
|
||||
var Edge = (function () {
|
||||
function Edge(body, pV1, pV2, pBoundary) {
|
||||
}
|
||||
return Edge;
|
||||
})();
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
function create() {
|
||||
var p = new Physics();
|
||||
//p.max_bodies
|
||||
}
|
||||
function update() {
|
||||
}
|
||||
function render() {
|
||||
//myGame.stage.context.strokeStyle = 'rgb(0,255,0)';
|
||||
//myGame.stage.context.beginPath();
|
||||
//myGame.stage.context.moveTo(poly1.points[0].x + poly1.pos.x, poly1.points[0].y + poly1.pos.y);
|
||||
//for (var i = 1; i < poly1.points.length; i++)
|
||||
//{
|
||||
// myGame.stage.context.lineTo(poly1.points[i].x + poly1.pos.x, poly1.points[i].y + poly1.pos.y);
|
||||
//}
|
||||
//myGame.stage.context.lineTo(poly1.points[0].x + poly1.pos.x, poly1.points[0].y + poly1.pos.y);
|
||||
//myGame.stage.context.stroke();
|
||||
//myGame.stage.context.closePath();
|
||||
}
|
||||
})();
|
||||
@@ -1,200 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
class Physics {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.vertices = [];
|
||||
this.edges = [];
|
||||
this.bodies = [];
|
||||
|
||||
}
|
||||
|
||||
public gravity: Phaser.Vector2;
|
||||
|
||||
public max_bodies: number = 512;
|
||||
public max_vertices: number = 1024;
|
||||
public max_edges: number = 1024;
|
||||
public max_body_vertices: number = 64;
|
||||
public max_body_edges: number = 64;
|
||||
|
||||
public bodyCount: number;
|
||||
public vertexCount: number;
|
||||
public edgeCount: number;
|
||||
public timestep: number;
|
||||
public iterations;
|
||||
|
||||
public vertices: Vertex[];
|
||||
public edges: Edge[];
|
||||
public bodies: PhysicsBody[];
|
||||
|
||||
// Sets the force on each vertex to the gravity force. You could of course apply other forces like magnetism etc.
|
||||
public updateForces() {
|
||||
|
||||
for (var i:number = 0; i < this.vertexCount; i++)
|
||||
{
|
||||
this.vertices[i].acceleration = this.gravity;
|
||||
}
|
||||
}
|
||||
|
||||
// Updates the vertex position
|
||||
public updateVerlet() {
|
||||
|
||||
for (var i:number = 0; i < this.vertexCount; i++)
|
||||
{
|
||||
var v:Vertex = this.vertices[i];
|
||||
var temp: Phaser.Vector2 = v.position;
|
||||
//v.position.mutableAdd(
|
||||
//v.position += v.position - v.oldPosition + v.acceleration * this.timestep * this.timestep;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public updateEdges() {
|
||||
}
|
||||
|
||||
public iterateCollisions() {
|
||||
}
|
||||
|
||||
public detectCollision(body1, body2) {
|
||||
}
|
||||
|
||||
public processCollision() {
|
||||
}
|
||||
|
||||
public intervalDistance(minA, maxA, minB, maxB) {
|
||||
}
|
||||
|
||||
public bodiesOverlap(body1, body2) {
|
||||
}
|
||||
|
||||
// CollisionInfo
|
||||
// depth, normal, edge, vertex
|
||||
|
||||
public update() {
|
||||
}
|
||||
|
||||
public render() {
|
||||
}
|
||||
|
||||
public addBody(body:PhysicsBody) {
|
||||
this.bodies.push(body);
|
||||
this.bodyCount = this.bodies.length;
|
||||
}
|
||||
|
||||
public addEdge(edge:Edge) {
|
||||
this.edges.push(edge);
|
||||
this.edgeCount = this.edges.length;
|
||||
}
|
||||
|
||||
public addVertex(vertex:Vertex) {
|
||||
this.vertices.push(vertex);
|
||||
this.vertexCount = this.vertices.length;
|
||||
}
|
||||
|
||||
public findVertex(x, y) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PhysicsBody {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
center: Phaser.Vector2;
|
||||
minX;
|
||||
minY;
|
||||
maxX;
|
||||
maxY;
|
||||
vertextCount;
|
||||
edgeCount;
|
||||
|
||||
vertices = [];
|
||||
edges = [];
|
||||
|
||||
public addEdge(edge) {
|
||||
}
|
||||
|
||||
public addVertex(vertex) {
|
||||
|
||||
}
|
||||
|
||||
public projectToAxis(axis, min, max) {
|
||||
}
|
||||
|
||||
public calculateCenter() {
|
||||
}
|
||||
|
||||
public createBox(x, y, width, height) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Vertex {
|
||||
|
||||
constructor(body, posX, posY) {
|
||||
}
|
||||
|
||||
position: Phaser.Vector2;
|
||||
oldPosition: Phaser.Vector2;
|
||||
acceleration: Phaser.Vector2;
|
||||
parent: PhysicsBody;
|
||||
}
|
||||
|
||||
class Edge {
|
||||
|
||||
constructor(body, pV1, pV2, pBoundary) {
|
||||
}
|
||||
|
||||
v1: Vertex;
|
||||
v2: Vertex;
|
||||
length;
|
||||
boundary;
|
||||
parent: PhysicsBody;
|
||||
|
||||
}
|
||||
|
||||
(function () {
|
||||
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
var p = new Physics();
|
||||
//p.max_bodies
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
//myGame.stage.context.strokeStyle = 'rgb(0,255,0)';
|
||||
//myGame.stage.context.beginPath();
|
||||
//myGame.stage.context.moveTo(poly1.points[0].x + poly1.pos.x, poly1.points[0].y + poly1.pos.y);
|
||||
|
||||
//for (var i = 1; i < poly1.points.length; i++)
|
||||
//{
|
||||
// myGame.stage.context.lineTo(poly1.points[i].x + poly1.pos.x, poly1.points[i].y + poly1.pos.y);
|
||||
//}
|
||||
|
||||
//myGame.stage.context.lineTo(poly1.points[0].x + poly1.pos.x, poly1.points[0].y + poly1.pos.y);
|
||||
|
||||
//myGame.stage.context.stroke();
|
||||
//myGame.stage.context.closePath();
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user