mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
got some animation going for shell explosions and robot collision damage
This commit is contained in:
parent
8e0477cc15
commit
df99a934ba
|
@ -187,19 +187,37 @@
|
||||||
fillCircle(x, y, shellDisplayRadius, SHELL_COLOR);
|
fillCircle(x, y, shellDisplayRadius, SHELL_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var explodeShell = function(shell) {
|
||||||
|
var x = scaleX(shell['pos-x']);
|
||||||
|
var y = scaleY(shell['pos-y']);
|
||||||
|
fillCircle(x, y, shellDisplayRadius * 10, SHELL_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
var animateWorld = function(previousWorld, currentWorld) {
|
var animateWorld = function(previousWorld, currentWorld) {
|
||||||
ctx.clearRect(0, 0, width, height);
|
ctx.clearRect(0, 0, width, height);
|
||||||
var shellMap = currentWorld.shells["shell-map"];
|
var currentShellMap = currentWorld.shells["shell-map"];
|
||||||
for (key in shellMap) {
|
var previousShellMap = previousWorld.shells["shell-map"];
|
||||||
if (shellMap.hasOwnProperty(key)) {
|
for (key in previousShellMap) {
|
||||||
drawShell(shellMap[key]);
|
if (previousShellMap.hasOwnProperty(key)) {
|
||||||
|
if (currentShellMap.hasOwnProperty(key)) {
|
||||||
|
drawShell(previousShellMap[key]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
explodeShell(previousShellMap[key]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentWorld.robots.forEach(function(robot, idx) {
|
currentWorld.robots.forEach(function(robot, idx) {
|
||||||
drawRobot(robot, ROBOT_COLORS[idx]);
|
if (previousWorld.robots[idx]["damage"] !== robot["damage"]) {
|
||||||
|
drawRobot(robot, "#fff");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawRobot(robot, ROBOT_COLORS[idx]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (currentWorld.shells["next-id"] !== previousWorld.shells["next-id"]) {
|
if (currentWorld.shells["next-id"] !== previousWorld.shells["next-id"]) {
|
||||||
|
console.log("hoi");
|
||||||
nextSoundEl.get().play();
|
nextSoundEl.get().play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user