-
-
Save aakashlpin/c1b946a0e167a29c58de0301364becdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function walk (x, y) { | |
var path = [{}, {}]; | |
var player = document.querySelector('#player'); | |
var i = 0; | |
var interval = setInterval(() => { | |
var cords = path.splice(i, 1); | |
player.setX(cords.x) | |
player.setY(coords.y) | |
i++; | |
}, 500) | |
return { | |
stop: interval | |
} | |
} | |
var stop = walk(); | |
stop(); | |
function gather (doSomething) { | |
// var stopWalk = walk(x, y); | |
// var stopChopDown = chopDown(); | |
// var stopReturn = walk(x, y); | |
var w = walk(x, y); | |
var stop = w.stop; | |
w | |
.then(function () { | |
stop = chopDown(); | |
}).then(function () { | |
walk(x, y) | |
}) | |
return { | |
stop, | |
} | |
} | |
gather.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tasks = [] | |
player.on('walk', (x, y) => { | |
tasks.push(generateWalkTasks(x, y)) | |
}) | |
player.on('gather', (obj) => { | |
tasks.push() | |
}) | |
setInterval(() => { | |
}, 500) | |
player.on('fight', (opponent) => { | |
tasks.push( | |
generateFightTasks.bind(opponent) | |
); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment