Video tutorial to create a simple game with Easel JS. Part 1 of a 3 part series. Easel JS is a Flash like Javascript framework for HTML5 Canvas element. Tutorial files available for download at http://www.webspaceinvader.com/simple-game.zip
Could you explain the use/reasoning behind the "|" in the following lines (I couldn't find anything on Google. Mainly cause I did not know what to look for):
bitmap.regX = bitmap.image.width/2|0;
bitmap.regY = bitmap.image.height/2|0;
ship.y = canvas.height*Math.random()|0
Thanks!!! I am enjoying going through your video tutorials. Very Helpful!
@VeryAngryBeaver
OH!!
That makes sense. Thanks for the help!
rockindahizzy 3 months ago
@rockindahizzy its the equivelant of
bitmap.regX = Math.floor(bitmap.image.width/2);
the reason to use |0 instead is because it runs faster
VeryAngryBeaver 3 months ago
Could you explain the use/reasoning behind the "|" in the following lines (I couldn't find anything on Google. Mainly cause I did not know what to look for):
bitmap.regX = bitmap.image.width/2|0;
bitmap.regY = bitmap.image.height/2|0;
ship.y = canvas.height*Math.random()|0
Thanks!!! I am enjoying going through your video tutorials. Very Helpful!
rockindahizzy 3 months ago