Add 2 example for the new Physics Engine

This commit is contained in:
Florian Rival
2018-12-24 18:34:10 +01:00
parent 2ed9088b58
commit 2fd4459364
18 changed files with 44962 additions and 1805 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

View File

@@ -0,0 +1 @@
A demo of all the joints that can be created using the Physics engine.

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

View File

@@ -0,0 +1 @@
A demo of all the joints, and the way they can be customized, using the Physics engine.

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

View File

@@ -9,6 +9,7 @@ const {
loadSerializedProject,
} = require('./lib/LocalProjectOpener');
const { writeProjectJSONFile } = require('./lib/LocalProjectWriter');
const makeExtensionsLoader = require('./lib/LocalJsExtensionsLoader');
const { getExampleNames } = require('./lib/ExamplesLoader');
const fs = require('fs');
@@ -35,28 +36,36 @@ const updateResources = (project, baseUrl) => {
project.exposeResources(worker);
};
getExampleNames().then(exampleNames =>
Promise.all(
exampleNames.map(exampleName => {
return readProjectJSONFile(
`../resources/examples/${exampleName}/${exampleName}.json`
)
.then(projectObject => {
console.log(`Example "${exampleName}" loaded.`);
const project = loadSerializedProject(gd, projectObject);
updateResources(project, baseUrl + '/' + exampleName);
fs.mkdir(`../src/fixtures/${exampleName}`, () => {
writeProjectJSONFile(
gd,
project,
`../src/fixtures/${exampleName}/${exampleName}.json`
);
console.log(`Update of "${exampleName}" done.`);
const extensionsLoader = makeExtensionsLoader({ gd, filterExamples: false });
extensionsLoader
.loadAllExtensions()
.then(loadingResults => {
console.info('Loaded extensions', loadingResults);
return getExampleNames();
})
.then(exampleNames =>
Promise.all(
exampleNames.map(exampleName => {
return readProjectJSONFile(
`../resources/examples/${exampleName}/${exampleName}.json`
)
.then(projectObject => {
console.log(`Example "${exampleName}" loaded.`);
const project = loadSerializedProject(gd, projectObject);
updateResources(project, baseUrl + '/' + exampleName);
fs.mkdir(`../src/fixtures/${exampleName}`, () => {
writeProjectJSONFile(
gd,
project,
`../src/fixtures/${exampleName}/${exampleName}.json`
);
console.log(`Update of "${exampleName}" done.`);
});
})
.catch(error => {
console.error('Error caught:', error);
});
})
.catch(error => {
console.error('Error caught:', error);
});
})
)
);
})
)
);

View File

@@ -1,7 +1,7 @@
import indexHTML from './GDJSindex.html.js';
const gdjsRoot =
'https://s3-eu-west-1.amazonaws.com/gdevelop-resources/GDJS-5.0.0-beta58';
'https://s3-eu-west-1.amazonaws.com/gdevelop-resources/GDJS-5.0.0-beta62';
export const findGDJS = cb => {
return cb({

View File

@@ -23,6 +23,10 @@ const jsExtensions = [
name: 'DeviceVibration',
extensionModule: require('GDJS-for-web-app-only/Runtime/Extensions/DeviceVibration/JsExtension.js'),
},
{
name: 'Physics2',
extensionModule: require('GDJS-for-web-app-only/Runtime/Extensions/Physics2Behavior/JsExtension.js'),
},
];
/**

View File

@@ -69,6 +69,8 @@ const exampleNames = [
'particles-various-effects',
'pathfinding-basics',
'pathfinding',
'physics-joints-demo',
'physics-joints-settings-demo',
'physics',
'pin-object-to-another-multiple-parents',
'pin-object-to-another',

File diff suppressed because it is too large Load Diff

View File

@@ -59,6 +59,8 @@ import particlesVariousEffects from '../fixtures/particles-various-effects/parti
import pathfinding from '../fixtures/pathfinding/pathfinding.json';
import pathfindingBasics from '../fixtures/pathfinding-basics/pathfinding-basics.json';
import physics from '../fixtures/physics/physics.json';
import physicsJointsDemo from '../fixtures/physics-joints-demo/physics-joints-demo.json';
import physicsJointsSettingsDemo from '../fixtures/physics-joints-settings-demo/physics-joints-settings-demo.json';
import pinObjectToAnother from '../fixtures/pin-object-to-another/pin-object-to-another.json';
import pinObjectToAnotherMultipleParents from '../fixtures/pin-object-to-another-multiple-parents/pin-object-to-another-multiple-parents.json';
import planeAndClouds from '../fixtures/plane-and-clouds/plane-and-clouds.json';
@@ -219,6 +221,10 @@ export default class BrowserProjectOpener {
return Promise.resolve(pathfindingBasics);
} else if (url === 'example://physics') {
return Promise.resolve(physics);
} else if (url === 'example://physics-joints-demo') {
return Promise.resolve(physicsJointsDemo);
} else if (url === 'example://physics-joints-settings-demo') {
return Promise.resolve(physicsJointsSettingsDemo);
} else if (url === 'example://platformer') {
return Promise.resolve(platformer);
} else if (url === 'example://platformer-double-jump') {

File diff suppressed because it is too large Load Diff