More Related Content
PDF
PDF
PDF
Deep Residual Learning (ILSVRC2015 winner) PPTX
PPTX
Lighting you up in Battlefield 3 PPTX
Past, Present and Future Challenges of Global Illumination in Games PPTX
The Rendering Pipeline - Challenges & Next Steps PDF
[DL Hacks 実装]MIDINET: A Convolutional Generative Adversarial Network For Symb... What's hot
PPTX
Photogrammetry and Star Wars Battlefront PDF
Graphics Gems from CryENGINE 3 (Siggraph 2013) PDF
PDF
[DL輪読会]MuseGAN: Multi-track Sequential Generative Adversarial Networks for Sy... PPTX
【DL輪読会】DreamFusion: Text-to-3D using 2D Diffusion PPT
Secrets of CryENGINE 3 Graphics Technology PPTX
顔認識アルゴリズム:Constrained local model を調べてみた PPTX
A Step Towards Data Orientation PDF
MMORPGで考えるゲームデザイン(2014年改訂版) PPSX
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14 PDF
JTubeSpeech: 音声認識と話者照合のために YouTube から構築される日本語音声コーパス PDF
Bindless Deferred Decals in The Surge 2 PPTX
Parallel Futures of a Game Engine (v2.0) PPTX
Physically Based and Unified Volumetric Rendering in Frostbite PPTX
PPTX
Moving Frostbite to Physically Based Rendering PPT
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing... PDF
Siggraph2016 - The Devil is in the Details: idTech 666 More from Project Samurai
PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 12 PDF
Python で画像処理をやってみよう! -SIFT 第7回- PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 9 PDF
Python で画像処理をやってみよう! -SIFT 第6回- PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 8 PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 7 PDF
Python で画像処理をやってみよう! -SIFT 第5回- PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 6 PDF
PDF
Make your Artificial Intelligence PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 4 PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 3 PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 2 PDF
数学的基礎から学ぶ Deep Learning (with Python) Vol. 1 PDF
Python で画像処理をやってみよう!第11回 - SIFT Vol.1 キーポイント候補 - PDF
Instagram API を使ってウェブアプリを作ろう! PDF
Pythonで画像処理をやってみよう!第8回 - Scale-space 第7回 - PDF
JavaScript でパックマン!第7回 (一旦最終回) PDF
Pythonで画像処理をやってみよう!第7回 - Scale-space 第6回 - PDF
JavaScript でパックマン!第4回
- 1.
MPS Setagaya 第7回(2015/10/11) ミーティング
JavaScript でパックマン! 第4回
金子純也
Morning Project Samurai 代表
MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
Step1. 手動で口パク!
var cv= document.getElementById(‘pac-man');
var ctx = cv.getContext("2d");
function drawPacman(ctx ,cx, cy){
ctx.strokeStyle="#FF0000";
ctx.fillStyle="#FF0000";
ctx.beginPath();
ctx.arc(cx, cy, 50, 30 * Math.PI / 180, 330 * Math.PI / 180);
ctx.lineTo(cx, cy);
ctx.lineTo(cx + 50 * Math.cos(30 * Math.PI / 180), cy +
50 * Math.sin(30 * Math.PI / 180));
ctx.fill();
}
drawPacman(ctx, 50, 50);
θ=30
MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko
- 8.
Step1. 手動で口パク!
var cv= document.getElementById(‘pac-man');
var ctx = cv.getContext("2d");
function drawPacman(ctx ,cx, cy, theta){
ctx.strokeStyle="#FF0000";
ctx.fillStyle="#FF0000";
ctx.beginPath();
ctx.arc(cx, cy, 50, theta * Math.PI / 180,
(360 - theta) * Math.PI / 180);
ctx.lineTo(cx, cy);
ctx.lineTo(cx + 50 * Math.cos(theta * Math.PI / 180),
cy + 50 * Math.sin(theta * Math.PI / 180));
ctx.fill();
}
drawPacman(ctx, 50, 50, 30);
drawPacman(ctx, 150, 50, 10);
θ=theta
MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko
- 9.
Step2. 自動でパクパクさせる
var cv= document.getElementById(‘pac-man');
var ctx = cv.getContext("2d");
var cx = 50, cy = 50, theta = 30, dTheta = -1;
function drawPacman(ctx ,cx, cy, theta){ … }
function animationLoop(timestamp) {
if (theta >= 30) dTheta = -1;
else if (theta <=0 ) dTheta = 1;
theta += dTheta;
ctx.clearRect(0, 0, cv.width, cv.height);
drawPacman(ctx, cx, cy, theta);
window.requestAnimationFrame(animationLoop);
}
window.requestAnimationFrame(animationLoop);MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko
- 10.
- 11.
- 12.
- 13.
イベントの例
• onkeydown: キーの押下イベント
•onkeyup: キーが離されたイベント
• onmousedown: マウスのボタンが押下された
• onmouseup: マウスのボタンが離された
MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko
- 14.
要素へのイベントハンドラの登録
cv.tabIndex = 1;
cv.onkeydown= function(event) {
event.preventDefault();
switch(event.keyCode) {
case 37:
cx -= 1; break;
case 38:
cy -= 1; break;
case 39:
cx += 1; break;
case 40:
cy += 1; break;
}
};
MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko
- 15.
- 16.
- 17.
- 18.
改良版 onkeydown イベントハンドラ
varmoveDirection = [0, 0] //x, y
cv.tabIndex = 1;
cv.onkeydown = function(event) {
event.preventDefault();
switch(event.keyCode) {
case 37:
moveDirection[0] = -1; break;
case 38:
moveDirection[1] = -1; break;
case 39:
moveDirection[0] = 1; break;
case 40:
moveDirection[1] = 1;
}
}; MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko
- 19.
改良版 描画関数
function animationLoop(timestamp){
if (theta >= 30) dTheta = -1;
else if (theta <=0 ) dTheta = 1;
theta += dTheta;
cx += moveDirection[0];
cy += moveDirection[1];
ctx.clearRect(0, 0, cv.width, cv.height);
drawPacman(ctx, cx, cy, theta);
window.requestAnimationFrame(animationLoop);
}
MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko
- 20.
- 21.
cv.onkeyup = function(event){
event.preventDefault();
switch(event.keyCode) {
case 37:
moveDirection[0] = 0;
break;
case 38:
moveDirection[1] = 0;
break;
case 39:
moveDirection[0] = 0;
break;
case 40:
moveDirection[1] = 0;
}
}; MPS Setagaya 第7回 (2015/10/11) ミーティング (c) Junya Kaneko