Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of WebWorkers for gaming - HTML5 Game Programming question

 
andrew ennamorato
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web workers seem like an important addition to Javascript, especially in terms of gaming. Being able to run a 'thread' to calculate say, collision detection, seems valuable. Wondering if you cover web workers in the book at all, or if they are too much a pain to use due to their limitations (no access to DOM, for ex).

 
James Williams
author
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,

Web Workers are covered. Web Workers communicate with the host page via message passing. If you can modularize your code in such a way to separate the computation needed on a worker thread from say the UI drawing, you won't have a problem with not accessing the DOM from the worker.
 
andrew ennamorato
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool, good to hear. I haven't seen a lot on web workers re: the whole 'HTML5' thing (seems like web sockets, local storage and geolocation get most of the pub) so something to look forward to in the book.

Thanks!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic