Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ゼロからはじめるゲームプログラミング

E63c0cf4a77b1799e02f97689db83d91?s=47 kaidouji85
June 16, 2018
810

 ゼロからはじめるゲームプログラミング

E63c0cf4a77b1799e02f97689db83d91?s=128

kaidouji85

June 16, 2018
Tweet

More Decks by kaidouji85

Transcript

  1. θϩ͔Β͸͡ΊΔ ήʔϜϓϩάϥϛϯά  ϓϩάϥϛϯάੜ์ૹษڧձୈճˏαΠϘ΢ζגࣜձ ࣾদࢁΦϑΟε։࠵ ஛಺ɹ༎հ

  2. ࣗݾ঺հ ஛಺ɹ༎հ ϓϩάϥϚʔ +4େ޷͖ ϓϩੜͪΌΜେ޷͖

  3. Ѫඤݝͱ͍͑͹ ԿΛࢥ͍ු͔΂·͔͢ʁ

  4. ͺͬ΍ΓϙϯδϡʔεͰ͢ΑͶʂ

  5. Ͱ͸ɺϙϯͱ͍͑͹ɺ ԿΛࢥ͍ු͔΂·͔͢ʁ

  6. ήʔϜͷ10/(Ͱ͢ΑͶʂ

  7. Ѫඤ ˣ ϙϯδϡʔε ˣ 10/( ˣ ήʔϜ

  8. ͱ͍͏༁Ͱ ήʔϜϓϩάϥϛϯά ͷ࿩Λ͠·͢

  9. ࠓ೔ͷΰʔϧ

  10. αϯϓϧίʔυ ࠓ೔ղઆ͢Δαϯϓϧίʔυ͸͜͜Ͱ͢ IUUQTHJUIVCDPNLBJEPVKJCFHJOHBNF

  11. ΞδΣϯμ Ξχϝʔγϣϯ͢Δ ΩϟϥΫλʔΛૢ࡞͢Δ ఢͱ౰ͨΓ൑ఆΛ࡞Δ ఢΛྔ࢈͢Δ

  12. ΞδΣϯμ Ξχϝʔγϣϯ͢Δ ΩϟϥΫλʔΛૢ࡞͢Δ ఢͱ౰ͨΓ൑ఆΛ࡞Δ ఢΛྔ࢈͢Δ

  13. αϯϓϧͷσϞ

  14. αϯϓϧ֓ཁ ΩϟϥΫλʔ͕ӈʹಈ͚ͩ͘ )5.-ʹ͸ը૾ɺ+4ϑΝΠϧ͕഑ஔ͞Ε͍ͯΔ +4Ͱը૾ΛΞχϝʔγϣϯ͍ͤͯ͞Δ

  15. Ξχϝͷجຊ͸ ύϥύϥອըͰ͢

  16. ͦͷୈҰา͸ ੩ࢭըΛඳ͘͜ͱͰ͢

  17. ղઆ Ξχϝʔγϣϯ͞ΕΔʹ͸ɺ
 ੩ࢭը͕ඳ͚ͳ͍ͱ࿩ʹͳΒͳ͍ ͜ͷ৔߹͸ϓϨΠϠʔΛ޷͖ͳҐஔʹදࣔ͢Δ ͜ͱ͕Ͱ͖ͳ͍ͱବ໨ Ͳ͏͢Ε͹ɺ)5.-ը૾Λ޷͖ͳҐஔʹ
 දࣔͰ͖Δͷ͔

  18. USBOTGPSNUSBOTMBUF ը૾Λ޷͖ͳҐஔʹදࣔͰ͖ΔελΠϧ \USBOTGPSNUSBOTMBUF Y࠲ඪ Z࠲ඪ ^ IUUQTEFWFMPQFSNP[JMMBPSHKBEPDT8FC $44USBOTGPSN

  19. )5.-ͷ࠲ඪܥ 9 : 

  20. ήʔϜϧʔϓ ήʔϜϓϩάϥϜͰ͸ɺύϥύϥອըͷཁྖͰ ΞχϝʔγϣϯΛ࣮ݱ͍ͯ͠Δ ύϥύϥອըΛϓϩάϥϜͰ࠶ݱ͢Δͱɺ
 ແݶϧʔϓʹͳΔ ͜ͷΑ͏ͳϧʔϓΛɺήʔϜϧʔϓͱ͍͏ αϯϓϧͰ͸ɺҰఆִؒͰϓϨΠϠʔ9࠲ඪ ʹ ͍ͯ͠Δ

  21. SFRVFTU"OJNBUJPO'SBNF )5.-ͰήʔϜϧʔϓΛ࣮ݱ͢ΔͨΊͷ΋ͷ Ҿ਺ʹࢦఆͨؔ͠਺Λɺ͍͍ײ͡ͷλΠϛϯά Ͱݺͼग़ͯ͘͠ΕΔ '14͘Β͍ʹ͸ͳΔ IUUQTEFWFMPQFSNP[JMMBPSHKBEPDT8FC "1*8JOEPXSFRVFTU"OJNBUJPO'SBNF

  22. SFRVFTU"OJNBUJPO'SBNFྫ function gameLoop(time) { requestAnimationFrame(gameLoop); playerPos.x += 4; } requestAnimationFrame(gameLoop);

  23. ΞδΣϯμ Ξχϝʔγϣϯ͢Δ ΩϟϥΫλʔΛૢ࡞͢Δ ఢͱ౰ͨΓ൑ఆΛ࡞Δ ఢΛྔ࢈͢Δ

  24. αϯϓϧͷσϞ

  25. αϯϓϧ֓ཁ Ϛ΢εΛԡ͍ͯ͠Δ͚࣌ͩɺΩϟϥ͕ӈʹਐΉ

  26. Ϛ΢εΠϕϯτͰ ૢ࡞ঢ়ଶΛͱΖ͏

  27. ղઆ JG ϘλϯΛԡͨ͠ Y ͱ͍ͨ͠ )5.-ʹ͸NPVTFEPXOɺNPVTFVQͱ͍͏
 Πϕϯτ͕༻ҙ͞Ε͍ͯΔ Πϕϯτ͸ى͖ͨॠؒʹ໋ྩ͕࣮ߦ͞ΕΔ΋ͷ ͳͷͰɺήʔϜϧʔϓ಺Ͱ௚઀࢖͑ͳ͍ ͔ͩΒɺม਺ʹ݁ՌΛอ͓࣋ͯ͘͠

  28. αϯϓϧͷσϞ

  29. αϯϓϧ֓ཁ Ϛ΢εΛԡ͍ͯ͠ΔؒɺϓϨΠϠʔ͕Ϛ΢εϙ Πϯλʹ޲͔ͬͯҠಈ͢Δ ϓϨΠϠʔ͕Ϛ΢εʹۙͮ͘ͱɺ
 Կނ͔ϒϨΔ ݁ߏͳස౓ͰɺϓϨΠϠʔ͕બ୒ঢ়ଶʹͳΔ

  30. ϕΫτϧԋࢉͰ ΩϟϥͷڍಈΛ࣮ݱ

  31. Ϛ΢εΛԡͨ࣌͠ͷڍಈ Ϛ΢εͷํ޲ʹ ϐΫηϧҠಈ

  32. 1 QY QZ  ϓϨΠϠʔ࠲ඪ . UY UZ  Ϛ΢ε࠲ඪ

    Ҡಈྔ1.c1.cY଎౓ c.1c 1. WY WZ
  33. 1 QY QZ  ϓϨΠϠʔ࠲ඪ . UY UZ  Ϛ΢ε࠲ඪ

    1. WY WZ 
  UYQY UZQZ c1.c 1. WY WZ
  34. 1 ϓϨΠϠʔ࠲ඪ . Ϛ΢ε࠲ඪ 1. WY WZ c1.c㲋 WY? WZ?

    c1.c
  35. 1 QY QZ  ϓϨΠϠʔ࠲ඪ . UY UZ  Ϛ΢ε࠲ඪ

    Ҡಈྔ WYc1.cY଎౓  WZc1.cY଎౓ c1.c 1. WY WZ
  36. αϯϓϧͷσϞ

  37. αϯϓϧ֓ཁ ϓϨΠϠʔ͕બ୒ঢ়ଶʹͳΔόά͕࣏͍ͬͯΔ ϓϨΠϠʔ͕Ϛ΢εʹۙͮ͘ͱϒϨΔόά͕
 ࣏͍ͬͯΔ

  38. *.(Λ΍ΊΑ͏

  39. ͳͥબ୒Ͱ͖Δͷ͔ ը૾λάͳͷͰɺ
 Ϛ΢εΫϦοΫͰબ୒Ͱ͖ͯ͠·͏ ͔ͩΒɺը૾λάͰͳ͘͢ EJWλάʹͯ͠ɺഎܠը૾ͱͯ͠
 ݩʑͷը૾Λઃఆ͢Δ

  40. ڑ཭ʹԠͯ͡ ҠಈྔΛௐ੔͠Α͏

  41. ղઆ ϓϨΠϠʔɺϚ΢εͷڑ཭͕ҠಈྔΑΓখ͍͞ ৔߹ɺϓϨΠϠʔ͕Ϛ΢εΛಥ͖ൈ͚ͯ͠·͏ ۩ମྫ͸࣍Ͱղઆ

  42. ϒϨΔݪҼ ϐΫηϧ ϐΫηϧ ϓϨΠϠʔ Ϛ΢ε

  43. ϒϨΔݪҼ ϐΫηϧ ϐΫηϧ ϓϨΠϠʔ Ϛ΢ε

  44. ϒϨΔݪҼ ϐΫηϧ ϐΫηϧ ϓϨΠϠʔ Ϛ΢ε ϐΫηϧ

  45. ϒϨΔݪҼ ϐΫηϧ ϓϨΠϠʔ Ϛ΢ε ϐΫηϧ

  46. ϒϨΔݪҼ ϐΫηϧ ϓϨΠϠʔ Ϛ΢ε ϐΫηϧ

  47. ղܾࡦ Ҡಈྔڑ཭ Ҡಈྔͷ෼͚ͩਐΉ Ҡಈྔڑ཭ ڑ཭ͷ෼͚ͩਐΉ

  48. ϓϨΠϠʔ Ϛ΢ε ϓϨΠϠʔ Ϛ΢ε ϐΫηϧ ϐΫηϧ ϐΫηϧ ϐΫηϧ Ҡಈྔڑ཭ Ҡಈྔڑ཭

  49. ΞδΣϯμ Ξχϝʔγϣϯ͢Δ ΩϟϥΫλʔΛૢ࡞͢Δ ఢͱ౰ͨΓ൑ఆΛ࡞Δ ఢΛྔ࢈͢Δ

  50. αϯϓϧͷσϞ

  51. αϯϓϧ֓ཁ ࠨʹҠಈ͢Δ͚ͩͷఢΛ௥Ճͨ͠ )5.-ϑΝΠϧʹఢը૾Λ௥Ճ ͦΕҎ֎͸ɺࠓ·Ͱ΍ͬͨ͜ͱͷ૊Έ߹Θͤ

  52. αϯϓϧͷσϞ

  53. αϯϓϧ֓ཁ ఢͱͷ౰ͨΓ൑ఆΛ࣮૷ͨ͠ ήʔϜΦʔόʔ͕ग़ଓ͚Δόά͕͋Δ

  54. ౰ͨΓ൑ఆ͸ ఺ؒͷڑ཭ΛݟΑ͏

  55. ౰ͨΓ൑ఆ ౰ͨΓ൑ఆͷํ๏͸৭ʑ͋Δ͕ɺ
 ఺ؒͷڑ཭Ͱ൑ఆ͢Δํ๏ָ͕Ͱ͢ ϓϨΠϠʔɺఢͷڑ཭͕Ұఆ஋ҎԼͳΒ
 ౰͍ͨͬͯΔͱ൑ఆ͠·͢

  56. 1 QY QZ  ϓϨΠϠʔ࠲ඪ & FY FZ  ఢ࠲ඪ

    ఺ؒͷڑ཭ 㲋 FYQY ?  FZQZ ? ڑ཭
  57. αϯϓϧͷσϞ

  58. αϯϓϧ֓ཁ ήʔϜΦʔόʔ͕ճ͚ͩग़ΔΑ͏ʹͳͬͨ ήʔϜΦʔόʔͨ͠Βɺ
 ϓϨΠϠʔ͕ফ͑ΔΑ͏ʹͳͬͨ

  59. ऴΘΒͳ͍(BNF0WFSͷݪҼ ήʔϜΦʔόʔ൑ఆϩδοΫ͕ɺ
 ϓϨΠϠʔͱఢͷ઀৮͚͔ͩͩΒ Ϛ˓ΦͰɺνϏʹͳͬͨ࣌ͷແఢ͕࣌ؒ
 ͳ͍ͱͲ͏ͳΔͰ͠ΐ͏ ˢσΧΠঢ়ଶͰ΋ɺҰॠͰࢮʹ·͢ ࠓճ΋ͦΕͱಉ͡ݪҼͰ͢

  60. ࢮ๢ϑϥάΛ ௥Ճ͠·͠ΐ͏

  61. ղઆ ϓϨΠϠʔ͕ੜ͖͍ͯΔ͔ɺࢮΜͰ͍Δ͔Λ
 දݱ͢Δม਺Λ௥Ճ͠·͠ΐ͏ ϓϨΠϠʔ͕ੜ͖͍ͯΔ৔߹ͷΈɺ(BNF0WFS Λදࣔ͠·͢ ˢಉ͡λΠϛϯάͰɺϓϨΠϠʔΛࢮ๢ঢ়ଶʹ ͠·͠ΐ͏

  62. ΞδΣϯμ Ξχϝʔγϣϯ͢Δ ΩϟϥΫλʔΛૢ࡞͢Δ ఢͱ౰ͨΓ൑ఆΛ࡞Δ ఢΛྔ࢈͢Δ

  63. αϯϓϧͷσϞ

  64. αϯϓϧ֓ཁ ڍಈ͸Կ΋มΘ͍ͬͯ·ͤΜ ίʔυͷߦ਺͕૿͑ͨͷͰɺϑΝΠϧ෼ׂͨ͠

  65. ΫϥεԽ͢Ε͹ ྔ࢈Ͱ͖Δ

  66. ͳͷͰɺطଘϑΝΠϧΛ
 Ϋϥε෼ׂ͠·͠ΐ͏

  67. Ϋϥεͱ͸ σʔλͱͦΕʹؔ͢Δૢ࡞ΛɺҰͭͷ෦඼
 ʹ·ͱΊΔ ˢͷ͜ͱΛΫϥεͱ͍͏ ΫϥεΛ࡞Δج४ɺ࢖͍ํͳͲ͸
 ΦϒδΣΫτࢦ޲Λษڧ͢Δͱ͍͍

  68. σʔλ ૢ࡞ ࢀর ϓϩάϥϜͷجຊߏ੒

  69. σʔλ ૢ࡞ ࢀর ϓϩάϥϜͷجຊߏ੒ ϞδϡʔϧͰ·ͱΊΔ

  70. σʔλ ૢ࡞ ࢀর ϓϩάϥϜͷجຊߏ੒ Ϋϥε ϝϯόม਺ ϝιου

  71. ࠓճͷΫϥε෼͚ ϓϨΠϠʔ ఢ λονؔ࿈ ౰ͨΓ൑ఆ ϕΫτϧεΧϥྔܭࢉ

  72. αϯϓϧͷσϞ

  73. αϯϓϧ֓ཁ ୔ࢁͷఢ͕ग़ΔΑ͏ʹͳͬͨ ιʔεͷ)5.-ϑΝΠϧ͔ΒΩϟϥΫλʔ
 %*7͕ফ͑ͨ Ͱ΋ΠϯεϖΫλͰݟΔͱɺ%*7͸ͪΌΜͱ ͋Δ

  74. ఢ͕ྔ࢈Ͱ͖ͳ͍ʁ ΦϒδΣΫτࢦ޲తʹ͸ɺఢΛྔ࢈͚ͨ͠Ε͹
 ͦͷ෼͚ͩఢΫϥεΛOFX͢Ε͹͍͍ ͦΕͰ΍Ζ͏ͱͨ͠Βɺఢ͕ମ͔͠
 දࣔ͞Εͳ͔ͬͨ ˢఢΫϥε͸)5.-্ͷ%*7Λࢀর͍ͯ͠Δ
 ͷͰɺఢͷ਺͚ͩಉλά͕ඞཁʹͳΔ

  75. ίϯετϥΫλͰ EJWΛੜ੒͍ͯ͠Δ

  76. ղઆ ఢΫϥεͷίϯετϥΫλͰ%*7λάΛੜ੒ ˢͷ%*7λάΛɺ+BWB4DSJQUͰ)5.-ʹ௥Ճ ͜ΕͰɺ%*7λά͕ಈతʹ௥Ճ͞ΕΔ࢓૊Έ͕ ੔ͬͨ

  77. αϯϓϧͷσϞ

  78. αϯϓϧ֓ཁ ڍಈ͸มߋͳ͠ ݟ௨͠Λྑ͘͢ΔͨΊɺఢͷੜ੒ॲཧɺ
 ήʔϜϧʔϓॲཧΛ·ͱΊͨΫϥεΛ௥Ճ ·ͱΊΔ࣌ʹ΋ίπ͕͋ΔɺͦΕ͸ʜʜ

  79. ഑ྻʹಥͬࠐΜͰ ϧʔϓͰҰׅॲཧ͢Δ

  80. #&'03& const enemy1 = new Enemy(); const enemy2 = new

    Enemy(); const enemy3 = new Enemy(); enemy1.gameLoop(); enemy2.gameLoop(); enemy3.gameLoop();
  81. "'5&3 this._enemyList = [ new Enemy(), new Enemy(), new Enemy()

    ]; this._enemyList.forEach(enemy => { enemy.gameLoop(); });
  82. ղઆ ఢΛྔ࢈ͯ͠΋ɺݺͼग़͢ϝιου͸શͯಉ͡ ಉ͡΋ͷΛఢͷ਺͚ͩίϐϖ͢Δͷ͸͠ΜͲ͍ ͔ͩΒɺఢΛ഑ྻม਺ʹηοτͯ͠ϧʔϓ෼Ͱ ճͯ͠ಉ͡ॲཧΛͤ͞Δ

  83. ͓ർΕ༷Ͱͨ͠ ղઆ͸Ҏ্Ͱ͢

  84. ·ͱΊ ήʔϜͷجຊ͸ύϥύϥອըͷݪཧͰ͋Δ Ҡಈɺ౰ͨΓ൑ఆͷ࣮ݱํ๏Λ஌Δʹ͸ɺ
 ਺ֶɾ෺ཧΛษڧ͠Α͏ ΫϥεԽ ഑ྻϧʔϓͰΩϟϥΛྔ࢈͠Α͏

  85. ͝ਗ਼ௌ͋Γ͕ͱ͏ ͍͟͝·ͨ͠

  86. ͓·͚5XFFO

  87. αϯϓϧͷσϞ

  88. αϯϓϧ֓ཁ ϓϨΠϠʔɺఢͷಈ͖Λ5XFFOʹஔ͖׵͑ͨ ఢͷಈ͖͕೿खʹͳͬͨ (BNF0WFS͕ঃʑʹු͖ग़ΔΑ͏ʹͳͬͨ

  89. 5XFFOΛ࢖͍·͠ΐ͏

  90. 5XFFOͱ͸ 5XFFOͱ͸ಈ͖Λొ࿥ͯ͠ɺܦա࣌ؒʹԠͨ͡ ஋ʹࣗಈతʹηοτͯ͘͠ΕΔ΋ͷͰ͋Δ ʮ44ඵ͔͚ͯɺม਺9Λʹมߋ͢Δʯ
 ͱ͍͏ײ͡ʹࢦఆ͢Δ 5XFFOΛ࢖͑͹ɺෳࡶͳಈ͖Ͱ΋؆୯ʹ
 ࣮ݱͰ͖Δ

  91. 5XFFOͷྫ ඵޙͳΒ ʮඵޙʹʯͷ5XFFO 9

  92. +4ͷ5XFFOϥΠϒϥϦ UXFFOKT
 IUUQTHJUIVCDPNUXFFOKTUXFFOKT 5XFFO.BY
 IUUQTHSFFOTPDLDPNUXFFONBY 7FMPDJUZKT
 IUUQWFMPDJUZKTPSH

  93. ·ͨɺ
 ࠓ·Ͱͷαϯϓϧʹ͸ க໋తͳ໰୊͕͋Γ·͢

  94. ͦΕ͸ '14ͷมߋʹऑ͍͜ͱ

  95. '14ͱ͸ 'SBNF1FS4FDPOEͷུ ඵؒʹԿճը໘͕ߋ৽͞ΕΔ͔ͱ͍͏͜ͱ SFRVFTU"OJNBUJPO'SBNF͸'14ʹͳΔΑ͏
 Α͠ͳʹ΍ͬͯ͘ΕΔ

  96. ࠓ·Ͱͷαϯϓϧͷ໰୊ ήʔϜϧʔϓ͕'14લఏͰॻ͔Ε͍ͯΔ '14͕ഒʹͳͬͨΒɺΩϟϥͷҠಈ଎౓΋ഒ SFRVFTU"OJNBUJPO'SBNF͸όοςϦʔɺ
 ϒϥ΢βͷΞΫςΟϒঢ়ଶͳͲͰ'14ҎԼʹ ͳΔ͜ͱ͕͋Δ

  97. ͳͥ5XFFOͰղܾ͢Δͷ͔ 5XFFO͸։͔࢝Βͷܦա࣌ؒʹͷΈґଘ͔Β ؒʹԿճߋ৽Λڬ΋͏͕ɺ։͔࢝ΒඵޙͳΒ ৗʹಉ͡஋ʹͳΔ ࣍Ͱ۩ମྫΛղઆ

  98.    ඵ ඵ ̎ඵ ̍ϑϨʔϜ͝ͱʹ ͢Δ 9 9

    ࣌ؒ ࣌ؒ 9 9 9
  99.    ඵ ඵ ̎ඵ ʮඵͰʯͷ5XFFOΛ࢖͏ 9 9 ࣌ؒ

    ࣌ؒ 9 9 9