HTML ဂရပ်ဖစ်

ဂရပ်ဖစ် ပင်မစာမျက်နှာ

Google Maps

Maps မိတ်ဆက် Maps အခြေခံ Maps Overlays Maps ပွဲများ Maps ထိန်းချုပ်မှုများ Maps အမျိုးအစားများ Maps အကိုးအကား

SVG ကျူတိုရီရယ်

SVG နိဒါန်း HTML တွင် SVG SVG စတုဂံ SVG စက်ဝိုင်း SVG Ellipse SVG လိုင်း SVG Polygon SVG Polyline SVG လမ်းကြောင်း SVG စာသား SVG Stroking SVG Filters နိဒါန်း SVG မှုန်ဝါးခြင်းအကျိုးသက်ရောက်မှုများ SVG Drop Shadows SVG Linear SVG Radial SVG ဥပမာများ SVG အကိုးအကား

Canvas ကျူတိုရီရယ်

Canvas မိတ်ဆက် ကင်းဗတ်ဆွဲခြင်း။ Canvas Coordinates ကင်းဗတ် Gradients ကင်းဗတ်စာသား ကင်းဗတ်ပုံများ ကင်းဗတ်ရည်ညွှန်း

ကင်းဗတ်နာရီ

နာရီ မိတ်ဆက် နာရီမျက်နှာ နာရီနံပါတ်များ နာရီလက်များ နာရီစတင်

HTML ဂိမ်း

ဂိမ်းမိတ်ဆက် ဂိမ်း Canvas ဂိမ်းအစိတ်အပိုင်းများ ဂိမ်းထိန်းချုပ်သူများ ဂိမ်းအတားအဆီးများ ဂိမ်းရမှတ် ဂိမ်းပုံများ ဂိမ်းအသံ ဂိမ်းဆွဲငင်အား ဂိမ်းခုန်ခြင်း။ ဂိမ်းလှည့်ခြင်း။ ဂိမ်းလှုပ်ရှားမှု

ဂိမ်းလှုပ်ရှားမှု

Game Rotation အခန်းတွင် ရှင်းပြထားသည့် အစိတ်အပိုင်းများကို ပုံဆွဲနည်းအသစ်ဖြင့်၊ ရွေ့လျားမှုများသည် ပိုမိုပျော့ပြောင်းပါသည်။


အရာဝတ္ထုတွေကို ဘယ်လိုရွှေ့မလဲ။

အစိတ်အပိုင်း၏ လက်ရှိအမြန်နှုန်းကို ကိုယ်စားပြုသည့် တည်ဆောက်သူ speedသို့ ပိုင်ဆိုင်မှု တစ်ခု ထည့်ပါ ။component

နှင့် . newPos()တို့ကို အခြေခံ၍ အစိတ်အပိုင်း၏ အနေအထားကို တွက်ချက်ရန် နည်းလမ်း တွင် အပြောင်းအလဲအချို့ ပြုလုပ်ပါ speedangle

ပုံသေအားဖြင့်၊ အစိတ်အပိုင်းများသည် အပေါ်သို့ မျက်နှာမူနေပြီး၊ speed property ကို 1 သို့ သတ်မှတ်ခြင်းဖြင့်၊ အစိတ်အပိုင်းသည် ရှေ့သို့ စတင်သွားပါမည်။

ဥပမာ

function component(width, height, color, x, y) {
  this.gamearea = gamearea;
  this.width = width;
  this.height = height;
  this.angle = 0;
  this.speed = 1;
  this.x = x;
  this.y = y;
  this.update = function() {
    ctx = myGameArea.context;
    ctx.save();
    ctx.translate(this.x, this.y);
    ctx.rotate(this.angle);
    ctx.fillStyle = color;
    ctx.fillRect(this.width / -2, this.height / -2, this.width, this.height);
    ctx.restore();
  }
  this.newPos = function() {
    this.x += this.speed * Math.sin(this.angle);
    this.y -= this.speed * Math.cos(this.angle);
  }
}


အကွေ့များ ပြုလုပ်ခြင်း။

ဘယ်ညာ အလှည့်အပြောင်းလည်း လုပ်ချင်တယ်။ moveAngleလက်ရှိရွေ့လျားနေသောတန်ဖိုး သို့မဟုတ် လှည့်ခြင်းထောင့်ကို ညွှန်ပြသည့် ဟုခေါ်သော ပစ္စည်းအသစ်တစ်ခု ပြုလုပ် ပါ။ ပိုင်ဆိုင်မှုအပေါ် အခြေခံ၍ newPos()တွက်ချက်နည်းတွင် anglemoveAngle

ဥပမာ

မရွှေ့မပြောင်းနိုင်သော ပိုင်ဆိုင်မှုကို 1 ဟု သတ်မှတ်ပြီး ဘာဖြစ်မည်ကို ကြည့်ပါ-

function component(width, height, color, x, y) {
  this.width = width;
  this.height = height;
  this.angle = 0;
  this.moveAngle = 1;
  this.speed = 1;
  this.x = x;
  this.y = y;
  this.update = function() {
    ctx = myGameArea.context;
    ctx.save();
    ctx.translate(this.x, this.y);
    ctx.rotate(this.angle);
    ctx.fillStyle = color;
    ctx.fillRect(this.width / -2, this.height / -2, this.width, this.height);
    ctx.restore();
  }
  this.newPos = function() {
    this.angle += this.moveAngle * Math.PI / 180;
    this.x += this.speed * Math.sin(this.angle);
    this.y -= this.speed * Math.cos(this.angle);
  }
}

Keyboard ကိုသုံးပါ။

ကီးဘုတ်အသုံးပြုသောအခါ အနီရောင်စတုရန်းပုံသည် မည်သို့ရွေ့လျားသနည်း။ အပေါ်နှင့်အောက် ရွှေ့ပြီး ဘေးမှတစ်ဖက်သို့ ရွှေ့မည့်အစား သင် "တက်" မြှားကို အသုံးပြုသောအခါ အနီရောင်စတုရန်းကို ရှေ့သို့ရွှေ့ကာ ဘယ်ညာ မြှားများကို နှိပ်သည့်အခါ ဘယ်ညာ လှည့်ပါ။

ဥပမာ