Skip to content

Commit

Permalink
Added waiting time text
Browse files Browse the repository at this point in the history
  • Loading branch information
gbertherat committed Nov 24, 2020
1 parent fae5a20 commit 15c47a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions jumpers/js/character.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
function Character(x, name){
function Character(x, name, time){
this.pos = createVector(x, height/2);
this.vel = createVector();
this.grav = 0.1;
this.size = 50;
this.name = name;
this.waitingTime = time;

this.show = function(time){
this.show = function(){
push();
colorMode(HSB, 255);
color = 80 - constrain(time / 10000, 0, 255);
color = 80 - constrain(this.waitingTime / 10000, 0, 255);
stroke(color, 255, 180);
fill(color, 255, 255);
ellipse(this.pos.x, this.pos.y, this.size, this.size);
Expand All @@ -22,9 +23,9 @@ function Character(x, name){
this.pos.y = constrain(this.pos.y, -height/2 + this.size/2, height/4 - this.size/2);
}

this.jump = function(time){
this.jump = function(){
if(this.pos.y == height/4 - this.size/2){
this.vel.y = -5 - time/600000;
this.vel.y = -5 - this.waitingTime/600000;
}
if(this.pos.y == -height/2 + this.size/2){
this.vel.y = -this.vel.y;
Expand All @@ -42,8 +43,15 @@ function Character(x, name){
textSize(16);
textStyle(BOLD);
textAlign(CENTER);
text(this.name, this.pos.x, height/3 - 50);
text(this.name, this.pos.x, height/3 - 60);
text("Temps d'attente: " + this.formatTime(), this.pos.x, height/3 - 40);
}
pop();
}

this.formatTime = function(){
return moment("2015-01-01").startOf('day')
.seconds(this.waitingTime/1000)
.format('HH:mm:ss');
}
}
6 changes: 3 additions & 3 deletions jumpers/js/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function setup(){
x = step/2;

for(var i = 0; i < data.length; i++){
chars.push(new Character(x, data[i].designation));
chars.push(new Character(x, data[i].designation, data[i].realMaxWaitingTimeMs));
x += step;
}

Expand All @@ -46,9 +46,9 @@ function draw(){
showGroung();

for(var i = 0; i < chars.length; i++){
chars[i].show(data[i].realMaxWaitingTimeMs);
chars[i].show();
chars[i].update();
chars[i].jump(data[i].realMaxWaitingTimeMs);
chars[i].jump();
}
}

Expand Down

0 comments on commit 15c47a0

Please sign in to comment.