Skip to content

Commit

Permalink
le he anadido un espectaculo de luces
Browse files Browse the repository at this point in the history
  • Loading branch information
khanatos committed Jun 6, 2013
1 parent 1150ff6 commit 9fef7d9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
35 changes: 35 additions & 0 deletions js/live_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,39 @@ function LiveObject(name, image_path, x, y, width, height, image_count) {
}


function get_random_color() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
}

function RayoLuz() {
canvas = document.getElementById("canvas");
context = canvas.getContext('2d');

rayoluzini = Math.floor((Math.random()*window.innerWidth - 250)+1);
rayoluzfin = rayoluzini+200;

context.beginPath();
context.moveTo(0,-100);
context.lineTo(rayoluzini,canvas.height);
context.lineTo(rayoluzfin,canvas.height);
context.fillStyle=get_random_color();
context.fill();

rayoluzini = Math.floor((Math.random()*window.innerWidth - 250)+1);
rayoluzfin = rayoluzini+200;

context.beginPath();
context.moveTo(canvas.width,-100);
context.lineTo(rayoluzini,canvas.height);
context.lineTo(rayoluzfin,canvas.height);
context.fillStyle=get_random_color();
context.fill();
}



9 changes: 8 additions & 1 deletion js/mundo.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ function Mundo() {
t.inhabitants[i].paint_extra(t.context);
}
}

//add dance lights! when mundo.luz == true
if(mundo.luz == true)
{
luz = new RayoLuz();
}

} else {
var local_ready = true;
for(var i in t.inhabitants) {
Expand Down Expand Up @@ -81,5 +88,5 @@ $(function() {
mundo.inhabitants.push(paco);
mundo.inhabitants.push(juan);
//mundo.inhabitants.push(house);

});
4 changes: 4 additions & 0 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ $(function() {
}
} else if (ors[1] === "para") {
person.move(-1);
mundo.luz = false;
} else if (ors[1] === "baila") {
person.dance();
} else if (ors[0] === "luces") {
mundo.luz = true;
} else if (ors[0] === "musica") {
for(var i in mundo.inhabitants) {
mundo.inhabitants[i].dance();
mundo.luz = true;
}
} else if (ors[0] === "nace" && ors.length === 5) {
// chapucilla
Expand Down

0 comments on commit 9fef7d9

Please sign in to comment.