Skip to content

Commit

Permalink
fixed anim pausing
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahkagan committed Mar 31, 2011
1 parent 842c3c6 commit 271accd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
17 changes: 11 additions & 6 deletions b_cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ var b_cell = function(p, spec) {

p.popMatrix();

if (ascending === true) {
counter++;
}
else if (ascending === false) {
counter--;
}
if (!anim_paused) {
if (ascending === true) {
counter++;
}
else if (ascending === false) {
counter--;
}
}
if (counter === c_max) {
ascending = false;
}
Expand Down Expand Up @@ -237,12 +239,15 @@ var b_cell = function(p, spec) {
}
};

var anim_paused = false;
obj.stop_animation = function() {
b_anim.pause();
anim_paused = true;
};

obj.resume_animation = function() {
b_anim.start();
anim_paused = false;
};

return obj;
Expand Down
5 changes: 2 additions & 3 deletions cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ var cell = function(p, spec) {
// Make sounds
sounds.play_sound("cell_fire");

// TODO: need a slower death
obj.die();

var pos = obj.get_pos();
Expand Down Expand Up @@ -310,15 +309,15 @@ var cell = function(p, spec) {
if (num_particles === 1) {
ang = arrow_angle;
}
num_dots = 3
var num_dots = 5;
while (num_particles > 0) {
var offset = 4;
p.fill(153);
p.noStroke();
for (var i = 0; i < num_dots; i++) {
x = r*p.cos(ang)*offset + pos.x ;
y = r*p.sin(ang)*offset + pos.y ;
p.ellipse(x, y, 3, 3);
p.ellipse(x, y, 2, 2);
offset += 2;
}

Expand Down
2 changes: 1 addition & 1 deletion floater.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var floater = function(p, spec) {
macrophage_active.pause();
};

obj.stop_animation = function() {
obj.resume_animation = function() {
macrophage_alive.start();
macrophage_active.start();
};
Expand Down
17 changes: 11 additions & 6 deletions in_game_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ var in_game_state = function (p, previous_state, game_type) {
arrows: "Use the LEFT and RIGHT arrow keys to switch between infected cells.",
macrophage: "Watch out for macrophages! They will kill your virion and alert a B cell.",
antibodies: "Oh no! The B cell is producing antibodies! If an antibody attaches to an infected cell, the cell will be marked for destruction by a granulocyte.",
killer: "A granulocyte just destroyed one of your infected cells and all the virions inside it! Your virus won't be safe from the granulocyte until it mutates, creating a new strain.",
mutation: "Your virus just mutated to a new strain! Now it will be safe from the immune system until you hit another macrophage. Each virion can only be attacked by immune cells that know about its strain. Immune cells that know about a certain strain will be filled with the same color as virions of that strain.",
};

Expand All @@ -157,13 +158,13 @@ var in_game_state = function (p, previous_state, game_type) {
var w = 300;
var h = 250;
var tw = w-50;
console.log(tw);
obj.draw = function() {
p.noStroke();
p.fill(100);
p.rectMode(p.CENTER);
p.rect(x, y, w, h);
p.fill(0);
p.textSize(14);
p.textAlign(p.CENTER, p.CENTER);
p.text(txt, x-tw/2, y-tw/2, tw, h-50);
};
Expand All @@ -180,7 +181,7 @@ var in_game_state = function (p, previous_state, game_type) {
return obj; // the current state
},
rect: {
pos: new p.PVector(p.width/2, p.height/2+100),
pos: new p.PVector(p.width/2, p.height/2+80),
width: 50, height: 50,
text: "OK"
}
Expand All @@ -194,8 +195,7 @@ var in_game_state = function (p, previous_state, game_type) {
popup : function(type) {
if (is_tutorial && tut_flags[type]) {
do_pause();
text = tut_msgs[type];//type_to_text(type);
//show_button(text);
text = tut_msgs[type];
show_popup(text);
tut_flags[type] = false;
}
Expand Down Expand Up @@ -1037,6 +1037,7 @@ var in_game_state = function (p, previous_state, game_type) {
cell.get_state() === "active")
&& cell.has_antibody()
&& same_mutation_level(tk, cell)) {
tut_manager.popup("killer");
cell.die();
sounds.play_sound("kill");
tk.set_target(null);
Expand Down Expand Up @@ -1734,8 +1735,12 @@ var in_game_state = function (p, previous_state, game_type) {
};

var do_pause = function() {
paused = true;
sounds.pause_background_music();
tut_pause();
};

var tut_pause = function() {
paused = true;
// stop the animations
do_to_all_objs(
function(o) {
Expand All @@ -1744,7 +1749,7 @@ var in_game_state = function (p, previous_state, game_type) {
}
}
);
}
};

var do_fire = function() {
if (active_cell !== null) {
Expand Down

0 comments on commit 271accd

Please sign in to comment.