-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspatialManager.js
72 lines (44 loc) · 1.15 KB
/
spatialManager.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
/*
spatialManager.js
A module which handles spatial lookup, as required for...
e.g. general collision detection.
*/
"use strict";
/* jshint browser: true, devel: true, globalstrict: true */
/*
0 1 2 3 4 5 6 7 8
12345678901234567890123456789012345678901234567890123456789012345678901234567890
*/
var spatialManager = {
// "PRIVATE" DATA
_nextSpatialID : 1, // make all valid IDs non-falsey (i.e. don't start at 0)
_entities : [],
// "PRIVATE" METHODS
//
// <none yet>
// PUBLIC METHODS
getNewSpatialID : function() {
// TODO: YOUR STUFF HERE!
},
register: function(entity) {
var pos = entity.getPos();
var spatialID = entity.getSpatialID();
// TODO: YOUR STUFF HERE!
},
unregister: function(entity) {
var spatialID = entity.getSpatialID();
// TODO: YOUR STUFF HERE!
},
findEntityInRange: function(posX, posY, radius) {
// TODO: YOUR STUFF HERE!
},
render: function(ctx) {
var oldStyle = ctx.strokeStyle;
ctx.strokeStyle = "red";
for (var ID in this._entities) {
var e = this._entities[ID];
util.strokeCircle(ctx, e.posX, e.posY, e.radius);
}
ctx.strokeStyle = oldStyle;
}
}