Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

started writing pacmaze in tQuery

  • Loading branch information...
commit f6f07e2965c8a2eeaf86421ab7766260086b931e 1 parent ed63acb
@jeromeetienne authored
View
BIN  plugins/pacman/examples/images/BluePaintedTiles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  plugins/pacman/examples/images/PaddedOrangeWall.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
79 plugins/pacman/examples/pacmaze.html
@@ -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>
View
6 plugins/pacman/tquery.pacman.js
@@ -32,6 +32,7 @@ tQuery.registerStatic('Pacman', function(opts){
if( opts.shape === 'pacman' ){
tQuery.createSphere().addTo(container)
.addClass('ball')
+ .translateY(0.5)
.setPhongMaterial()
.map(texture)
.back()
@@ -43,9 +44,11 @@ tQuery.registerStatic('Pacman', function(opts){
.map(texture)
.back()
.positionY(0.25 + 0.125)
+ .translateY(0.5)
// build the robe
tQuery.createCylinder(0.5, 0.5, 0.75, 64).addTo(container)
.addClass('robe')
+ .translateY(0.5)
.setLambertMaterial()
.color(0xffff00)
.back()
@@ -58,6 +61,7 @@ tQuery.registerStatic('Pacman', function(opts){
.back()
.positionX(0.25)
.positionY(0.25 + 0.125)
+ .translateY(0.5)
tQuery.createSphere().addTo(container)
.addClass('eyeL')
.scaleBy(0.25)
@@ -66,6 +70,7 @@ tQuery.registerStatic('Pacman', function(opts){
.back()
.positionX(-0.25)
.positionY(0.25 + 0.125)
+ .translateY(0.5)
}else console.assert(false);
// add the shadow on the ground
@@ -76,7 +81,6 @@ tQuery.registerStatic('Pacman', function(opts){
tQuery.createPlane().addTo(container)
.addClass('shadow')
.rotationX(-Math.PI/2)
- .positionY(-0.5)
.setLambertMaterial()
.map(texture)
.opacity(0.5)
Please sign in to comment.
Something went wrong with that request. Please try again.