期末前端web大作業——用前端語言寫一個小遊戲
juese = function() {
this.status = "running";
this.runningCycle = 0;
this.mesh = new THREE.Group();
this.body = new THREE.Group();
this.mesh.add(this.body);
var torsoGeom = new THREE.CubeGeometry(7, 7, 10, 1);
this.torso = new THREE.Mesh(torsoGeom, brownMat);
this.torso.position.z = 0;
this.torso.position.y = 7;
this.torso.castShadow = true;
this.body.add(this.torso);
var pantsGeom = new THREE.CubeGeometry(9, 9, 5, 1);
this.pants = new THREE.Mesh(pantsGeom, whiteMat);
this.pants.position.z = -3;
this.pants.position.y = 0;
this.pants.castShadow = true;
this.torso.add(this.pants);
var tailGeom = new THREE.CubeGeometry(3, 3, 3, 1);
tailGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0,0,-2));
this.tail = new THREE.Mesh(tailGeom, lightBrownMat);
this.tail.position.z = -4;
this.tail.position.y = 5;
this.tail.castShadow = true;
this.torso.add(this.tail);
this.torso.rotation.x = -Math.PI/8;
var headGeom = new THREE.CubeGeometry(10, 10, 13, 1);
headGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0,0,7.5));
this.head = new THREE.Mesh(headGeom, brownMat);
this.head.position.z = 2;
this.head.position.y = 11;
this.head.castShadow = true;
this.body.add(this.head);
var cheekGeom = new THREE.CubeGeometry(1, 4, 4, 1);
this.cheekR = new THREE.Mesh(cheekGeom, pinkMat);
this.cheekR.position.x = -5;
this.cheekR.position.z = 7;
this.cheekR.position.y = -2.5;
this.cheekR.castShadow = true;
this.head.add(this.cheekR);
this.cheekL = this.cheekR.clone();
this.cheekL.position.x = - this.cheekR.position.x;
this.head.add(this.cheekL);
var noseGeom = new THREE.CubeGeometry(6, 6, 3, 1);
this.nose = new THREE.Mesh(noseGeom, lightBrownMat);
this.nose.position.z = 13.5;
this.nose.position.y = 2.6;
this.nose.castShadow = true;
this.head.add(this.nose);
var mouthGeom = new THREE.CubeGeometry(4, 2, 4, 1);
mouthGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0,0,3));
mouthGeom.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI/12));
this.mouth = new THREE.Mesh(mouthGeom, brownMat);
this.mouth.position.z = 8;
this.mouth.position.y = -4;
this.mouth.castShadow = true;
this.head.add(this.mouth);
var pawFGeom = new THREE.CubeGeometry(3,3,3, 1);
this.pawFR = new THREE.Mesh(pawFGeom, lightBrownMat);
this.pawFR.position.x = -2;
this.pawFR.position.z = 6;
this.pawFR.position.y = 1.5;
this.pawFR.castShadow = true;
this.body.add(this.pawFR);
this.pawFL = this.pawFR.clone();
this.pawFL.position.x = - this.pawFR.position.x;
this.pawFL.castShadow = true;
this.body.add(this.pawFL);
var pawBGeom = new THREE.CubeGeometry(3,3,6, 1);
this.pawBL = new THREE.Mesh(pawBGeom, lightBrownMat);
this.pawBL.position.y = 1.5;
this.pawBL.position.z = 0;
this.pawBL.position.x = 5;
this.pawBL.castShadow = true;
this.body.add(this.pawBL);
this.pawBR = this.pawBL.clone();
this.pawBR.position.x = - this.pawBL.position.x;
this.pawBR.castShadow = true;
this.body.add(this.pawBR);
var earGeom = new THREE.CubeGeometry(7, 18, 2, 1);
earGeom.vertices[6].x+=2;
earGeom.vertices[6].z+=.5;
earGeom.vertices[7].x+=2;
earGeom.vertices[7].z-=.5;
earGeom.vertices[2].x-=2;
earGeom.vertices[2].z-=.5;
earGeom.vertices[3].x-=2;
earGeom.vertices[3].z+=.5;
earGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0,9,0));
this.earL =外匯跟單gendan5.com new THREE.Mesh(earGeom, brownMat);
this.earL.position.x = 2;
this.earL.position.z = 2.5;
this.earL.position.y = 5;
this.earL.rotation.z = -Math.PI/12;
this.earL.castShadow = true;
this.head.add(this.earL);
this.earR = this.earL.clone();
this.earR.position.x = -this.earL.position.x;
this.earR.rotation.z = -this.earL.rotation.z;
this.earR.castShadow = true;
this.head.add(this.earR);
var eyeGeom = new THREE.CubeGeometry(2,4,4);
this.eyeL = new THREE.Mesh(eyeGeom, whiteMat);
this.eyeL.position.x = 5;
this.eyeL.position.z = 5.5;
this.eyeL.position.y = 2.9;
this.eyeL.castShadow = true;
this.head.add(this.eyeL);
var irisGeom = new THREE.CubeGeometry(.6,2,2);
this.iris = new THREE.Mesh(irisGeom, blackMat);
this.iris.position.x = 1.2;
this.iris.position.y = 1;
this.iris.position.z = 1;
this.eyeL.add(this.iris);
this.eyeR = this.eyeL.clone();
this.eyeR.children[0].position.x = -this.iris.position.x;
this.eyeR.position.x = -this.eyeL.position.x;
this.head.add(this.eyeR);
this.body.traverse(function(object) {
if (object instanceof THREE.Mesh) {
object.castShadow = true;
object.receiveShadow = true;
}
});
}
function createjuese() {
juese = new juese();
juese.mesh.rotation.y = Math.PI/2;
scene.add(juese.mesh);
juese.nod();
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69946337/viewspace-2846561/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 如何學web前端-幾款前端小遊戲推薦Web前端遊戲
- 用C語言編寫小遊戲——“井字棋”C語言遊戲
- Web | 一小時看懂前端語法Web前端
- Python期末大作業Python
- 用jQuery手寫一個小遊戲jQuery遊戲
- 用 JavaScript 寫一個卡片小遊戲JavaScript遊戲
- 人人都可以用C語言寫推箱子小遊戲C語言遊戲
- 為什麼Web前端語言只有JavaScript?Web前端JavaScript
- 用 PHP 寫一個"程式語言"PHP
- 用GDX寫個安卓小遊戲安卓遊戲
- javascript實現前端小遊戲2048JavaScript前端遊戲
- 我用 GitHub 9.8k 的 Go 語言 2D 遊戲引擎寫了個遊戲GithubGo遊戲引擎
- C語言小遊戲------貪吃蛇----小白專用C語言遊戲
- C語言實現的一個簡單的猜數小遊戲C語言遊戲
- 轉行Web前端工程師,需要什麼程式語言?Web前端工程師
- 寫一個狼吃羊的小遊戲遊戲
- Web前端 ---HTML語言表單Web前端HTML
- 從0開始用python寫一個命令列小遊戲(二)Python命令列遊戲
- 從0開始用python寫一個命令列小遊戲(十)Python命令列遊戲
- 從0開始用python寫一個命令列小遊戲(六)Python命令列遊戲
- 期末了,用Python寫個自動批改作業系統Python作業系統
- 做一個好前端必須要知道的事——JS語言前端JS
- 廣州藍景分享-web前端開發語言介紹Web前端
- Web前端要學什麼語言?需掌握哪些知識?Web前端
- ES6 手寫一個“辨色”小遊戲遊戲
- 使用Golang語言編寫Hello World Web應用GolangWeb
- 再談 Go 語言在前端的應用前景Go前端
- 五十音小遊戲中的前端知識遊戲前端
- 期末人福音——用Python寫個自動批改作業系統Python作業系統
- C語言初學者(自學)做的一個猜數字小遊戲C語言遊戲
- 手把手教你完成Android期末大作業(多功能應用型APP)AndroidAPP
- 在學web前端如何求職就業 Web前端就業前景怎樣Web前端求職就業
- 前端另一種多語言的實現思路前端
- WPF 模仿前端大佬寫一個Hover效果前端
- 手寫一個前端儲存工具庫前端
- 整個行業都在缺Web前端工程師,你還在問Web前端工作好找嗎?行業Web前端工程師
- Web前端就業薪資是多少?Web前端要學什麼?Web前端就業
- 用Go和Korok寫一個Flappybird遊戲-5GoAPP遊戲