Removed Stuff
This commit is contained in:
@ -2,7 +2,6 @@ let images = {};
|
|||||||
let simulator = [];
|
let simulator = [];
|
||||||
let maxSpeed = 1;
|
let maxSpeed = 1;
|
||||||
let backgroundImage;
|
let backgroundImage;
|
||||||
let worldScale;
|
|
||||||
let LEFT = [-1,0];
|
let LEFT = [-1,0];
|
||||||
|
|
||||||
const entityTypes = Object.freeze({
|
const entityTypes = Object.freeze({
|
||||||
@ -69,18 +68,18 @@ function createEntity(x, y, vx, vy, ax, ay, rot, rotv, type, id=0, iframes=Math.
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
simulator.push({
|
simulator.push({
|
||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
ax: ax,
|
ax: ax,
|
||||||
ay: ay,
|
ay: ay,
|
||||||
vx: vx,
|
vx: vx,
|
||||||
vy: vy,
|
vy: vy,
|
||||||
rot: rot,
|
rot: rot,
|
||||||
rotv: rotv,
|
rotv: rotv,
|
||||||
mass: getMass(type),
|
mass: getMass(type),
|
||||||
forcex: 0.0,
|
forcex: 0.0,
|
||||||
forcey: 0.0,
|
forcey: 0.0,
|
||||||
type: type,
|
type: type,
|
||||||
show: true,
|
show: true,
|
||||||
ueid: id,
|
ueid: id,
|
||||||
iframes: iframes
|
iframes: iframes
|
||||||
@ -103,11 +102,11 @@ function getRandomType(){
|
|||||||
|
|
||||||
function physicsUpdate(entity){
|
function physicsUpdate(entity){
|
||||||
if (entity.show){
|
if (entity.show){
|
||||||
entity.vx += entity.ax;
|
entity.vx += entity.ax;
|
||||||
entity.vy += entity.ay;
|
entity.vy += entity.ay;
|
||||||
entity.x += entity.vx;
|
entity.x += entity.vx;
|
||||||
entity.y += entity.vy;
|
entity.y += entity.vy;
|
||||||
entity.rot += entity.rotv;
|
entity.rot += entity.rotv;
|
||||||
if (entity.iframes > 0) entity.iframes -= 1;
|
if (entity.iframes > 0) entity.iframes -= 1;
|
||||||
if (entity.iframes == 0) simulator.forEach((other_entity) =>{
|
if (entity.iframes == 0) simulator.forEach((other_entity) =>{
|
||||||
checkCollision(entity, other_entity);
|
checkCollision(entity, other_entity);
|
||||||
@ -117,7 +116,7 @@ function physicsUpdate(entity){
|
|||||||
|
|
||||||
function checkCollision(entity1, entity2){
|
function checkCollision(entity1, entity2){
|
||||||
if (entity1.type == entityTypes.COMET && entity2.type == entityTypes.COMET){
|
if (entity1.type == entityTypes.COMET && entity2.type == entityTypes.COMET){
|
||||||
|
|
||||||
}else if (entity1.ueid != entity2.ueid
|
}else if (entity1.ueid != entity2.ueid
|
||||||
&& entity1.show
|
&& entity1.show
|
||||||
&& entity2.show){
|
&& entity2.show){
|
||||||
@ -129,11 +128,11 @@ function checkCollision(entity1, entity2){
|
|||||||
line(entity1.x,entity1.y, entity2.x, entity2.y);
|
line(entity1.x,entity1.y, entity2.x, entity2.y);
|
||||||
console.log("Collision at", entity1.x, entity1.y, entity1.iframes, entity2.x, entity2.y, dist);
|
console.log("Collision at", entity1.x, entity1.y, entity1.iframes, entity2.x, entity2.y, dist);
|
||||||
}
|
}
|
||||||
Explode(entity1);
|
Explode(entity1);
|
||||||
Explode(entity2);
|
Explode(entity2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Explode(entity){
|
function Explode(entity){
|
||||||
if(entity.type == entityTypes.METERORITE_SMALL){
|
if(entity.type == entityTypes.METERORITE_SMALL){
|
||||||
@ -143,12 +142,12 @@ function Explode(entity){
|
|||||||
entity.type = entityTypes.METERORITE_SMALL
|
entity.type = entityTypes.METERORITE_SMALL
|
||||||
entity.iframes = 1000;
|
entity.iframes = 1000;
|
||||||
createEntity(entity.x, entity.y, entity.vx + Math.random(), entity.vy + Math.random(), 0.0,0.0,0.0,0.0, entityTypes.METERORITE_SMALL, id=entity.ueid, iframes=1000);
|
createEntity(entity.x, entity.y, entity.vx + Math.random(), entity.vy + Math.random(), 0.0,0.0,0.0,0.0, entityTypes.METERORITE_SMALL, id=entity.ueid, iframes=1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function BlackHole(x,y,m,entity){
|
function BlackHole(x,y,m,entity){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawBackground(refImage){
|
function drawBackground(refImage){
|
||||||
@ -163,16 +162,16 @@ function drawBackground(refImage){
|
|||||||
|
|
||||||
function drawEntity(entity){
|
function drawEntity(entity){
|
||||||
if (entity.show){
|
if (entity.show){
|
||||||
push();
|
push();
|
||||||
imageMode(CENTER);
|
imageMode(CENTER);
|
||||||
translate(entity.x, entity.y, 0);
|
translate(entity.x, entity.y, 0);
|
||||||
if (entity.type == entityTypes.COMET){
|
if (entity.type == entityTypes.COMET){
|
||||||
rotate((Math.atan2(entity.vx, entity.vy) - Math.atan2(-1,0)) * 180/Math.PI);
|
rotate((Math.atan2(entity.vx, entity.vy) - Math.atan2(-1,0)) * 180/Math.PI);
|
||||||
}else{
|
}else{
|
||||||
rotate(entity.rot);
|
rotate(entity.rot);
|
||||||
}
|
}
|
||||||
image(images[entity.type], 0,0);
|
image(images[entity.type], 0,0);
|
||||||
pop();
|
pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +189,7 @@ function setup(){
|
|||||||
describe("A space physics simulator");
|
describe("A space physics simulator");
|
||||||
|
|
||||||
canvas.position(0,0);
|
canvas.position(0,0);
|
||||||
worldScale = createSlider();
|
|
||||||
//Load Entities
|
//Load Entities
|
||||||
|
|
||||||
for(var i = 0; i <= Settings.entityCount; i+=1){
|
for(var i = 0; i <= Settings.entityCount; i+=1){
|
||||||
@ -214,7 +213,6 @@ function mouseClicked(){
|
|||||||
simulator.forEach((entity) =>{
|
simulator.forEach((entity) =>{
|
||||||
|
|
||||||
})
|
})
|
||||||
console.log(worldScale.value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(){
|
function draw(){
|
||||||
|
|||||||
Reference in New Issue
Block a user