adityaravishankar / command-and-conquer

Command & Conquer in HTML5/Javascript
777 stars 170 forks source link

Get full unit life at empty bar #35

Open ajira86 opened 12 years ago

ajira86 commented 12 years ago

I was attacking two turrets and one of my tank becom full of life after loosing all in progress bar. After that, he continue to run like a fresh tank

adityaravishankar commented 12 years ago

Wow... this one is new.... I'll check the code to see if I can find out whats happening....

However this one is going to be hard to replicate :(

jovoud commented 12 years ago

line 1203: [code] var vehicle = vehicles.add({name:unitButton.name,x:constructedAt.x+1, y:constructedAt.y + 3,moveDirection:16,turretDirection:16, orders:{type:'move',to:{x:Math.floor(constructedAt.x-1+ (Math.random()*4)), // orders:{type:'move',to:{x:Math.floor(constructedAt.x-1), y:Math.floor(constructedAt.y+5)}}}); game.units.push(vehicle);
[/code]

Could it be that by accident 2 tanks are create on the same coordinates? so when you move they move together and or not detected using the 'tanks move for each other' algorithm? So if that could happen and they both move the same way thereby drawn the same way, when 1 tank is destroyed it will be removed but the other tank is still present?

adityaravishankar commented 12 years ago

Don't think so....

The second tank would avoid the first tank because of the collision-radius intersection... So it would turn away before getting near the first tank...