Skip to content

Commit 249efc8

Browse files
committed
cleaned up AI stuff, added larger images for icons
1 parent fe7984a commit 249efc8

File tree

5 files changed

+56
-20
lines changed

5 files changed

+56
-20
lines changed

public/assets/css/bootstrap.css

+25
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,31 @@ table .span24 {
13881388
width: 1884px;
13891389
margin-left: 0;
13901390
}
1391+
1392+
1393+
/* ICONS */
1394+
1395+
.user-big {
1396+
display: inline-block;
1397+
width: 24px;
1398+
height: 24px;
1399+
background-image: url("../img/glyphicons/glyphicons_003_user.png");
1400+
}
1401+
1402+
.user-fire {
1403+
display: inline-block;
1404+
width: 24px;
1405+
height: 24px;
1406+
background-image: url("../img/glyphicons/glyphicons_022_fire.png");
1407+
}
1408+
1409+
.user-plane {
1410+
display: inline-block;
1411+
width: 24px;
1412+
height: 24px;
1413+
background-image: url("../img/glyphicons/glyphicons_038_airplane.png");
1414+
}
1415+
13911416
[class^="icon-"],
13921417
[class*=" icon-"] {
13931418
display: inline-block;

public/assets/img/.DS_Store

6 KB
Binary file not shown.
42 KB
Binary file not shown.

public/assets/js/demojs/aiWorker.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
var things;
22
var updates;
33

4-
// var scaledRandomInt = function(max, min) {
5-
// return Math.round(min + Math.random()*(max-min));
6-
// }
7-
//
8-
// var getDistance = function(x1,x2,y1,y2) {
9-
// return Math.sqrt(Math.pow(Math.abs(x1-x2),2) + Math.pow(Math.abs(y1-y2),2));
10-
// }
4+
var scaledRandomInt = function(max, min) {
5+
return Math.round(min + Math.random()*(max-min));
6+
}
7+
8+
var getDistance = function(x1,x2,y1,y2) {
9+
return Math.sqrt(Math.pow(Math.abs(x1-x2),2) + Math.pow(Math.abs(y1-y2),2));
10+
}
1111

1212
var actions = {
1313
fireToBelow: function(){
@@ -20,7 +20,7 @@ var actions = {
2020
updates.minDy = -2;
2121
updates.maxDy = 3;
2222
updates.symbol = '';
23-
updates.className = 'thing icon-fire';
23+
updates.className = 'thing user-fire';
2424
postMessage(updates);
2525
},
2626

@@ -34,7 +34,7 @@ var actions = {
3434
updates.minDy = -3;
3535
updates.maxDy = 2;
3636
updates.symbol = '';
37-
updates.className = 'thing icon-plane';
37+
updates.className = 'thing user-plane';
3838
postMessage(updates);
3939
},
4040

views/artificial.html

+22-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
<script type="text/javascript" language=JavaScript src="assets/js/demojs/aiWorker.js"></script>
3030
<style>
31-
3231
.thing {
3332
position:absolute;
3433
font-size: 35px;
@@ -121,9 +120,17 @@ <h1>TechX 2012 - HTML5 WebWorkers API</h1>
121120
<div class="control-group">
122121
<label class="control-label" for="textarea"></label>
123122
<div class="controls">
124-
<button id="go" class="btn-small btn-primary" href="#">Go</button>
123+
<button id="go" class="btn-small btn-primary" href="#">Mass Panic</button>
125124
</div>
126125
</div>
126+
127+
<div class="control-group">
128+
<label class="control-label" for="textarea"></label>
129+
<div class="controls">
130+
<button id="ai" class="btn-small btn-primary" href="#">Begin AI</button>
131+
</div>
132+
</div>
133+
127134
</fieldset>
128135
</form>
129136
</div>
@@ -148,11 +155,11 @@ <h1>TechX 2012 - HTML5 WebWorkers API</h1>
148155

149156
var Thing = function(left, top, id) {
150157
this.id = id;
151-
this.minDx = -1; this.maxDx = 1;
152-
this.minDy = -1; this.maxDy = 1;
158+
this.minDx = -7; this.maxDx = 7;
159+
this.minDy = -7; this.maxDy = 7;
153160
this.x = this.xOld = left;
154161
this.y = this.yOld = top;
155-
this.pxTravelled = 1;
162+
this.pxTravelled = 7;
156163
elemMap[id] = createThingElem(left, top);
157164
}
158165

@@ -175,7 +182,7 @@ <h1>TechX 2012 - HTML5 WebWorkers API</h1>
175182
var createThingElem = function(left, top) {
176183
var elem = document.createElement("i");
177184
elem.innerHTML = "";
178-
elem.className = "thing icon-user";
185+
elem.className = "thing user-big";
179186
document.body.appendChild(elem);
180187
elem.style.left = this.x;
181188
elem.style.top = this.y;
@@ -358,11 +365,15 @@ <h1>TechX 2012 - HTML5 WebWorkers API</h1>
358365
things[i].start();
359366
thingMap[things[i].id] = things[i];
360367
}
361-
var intervals = [];
362-
intervals[0] = window.setInterval(invokeWorker.curry('updatePaths'),1000);
363-
intervals[1] = window.setInterval(invokeWorker.curry('fireToBelow'),1000),
364-
intervals[2] = window.setInterval(invokeWorker.curry('rocketToSky'),1000);
365-
intervals[3] = window.setInterval(invokeWorker.curry('erradicateSlowest'),1000);
368+
$('#ai').click(function(e) {
369+
e.preventDefault();
370+
console.log('ai');
371+
var intervals = [];
372+
intervals[0] = window.setInterval(invokeWorker.curry('updatePaths'),1000);
373+
intervals[1] = window.setInterval(invokeWorker.curry('fireToBelow'),1000),
374+
intervals[2] = window.setInterval(invokeWorker.curry('rocketToSky'),1000);
375+
intervals[3] = window.setInterval(invokeWorker.curry('erradicateSlowest'),1000);
376+
});
366377

367378
}else{
368379
console.log('WITHOUT WORKER');

0 commit comments

Comments
 (0)