vanilla js game loop 1

vanilla js game loop

function print_hello() {
  console.log("Hello!");
  // Continue playing the game - aka Recursive trigger motherfucker
  setTimeout(print_hello,500)
}

// Trigger aka Start Game
setTimeout(print_hello, 500);

Here is what the above code is Doing:
1. We’re creating a function called print_hello()
2. We’re printing “Hello!” to the console
3. We’re calling the function print_hello() again, but with a delay of 500 milliseconds
4. We’re calling the function print_hello() for the first time, with a delay of 500 milliseconds

So, what’s happening here?

We’re calling the function print_hello() for the first time, with a delay of 500 milliseconds.

After 500 milliseconds, the function print_hello() is called.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the console.

Then, we’re calling the function print_hello() again, but with a delay of 500 milliseconds.

After another 500 milliseconds, the function print_hello() is called again.

Inside the function, we’re printing “Hello!” to the

Similar Posts