Javascriptを使って、シューティングゲームを作成中です。以下に示してありますコードの中にあるrand(0,field_w)<<8、rand(0,field_h)<<8のビット演算子の理解に苦しんでいます。
私の今の理解ですと、rand()で得られた数を2進数に直して、2進数にしたときの1の位置を左に8ずらすという理解でいます。その考えで合っているのか、全く違うのか、また実際に起きていることのイメージを具体的に教えていただきたいです。不慣れではありますが、よろしくお願いいたします。
~HTML~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="sass/style.css"> <title>デジタル時計</title> </head> <body> <canvas id="can"></canvas> <script src="js/main.js"></script> </body> </html> ~Javascript~ /*画面サイズ*/ const screen_w = 180; const screen_h = 320; /*キャンバスサイズ*/ const canvas_w = screen_w*2; const canvas_h = screen_h*2; /*フィールドサイズ*/ const field_w = screen_w*2 const field_h = screen_h*2 /*キャンバス*/ let can = document.getElementById('can'); let con = can.getContext('2d'); can.width = canvas_w; can.height = canvas_h ; function rand(min,max){ return Math.floor(Math.random()*(max-min+1))+min; } class Star{ constructor(){ this.x = rand(0,field_w)<<8; this.y = rand(0,field_h)<<8; this.vx = 0; this.vy = rand(30,200); this.sz; } draw(){ } update(){ this.x += this.vx; this.y += this.vy; } } コード