javascript - Game Not Detecting Collision Between Character and border -


all collision working accept when character collides border. want character re-spawn when character collides border use code:

 left = 10;  var releft = {'left':left + "px"};  $('#char').css(releft);  top = 10;  var retop = {'top':top + "px"};  $('#char').css(retop); 

but not when character collides it.

note: if see full code of game more information on code writing me better can go torin.eschweb.com , click ctrl + u , show code.

in checkcollision function should add check if player off screen.

adding end of function give basic idea i'm referring to.

     if($('#char').offset().top < 0 || $('#char').offset().top > window.innerheight || $('#char').offset().left < 0 || $('#char').offset().left > window.innerwidth ){       console.log('off screen');      } 

i suggest making function can detect if off screen.

the example gave not take account offsets. i'm trying keep simple possible.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -