Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better tank game no dimension mapping #19

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added examples/assets/images/red-tank-diffuse.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions examples/assets/procedural-sphere.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function proc( options ) {

options = options || {};
options.type = options.type || "sphere";
options.radius = options.radius || 0.5;
options.latDetail = options.latDetail || 24;
options.lonDetail = options.lonDetail || 24;

var mesh =
{
primitive: {
type: options.type,
radius: options.radius,
lat: options.latDetail,
lon: options.lonDetail,
uvmapper: {
projectionMode: "cubic",
scale: [1, 1, 1]
}
},
compile: true
};

return mesh;

}
17 changes: 9 additions & 8 deletions examples/cube-collision/cube-collision.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ document.addEventListener( "DOMContentLoaded", function( e ) {

var box2dOptions = {
resolver: {
gravity: [0,-0.5]
dimensionMap: box2dExtension.services.resolver.service.prototype.DimensionMaps.XY
}
};

engine.registerExtension( cubicvrExtension, cubicvrOptions );
engine.registerExtension( box2dExtension);//, box2dOptions);
engine.registerExtension( box2dExtension, box2dOptions);

var resources = {};

Expand Down Expand Up @@ -102,13 +102,14 @@ document.addEventListener( "DOMContentLoaded", function( e ) {

var lightDefinition = new cubicvr.LightDefinition({
intensity: 1,
distance: 20,
light_type: cubicvr.LightDefinition.LightTypes.POINT,
method: cubicvr.LightDefinition.LightingMethods.DYNAMIC
});

space.add( new engine.Entity( "camera",
[
new engine.core.Transform( [0, 0, 5] ),
new engine.core.Transform( [0, 0, 10] ),
new cubicvr.Light( lightDefinition ),
new cubicvr.Camera( {
targeted:false
Expand All @@ -117,7 +118,7 @@ document.addEventListener( "DOMContentLoaded", function( e ) {
));

var bodyDefinition = new box2d.BodyDefinition();
var fixtureDefinition = new box2d.FixtureDefinition({shape:new box2d.BoxShape(0.25,0.25)});
var fixtureDefinition = new box2d.FixtureDefinition({shape:new box2d.BoxShape(1,1)});

for (var cubeIndex = 0; cubeIndex < 5; cubeIndex++){

Expand All @@ -132,7 +133,7 @@ document.addEventListener( "DOMContentLoaded", function( e ) {
};
var firstCube = new engine.Entity( "cube1",
[
new engine.core.Transform( [3 + cubeIndex * 1.5, 0.125, 0], [0, 0, 0], [0.5, 0.5, 0.5] ),
new engine.core.Transform( [3 + cubeIndex * 3, 0.25, 0], [0, 0, 0]),
firstBody,
new cubicvr.Model( resources.mesh, resources.material )
]
Expand All @@ -151,14 +152,14 @@ document.addEventListener( "DOMContentLoaded", function( e ) {

var secondCube = new engine.Entity( "cube2",
[
new engine.core.Transform( [-3 - cubeIndex * 1.5, -0.125, 0], [0, 0, 0], [0.5, 0.5, 0.5] ),
new engine.core.Transform( [-3 - cubeIndex * 3, -0.25, 0], [0, 0, 0]),
secondBody,
new cubicvr.Model( resources.mesh, resources.material )
]
);
space.add( secondCube );
new engine.Event("LinearImpulse", {impulse: [-0.25,0]}).dispatch(firstCube);
new engine.Event("LinearImpulse", {impulse: [0.25,0]}).dispatch(secondCube);
new engine.Event("LinearImpulse", {impulse: [-1,0]}).dispatch(firstCube);
new engine.Event("LinearImpulse", {impulse: [1,0]}).dispatch(secondCube);
}

var task = new engine.FunctionTask( function() {
Expand Down
4 changes: 3 additions & 1 deletion examples/tank/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ <h2>Tank controls</h2>
Press S to move the tank backwards<br />
Press A to turn the tank left<br />
Press D to turn the tank right<br />
Press Space to trigger a fire event (viewable in the console)
Press the left arrow key to turn the turret to the left<br />
Press the right arrow key to turn the turret to the right<br />
Press Space to fire
</p>
</body>
</html>
4 changes: 3 additions & 1 deletion examples/tank/tank-controls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"MoveBackward": [ "S" ],
"TurnLeft": [ "A" ],
"TurnRight": [ "D" ],
"StrafeModifier": [ "SHIFT" ]
"StrafeModifier": [ "SHIFT" ],
"TurnTurretLeft": [ "LEFT" ],
"TurnTurretRight": [ "RIGHT" ]
},
"Actions": {
"Fire": [ "SPACE" ]
Expand Down
Loading