game loops
play

Game Loops CIS 580 - Fundamentals of Game Programming Hangman - PowerPoint PPT Presentation

Game Loops CIS 580 - Fundamentals of Game Programming Hangman Game Phases Game Loop Turn-based vs. Real-Time Turn-Based Real-Time Fixed-Timestep vs. Variable Timestep Example - Ballistic Motion x (delta t/timestep) Hybrid Game Loop


  1. Game Loops CIS 580 - Fundamentals of Game Programming

  2. Hangman

  3. Game Phases

  4. Game Loop

  5. Turn-based vs. Real-Time

  6. Turn-Based

  7. Real-Time

  8. Fixed-Timestep vs. Variable Timestep

  9. Example - Ballistic Motion

  10. x (delta t/timestep) Hybrid Game Loop

  11. Every Nth loop Every Nth loop Variable update/render Game Loop

  12. Coding Game Loops

  13. function loop() { setTimeout( loop, 16.666); // Asyncronous processInput(); update(); render(); } // 0.016666s = 1/60s setTimeout( loop, 16.666); setTimeout game loop

  14. function loop() { processInput(); update(); render(); } // 0.016666s = 1/60s var loopHandle = setInterval( loop, 16.666); setInterval game loop

  15. function loop() { processInput(); update(); render(); loop(); } recursive game loop

  16. function loop(timestamp) { processInput(); update(); render(); requestAnimationFrame(loop); } requestAnimationFrame(loop); Simple request animation frame game loop

  17. var start = null; function loop(timestamp) { var progress; if (start === null) start = timestamp; progress = timestamp - start; processInput(); update(progress); render(progress); requestAnimationFrame(loop); } requestAnimationFrame(loop); “Variable”-rate setTimeout game loop

  18. var start = null; var timestep = 16.6666; // 0.016666s = 1/60s function loop(timestamp) { var progress; if (start === null) start = timestamp; progress = timestamp - start; processInput(); while(progress > timestep) { update(progress); progress -= timestep; start += timestep; } render(progress); requestAnimationFrame(loop); } requestAnimationFrame(loop); Fixed Timestep setTimeout game loop

  19. request animation frame polyfill

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend