This commit is contained in:
Nicky Case 2017-07-13 14:49:49 -04:00
parent 1a17694633
commit ec0f50f460
15 changed files with 164 additions and 94 deletions

View file

@ -63,13 +63,29 @@
"trimmed": false, "trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":502,"h":502}, "spriteSourceSize": {"x":0,"y":0,"w":502,"h":502},
"sourceSize": {"w":502,"h":502} "sourceSize": {"w":502,"h":502}
},
"iterated_payoffs0008":
{
"frame": {"x":1034,"y":1034,"w":502,"h":502},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":502,"h":502},
"sourceSize": {"w":502,"h":502}
},
"iterated_payoffs0009":
{
"frame": {"x":10,"y":1546,"w":502,"h":502},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":502,"h":502},
"sourceSize": {"w":502,"h":502}
}}, }},
"meta": { "meta": {
"app": "Adobe Animate", "app": "Adobe Animate",
"version": "15.2.0.66", "version": "15.2.0.66",
"image": "iterated_payoffs.png", "image": "iterated_payoffs.png",
"format": "RGBA8888", "format": "RGBA8888",
"size": {"w":2048,"h":2048}, "size": {"w":2048,"h":4096},
"scale": "1" "scale": "1"
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 164 KiB

View file

@ -1,19 +0,0 @@
{"frames": {
"iterated_scoreboard0000":
{
"frame": {"x":10,"y":10,"w":402,"h":202},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":402,"h":202},
"sourceSize": {"w":402,"h":202}
}},
"meta": {
"app": "Adobe Animate",
"version": "15.2.0.66",
"image": "iterated_scoreboard.png",
"format": "RGBA8888",
"size": {"w":512,"h":512},
"scale": "1"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -59,17 +59,15 @@ body{
top:-270px; top:-270px;
} }
#slideshow .object{ .object{
position: absolute; position: absolute;
transition: left 0.5s ease-in-out, top 0.5s ease-in-out;
} }
/********* Fader *********/ /********* Fader *********/
.fader{ .fader{
-webkit-transition: opacity 0.3s ease-in-out; transition: opacity 0.5s ease-in-out;
-mos-transition: opacity 0.3s ease-in-out;
-ms-transition: opacity 0.3s ease-in-out;
transition: opacity 0.3s ease-in-out;
} }
/******** Text Box ********/ /******** Text Box ********/
@ -293,6 +291,31 @@ body{
z-index: 200; z-index: 200;
} }
/*************************/
/******* SCOREBOARD *******/
/*************************/
#scoreboard{
position: absolute;
width:200px; height:100px;
background: url(../assets/iterated/iterated_scoreboard.png);
background-size: 100% 100%;
}
#scoreboard > div{
position: absolute;
width: 60px; height: 60px;
text-align: center;
font-size: 50px;
color: #666666;
}
#scoreboard > div:nth-child(1){
left: 20px;
top: 21px;
}
#scoreboard > div:nth-child(2){
right: 15px;
top: 21px;
}
/*************************/ /*************************/
/***** SLIDE SELECT ******/ /***** SLIDE SELECT ******/

View file

@ -18,14 +18,8 @@ function Background(config){
self.dom.style.height = height+"px"; self.dom.style.height = height+"px";
self.dom.style.background = config.color; self.dom.style.background = config.color;
// Add... // Add & Remove
self.add = function(INSTANT){ self.add = function(){ _add(self); };
return _addFade(self, INSTANT); self.remove = function(){ _remove(self); };
};
// Remove...
self.remove = function(INSTANT){
return _removeFade(self, INSTANT);
};
} }

View file

@ -72,15 +72,8 @@ function Button(config){
listen(self, self.id+"/deactivate", self.deactivate); listen(self, self.id+"/deactivate", self.deactivate);
} }
// Add... // Add & Remove
self.add = function(INSTANT){ self.add = function(){ _add(self); };
return _addFade(self, INSTANT); self.remove = function(){ _remove(self); };
};
// Remove...
self.remove = function(INSTANT){
unlisten(self);
return _removeFade(self, INSTANT);
};
} }

View file

@ -14,14 +14,14 @@ function Slideshow(config){
// Reset: INITIAL VARIABLES // Reset: INITIAL VARIABLES
self.reset = function(){ self.reset = function(){
// CLEAR
if(self.clear) self.clear();
// On End? // On End?
if(self.currentSlide && self.currentSlide.onend){ if(self.currentSlide && self.currentSlide.onend){
self.currentSlide.onend(self); self.currentSlide.onend(self);
} }
// CLEAR
if(self.clear) self.clear();
// Reset // Reset
self.dom.innerHTML = ""; self.dom.innerHTML = "";
self.slideIndex = -1; self.slideIndex = -1;
@ -36,7 +36,7 @@ function Slideshow(config){
////////////////////////////////////////////////// //////////////////////////////////////////////////
// Go to next slide // Go to next slide
self.nextSlide = function(INSTANT){ self.nextSlide = function(){
// On End? // On End?
if(self.currentSlide && self.currentSlide.onend){ if(self.currentSlide && self.currentSlide.onend){
@ -73,9 +73,7 @@ function Slideshow(config){
self.objects = {}; self.objects = {};
// Add Object // Add Object
self.add = function(objectConfig, INSTANT){ self.add = function(objectConfig){
INSTANT = true; // hack, sure.
// Create object // Create object
var Classname = window[objectConfig.type]; var Classname = window[objectConfig.type];
@ -87,29 +85,25 @@ function Slideshow(config){
self.objects[objectConfig.id] = obj; self.objects[objectConfig.id] = obj;
// Add it for real! // Add it for real!
return obj.add(INSTANT); // return a possible promise return obj.add();
}; };
// Remove Object // Remove Object
self.remove = function(objectID, INSTANT){ self.remove = function(objectID){
INSTANT = true; // hack, sure.
// Find it... // Find it...
var obj = self.objects[objectID]; var obj = self.objects[objectID];
// Remove from memory & DOM // Remove from memory & DOM
delete self.objects[objectID]; delete self.objects[objectID];
return obj.remove(INSTANT); // return a possible promise return obj.remove();
}; };
// Clear: Remove ALL objects // Clear: Remove ALL objects
self.clear = function(INSTANT){ self.clear = function(){
for(var id in self.objects){ for(var id in self.objects) self.remove(id);
self.remove(id, INSTANT);
}
}; };

View file

@ -30,16 +30,10 @@ function TextBox(config){
self.text_id = id; self.text_id = id;
self.setText(Words.get(self.text_id)); self.setText(Words.get(self.text_id));
}; };
self.setTextID(config.text_id); if(config.text_id) self.setTextID(config.text_id);
// Add... // Add & Remove
self.add = function(INSTANT){ self.add = function(){ _add(self); };
return _addFade(self, INSTANT); self.remove = function(){ _remove(self); };
};
// Remove...
self.remove = function(INSTANT){
return _removeFade(self, INSTANT);
};
} }

View file

@ -135,7 +135,7 @@ function Iterated(config){
self.dehighlightPayoff(); self.dehighlightPayoff();
// End Round // End Round
publish("iterated/round/end"); publish("iterated/round/end", payoffs);
}); });
@ -166,19 +166,62 @@ function Iterated(config){
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Add... // Add...
self.add = function(INSTANT){ self.add = function(){
return _add(self); _add(self);
}; };
// Remove... // Remove...
self.remove = function(INSTANT){ self.remove = function(){
app.destroy(); app.destroy();
unlisten(self); unlisten(self);
return _remove(self); _remove(self);
}; };
} }
function IteratedScoreboard(config){
var self = this;
self.config = config;
// DOM
self.dom = document.createElement("div");
self.dom.id = "scoreboard";
self.dom.className = "object";
self.dom.style.left = config.x+"px";
self.dom.style.top = config.y+"px";
// Left score
var left = document.createElement("div");
self.dom.appendChild(left);
// Right score
var right = document.createElement("div");
self.dom.appendChild(right);
// Reset
self.score = [0,0];
self.reset = function(){
self.score = [0,0];
self.showScore();
};
self.addScore = function(a,b){
self.score[0] += a;
self.score[1] += b;
self.showScore();
};
self.showScore = function(){
left.innerHTML = self.score[0];
right.innerHTML = self.score[1];
};
self.reset();
// Add & Remove
self.add = function(){ _add(self); };
self.remove = function(){ _remove(self); };
}
function IteratedPeep(config){ function IteratedPeep(config){
var self = this; var self = this;

View file

@ -410,16 +410,16 @@ function SandboxUI(config){
///////////////////////////////////////// /////////////////////////////////////////
// Add... // Add...
self.add = function(INSTANT){ self.add = function(){
return _add(self); _add(self);
}; };
// Remove... // Remove...
self.remove = function(INSTANT){ self.remove = function(){
for(var i=0;i<numbers.length;i++) unlisten(numbers[i]); for(var i=0;i<numbers.length;i++) unlisten(numbers[i]);
for(var i=0;i<sliders.length;i++) unlisten(sliders[i]); for(var i=0;i<sliders.length;i++) unlisten(sliders[i]);
unlisten(self); unlisten(self);
return _remove(self); _remove(self);
}; };
} }

View file

@ -101,14 +101,14 @@ function Splash(config){
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Add... // Add...
self.add = function(INSTANT){ self.add = function(){
return _add(self); _add(self);
}; };
// Remove... // Remove...
self.remove = function(INSTANT){ self.remove = function(){
app.destroy(); app.destroy();
return _remove(self); _remove(self);
}; };
} }

View file

@ -371,19 +371,17 @@ function Tournament(config){
listen(self, "tournament/reproduce", self._startReproduce); listen(self, "tournament/reproduce", self._startReproduce);
// Add... // Add...
self.add = function(INSTANT){ self.add = function(){
return _add(self); _add(self);
}; };
// Remove... // Remove...
// TODO: KILL ALL LISTENERS, TOO. self.remove = function(){
// TODO: Don't screw up when paused or looking at new tab
self.remove = function(INSTANT){
_stopAutoPlay(); _stopAutoPlay();
for(var i=0; i<self.agents.length; i++) unlisten(self.agents[i]); for(var i=0; i<self.agents.length; i++) unlisten(self.agents[i]);
unlisten(self); unlisten(self);
app.destroy(); app.destroy();
return _remove(self); _remove(self);
}; };
} }

View file

@ -5,17 +5,36 @@ SLIDES.push({
onjump: function(self){ onjump: function(self){
// Iterated Simulation // Iterated Simulation
self.add({id:"iterated", type:"Iterated", x:130, y:133}); self.add({id:"iterated", type:"Iterated", x:130, y:183});
self.objects.iterated.dehighlightPayoff(); self.objects.iterated.dehighlightPayoff();
}, },
onstart: function(self){ onstart: function(self){
// Move it
self.objects.iterated.dom.style.top = 183;
// Scoreboard!
self.add({id:"scoreboard", type:"IteratedScoreboard", x:378, y:85});
// Extra info up top
_.yourTotalScore = 0;
self.add({
id:"info", type:"TextBox",
x:378, y:45, width:200, height:50, align:"center", size:15
});
var _showInfo = function(){
var infoWords = Words.get("iterated_info_1")+ROUND_INDEX+"/"+ROUNDS.length;
infoWords += "<br>";
infoWords += Words.get("iterated_info_2")+_.yourTotalScore;
self.objects.info.setText(infoWords);
};
// ROUNDS // ROUNDS
var ROUNDS = [ var ROUNDS = [
{id:"tft", num:5}, {id:"tft", num:5},
//{id:"all_d", num:4}, {id:"all_d", num:4},
//{id:"all_c", num:4}, //{id:"all_c", num:4},
//{id:"grudge", num:5}, //{id:"grudge", num:5},
//{id:"prober", num:7} //{id:"prober", num:7}
@ -24,13 +43,13 @@ SLIDES.push({
ROUND_NUM = 0; ROUND_NUM = 0;
self.add({ self.add({
id:"buttonCheat", type:"Button", x:275, y:403, uppercase:true, id:"buttonCheat", type:"Button", x:275, y:453, uppercase:true,
text_id:"label_cheat", text_id:"label_cheat",
message:"iterated/cheat" message:"iterated/cheat"
}); });
self.add({ self.add({
id:"buttonCooperate", type:"Button", x:495, y:400, uppercase:true, id:"buttonCooperate", type:"Button", x:495, y:450, uppercase:true,
text_id:"label_cooperate", text_id:"label_cooperate",
message:"iterated/cooperate" message:"iterated/cooperate"
}); });
@ -39,11 +58,16 @@ SLIDES.push({
publish("buttonCheat/deactivate"); publish("buttonCheat/deactivate");
publish("buttonCooperate/deactivate"); publish("buttonCooperate/deactivate");
}); });
listen(self, "iterated/round/end", function(){ listen(self, "iterated/round/end", function(payoffA, payoffB){
publish("buttonCheat/activate"); publish("buttonCheat/activate");
publish("buttonCooperate/activate"); publish("buttonCooperate/activate");
// Add score!
self.objects.scoreboard.addScore(payoffA, payoffB);
_.yourTotalScore += payoffA;
_showInfo();
// Next round // Next round
ROUND_NUM++; ROUND_NUM++;
if(ROUND_NUM >= ROUNDS[ROUND_INDEX].num){ if(ROUND_NUM >= ROUNDS[ROUND_INDEX].num){
@ -55,12 +79,16 @@ SLIDES.push({
publish("slideshow/scratch"); // NEXT SLIDE, WHATEVER publish("slideshow/scratch"); // NEXT SLIDE, WHATEVER
}else{ }else{
publish("iterated/newOpponent",[ROUNDS[ROUND_INDEX].id]); publish("iterated/newOpponent",[ROUNDS[ROUND_INDEX].id]);
self.objects.scoreboard.reset();
_showInfo();
} }
} }
}); });
_showInfo();
}, },
onend: function(self){ onend: function(self){

View file

@ -83,6 +83,12 @@ blah blah blah blah. But what if...
<!-- - - - - - ITERATED - - - - - - - --> <!-- - - - - - ITERATED - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - --> <!-- - - - - - - - - - - - - - - - - -->
<p id="iterated_info_1">
opponent:
</p>
<p id="iterated_info_2">
your total score:
</p>
<!-- - - - - - - - - - - - - - - - - --> <!-- - - - - - - - - - - - - - - - - -->
<!-- - - - - TOURNAMENT! - - - - - - --> <!-- - - - - TOURNAMENT! - - - - - - -->