-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcreature2.js
39 lines (31 loc) · 1.03 KB
/
creature2.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
jj.createCreature('sensing', function (creature) {
var canvas = document.createElement('canvas'),
context = canvas.getContext('2d'),
width = canvas.width = 100,
height = canvas.height = 100;
creature.data({
sight: 500,
hearing: 600,
smell: 200
});
creature.size({width: width, height: height});
creature.position({top: 80, left: jj.center().left - (width / 2)});
creature.el.append(canvas);
context.fillStyle = "#FFD68E";
context.beginPath();
context.arc(50, 50, width / 2, 0, Math.PI * 2, true);
context.closePath();
context.fill();
creature.bind('touch', function(other) {
console.log(creature.name() + ' touched ' + other.name());
});
creature.bind('see', function(other) {
console.log(creature.name() + ' saw ' + other.name());
});
creature.bind('hear', function(other) {
console.log(creature.name() + ' heard ' + other.name());
});
creature.bind('smell', function(other) {
console.log(creature.name() + ' smelt ' + other.name());
});
});