forked from Tritlo/Tebert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTebert.js
88 lines (81 loc) · 2.01 KB
/
Tebert.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//Tebert.js (C) 2014 Matthias Pall Gissurarson, Vilhjalmur Vilhjalmsson
function Tebert(descr){
var modelFile = (lowdef) ? "monkey.ply" : "head.ply";
//var d = plyReader.getData(modelFile);
this.__proto__.setup(modelFile);
this.textureSrc = "fur.png";
descr.shininess = 4;
this.setup(descr);
this.rotate(Math.PI,[0,1,0]);
this.origHeight = this.loc[1];
this.currentTrans = [0,0,0,0];
this.setColor(descr.color || [0.2,0.2,0.2,1.0]);
this.scale([0.35,0.35,0.35]);
this.type = "Tebert";
this.moveQueue = [];
this.rot = 0;
};
Tebert.prototype = new Character();
Tebert.prototype.onAnimStart = function(currloc,nextloc){
rotateTo(currloc,nextloc);
};
Tebert.prototype.kill = function() {
//console.log('DEAD');
this.moveQueue = [];
this.addMove([-this.loc[0], -this.loc[2]]);
onTebertDeath();
};
Tebert.prototype.onAnimEnd = function(currloc,prevloc){
pyramid.visit(currloc[0],currloc[2]);
if (pyramid.hasWon()) onVictory();
entityManager.checkCollisions();
// moveEye();
entityManager.killOutOfBounds();
};
Tebert.prototype.keys = function(keyPressed){
var tb = this;
var keys = {
"i": function(){
if(tb.rot === 0)
return [0,-1];
if(tb.rot === -Math.PI/2)
return [1,0];
if(tb.rot === Math.PI/2)
return [-1,0];
if(tb.rot === Math.PI)
return [0,1];
},
"j": function(){
if(tb.rot === 0)
return [-1,0];
if(tb.rot === -Math.PI/2)
return [0,-1];
if(tb.rot === Math.PI/2)
return [0,1];
if(tb.rot === Math.PI)
return [1,0];
},
"k": function(){
if(tb.rot === 0)
return [0,1];
if(tb.rot === -Math.PI/2)
return [-1,0];
if(tb.rot === Math.PI/2)
return [1,0];
if(tb.rot === Math.PI)
return [0,-1];
},
"l": function(){
if(tb.rot === 0)
return [1,0];
if(tb.rot === -Math.PI/2)
return [0,1];
if(tb.rot === Math.PI/2)
return [0,-1];
if(tb.rot === Math.PI)
return [-1,0];
}
};
var move = keys[keyPressed]();
this.addMove(move);
};