js-browser-tile-game/js/animation.js
Aaron Yarborough 4b4e124c57 Initial commit
2019-12-02 10:05:48 +00:00

43 lines
No EOL
1,019 B
JavaScript

function Animation() {
this.name = "";
this.steps = [];
}
Animation.prototype.setAni = function(animation) {
// Set animation name
this.name = animation;
// Load content from animation file
var content = getFileContent("assets/animations/" + animation);
var lines = content.split("\n");
// Parse content and store frames
for (var i = 0; i < lines.length; i++) {
// Ignore blank lines
if (lines[i] == "") continue;
if (end == true) continue;
// If it hasn't found the ANI line yet
if (inside == false && lines[i] == "ANI") {
// Tell the script it's found the ani line
console.debug("found inside!");
inside = true;
continue;
// If it has already found the ANI line
} else if (inside == true) {
// Check if it's the end of the ani
if (lines[i] == "ANIEND") {
// Tell the script it's the end of the ani
end = true;
continue;
} else {
// Add the line to the steps list
this.steps.push(lines[i]);
}
}
}
console.debug(this.steps);
}