Message from JavaScript discussions

April 2019

— Try to explain what you need

— 

Let time = null;
const func = null;
class Game {
constructor(pace, money){
this.hour = (a) =>{
a = Math.floor(this.startTime/60)
return (a > 23) ?a = 0 :a
};
this.minute = (a) => {
a = this.startTime%60
return (a < 10) ?'0'+a :a }
this.startTime = 464;
this.pace = pace;
this.money = money; //12
this.interval = null;
this.process = null;
}
displayTime(){
return this.hour() +':'+this.minute()
}
tick(){
return this.startTime++
}
play(...func){

const queue = (...func)=>{
for(let f of func){
return f()
}
}

this.interval = setInterval(()=>{
console.log(this.displayTime());
queue(...func)
this.tick()
console.log(time);
time++;}, 1000)
}
pause(){
return clearInterval(this.interval)
}
}
const newGame = new Game(1000, 10000);
time = newGame.startTime
const test =()=>newGame.pause()
setTimeout(test, 8000)

const test2 = () => console.log('walking')

const manage = (action, duration) => {
newGame.pause()
newGame.play(()=>{
for(let a = 0; a < action.length; a){
let first = action[0]
let second = action[1]
let third = action[2]
}
return
})
const resume = () => {
newGame.pause()
newGame.play()
}
setTimeout(resume, duration)
}
newGame.play()

const testing = () => manage([test2, test2], 4000)
setTimeout(testing, 3000)

— Show how you want it to work when you call your function

— In the code above the manage(action, 4000) must have pure variables instead of the array

— And why must you have these?

— Hello.. any one has js code to making binary search tree in html canvas by dynamic input

— I can't take time to explain now I'll be back

— Ok so manage(action, duration) captures the array, and each item of the array will be a function when called in a nested function newGame.play() so it has to be passed as variables

Message permanent page

— "passed as variables"

— I still don't understand what you mean by that

— If a nested function also needs these functions in the array, you should just pass the array to that function as well

Message permanent page

— I'm starting to think I will just settle for a single process then