git @ Cat's Eye Technologies Cyclobots / 7a07441
Checkpoint having a selection dropdown for kind of visuals. Chris Pressey 3 years ago
1 changed file(s) with 39 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
3232 });
3333 }
3434
35 function setVisuals(c) {
35 function setClassicVisuals(c) {
3636 c.forEachBot(function(bot) {
3737 if (bot.graphics) return;
3838 var graphics = new PIXI.Graphics();
4040 graphics.beginFill(0xff0000);
4141 graphics.drawCircle(0, 0, 10);
4242 graphics.endFill();
43 //graphics.filters = [new PIXI.filters.BlurFilter()];
4443 app.stage.addChild(graphics);
4544 bot.graphics = graphics;
4645 });
4746 }
4847
49 setVisuals(c);
48 function setBlurredVisuals(c) {
49 c.forEachBot(function(bot) {
50 if (bot.graphics) return;
51 var graphics = new PIXI.Graphics();
52 graphics.lineStyle(0);
53 graphics.beginFill(0xff0000);
54 graphics.drawCircle(0, 0, 10);
55 graphics.endFill();
56 graphics.filters = [new PIXI.filters.BlurFilter()];
57 app.stage.addChild(graphics);
58 bot.graphics = graphics;
59 });
60 }
61
62 setClassicVisuals(c);
5063
5164 app.ticker.add(function(delta) {
5265 c.update();
6679 button.onclick = fun;
6780 return button;
6881 }
69 function makeSelect(container, labelText, optionsArray, fun, def) {
82 function makeSelect(container, labelText, optionsArray, fun) {
7083 var label = document.createElement('label');
7184 label.innerHTML = labelText;
7285 container.appendChild(label);
7386 var select = document.createElement("select");
7487 for (var i = 0; i < optionsArray.length; i++) {
7588 var op = document.createElement("option");
76 op.value = optionsArray[i][0];
77 op.text = optionsArray[i][1];
89 op.value = optionsArray[i].value;
90 op.text = optionsArray[i].text;
7891 select.options.add(op);
7992 }
8093 select.onchange = function(e) {
81 fun(optionsArray[select.selectedIndex][0]);
94 fun(optionsArray[select.selectedIndex]);
8295 };
8396 select.selectedIndex = 0;
8497 label.appendChild(select);
99112 }
100113 function makeVisualsPanel(container) {
101114 var panel = makeDiv(container);
115 makeSelect(panel, "Visuals:", [
116 {
117 text: "Classic",
118 value: function() {
119 removeVisuals(c);
120 setClassicVisuals(c);
121 }
122 },
123 {
124 text: "Blurred",
125 value: function() {
126 removeVisuals(c);
127 setBlurredVisuals(c);
128 }
129 },
130 ], function(selection) {
131 selection.value();
132 });
102133 makeButton(panel, "Classic", function(e) { setVisuals(c); });
103 makeButton(panel, "Remove", function(e) { removeVisuals(c); });
134 makeButton(panel, "Remove", function(e) { });
104135 }
105136
106137 var controlPanel = makeDiv(config.container);