Affichage du score total, amélioration du calcul des couleurs.
This commit is contained in:
parent
049ff27ffa
commit
a14ce7aacc
|
@ -4,6 +4,10 @@ Number.prototype.clip = function(min, max, floor) {
|
|||
} catch(e) {alert("Error Number.prototype.clip");alert(e);}
|
||||
};
|
||||
|
||||
Number.prototype.mapInterval = function(a,b,x,y) {
|
||||
return x + ((this-a) / (b-a) * (y-x));
|
||||
}
|
||||
|
||||
function dichotomy(start, isBigger, foo) {
|
||||
try {
|
||||
var i = 0, min = 0, max, half;
|
||||
|
@ -152,4 +156,17 @@ $.fn.clickOnce = function(fn) {
|
|||
try {
|
||||
this.unbind("click",fn).click(fn);
|
||||
} catch(e) {alert("Error $.fn.clickOnce");alert(e);}
|
||||
};
|
||||
|
||||
/**
|
||||
* startcolor et endcolor sont de la forme {r:0,g:255,b:127}
|
||||
*/
|
||||
$.fn.goodBad = function(min, max, startcolor, endcolor) {
|
||||
var val = parseInt(this.text(), 10);
|
||||
if (isNaN(val)) return this;
|
||||
this.css("color","rgb("
|
||||
+(val.mapInterval(min,max,startcolor.r,endcolor.r).clip(0, 255, true))+","
|
||||
+(val.mapInterval(min,max,startcolor.g,endcolor.g).clip(0, 255, true))+","
|
||||
+(val.mapInterval(min,max,startcolor.b,endcolor.b).clip(0, 255, true))+")");
|
||||
return this;
|
||||
};
|
|
@ -433,17 +433,19 @@ score.enter = function () {
|
|||
score.leave = function () {
|
||||
try {
|
||||
if (runstate.scoreFetched) runstate.scoreFetched = function() {};
|
||||
$("#score .scores").empty();
|
||||
$("#templates .scoreTotal").empty();
|
||||
} catch(e) {alert("Error score.leave");alert(e);}
|
||||
};
|
||||
|
||||
score.ui = function () {
|
||||
try {
|
||||
$("#score .scores").empty();
|
||||
$("#score .scoreTotal")
|
||||
.text(state.game.scoreTotal)
|
||||
.goodBad(-50,100,{r:255,g:0,b:0},{r:0,g:192,b:0});
|
||||
$.each(state.game.cloud, function(i,e) {
|
||||
try {
|
||||
var percentScore = (e.score - state.game.minScore) / (state.game.maxScore - state.game.minScore);
|
||||
u = $("#templates .scoreLine");
|
||||
ee = e;
|
||||
$("#templates .scoreLine")
|
||||
.clone()
|
||||
.find(".word")
|
||||
|
@ -451,7 +453,7 @@ score.ui = function () {
|
|||
.end()
|
||||
.find(".score")
|
||||
.text(e.score)
|
||||
.css("color","rgb("+(255 - 255*percentScore).clip(0,255)+","+(191*percentScore).clip(0,255,true)+",0)")
|
||||
.goodBad(-5,10,{r:255,g:0,b:0},{r:0,g:192,b:0})
|
||||
.end()
|
||||
.appendTo("#score .scores");
|
||||
} catch(e) {alert("Error anonymous 1 in score.ui");alert(e);}
|
||||
|
|
Loading…
Reference in New Issue
Block a user