Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed63acb
commit f6f07e2
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!doctype html><title>Minimal tQuery Page</title> | ||
<script src="../../../build/tquery-bundle-require.js"></script> | ||
<script src="../tquery.pacman.js"></script> | ||
<body><script> | ||
require([ 'tquery.skymap' | ||
, 'tquery.simplemaze' | ||
, 'tquery.controls' | ||
, 'tquery.keyboard' | ||
], function(){ | ||
var world = tQuery.createWorld().boilerplate().start(); | ||
|
||
// put some lights | ||
tQuery.createAmbientLight().addTo(world) | ||
.color(0x444444) | ||
tQuery.createDirectionalLight().addTo(world) | ||
.position(1,1,1) | ||
|
||
// add pacman | ||
var pacman = tQuery.Pacman.create().addTo(world) | ||
.translateX(-1.5) | ||
world.loop().hook(function(delta, now){ | ||
pacman.rotateY(0.02) | ||
}) | ||
|
||
// world.removeCameraControls(); | ||
// tQuery(world.tCamera()).addTo(pacman).positionY(1.5) | ||
// world.tCamera().lookAt(tQuery.createVector3()) | ||
world.loop().hook(function(delta, now){ | ||
var camera = tQuery(world.tCamera()) | ||
if( camera.positionY() < 3.5 ) camera.positionY(3.5) | ||
}); | ||
|
||
// add a skymap | ||
tQuery.createSkymap('mars').addTo(world); | ||
|
||
var maze = tQuery.createSimpleMaze({ | ||
map : [ | ||
'*********', | ||
'* * *', | ||
'* ** ***', | ||
'* *', | ||
'*** *', | ||
'* *', | ||
'*********' | ||
], | ||
enableCeiling : false | ||
}).addTo(world) | ||
var maze3D = maze.object3D(); | ||
|
||
// to fix z-fighting with pacman shadow | ||
maze3D.positionY(-0.001) | ||
|
||
// very minimal controls | ||
var controls = { | ||
update : function(delta, now){ | ||
var keyboard = tQuery.keyboard(); | ||
var speed = 2; | ||
if( keyboard.pressed('left') ){ | ||
pacman.translateX(-speed * delta) | ||
} | ||
if( keyboard.pressed('right') ){ | ||
pacman.translateX(+speed * delta) | ||
} | ||
if( keyboard.pressed('up') ){ | ||
pacman.translateZ(-speed * delta) | ||
} | ||
if( keyboard.pressed('down') ){ | ||
pacman.translateZ(+speed * delta) | ||
} | ||
} | ||
}; | ||
|
||
// wrapper for this controls | ||
tQuery.createControlsWrapper({ | ||
controls : controls | ||
}).start() | ||
|
||
}) | ||
</script></body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters