Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Scalaで作るカジュアルゲーム
Search
yuiwai
November 11, 2018
590
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Scalaで作るカジュアルゲーム
yuiwai
November 11, 2018
More Decks by yuiwai
See All by yuiwai
Lagomに学ぶマイクロサービス / Learn Microservice with Lagom
yuiwai
0
890
scalajs-reactで作るフロントエンド / Frontend With scalajs-react
yuiwai
3
620
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
500
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
390
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
270
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
How STYLIGHT went responsive
nonsquared
100
6.3k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
410
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Designing Powerful Visuals for Engaging Learning
tmiket
1
540
Ethics towards AI in product and experience design
skipperchong
2
370
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
330
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
190
Transcript
Scalaで作る カジュアルゲーム Scala関西Summit 2018 Yuichiro Iwai
発表の内容 • 自己紹介 + α • Scalaのユースケース ◦ ビルドダーゲットごとに軽く見ます •
カジュアルゲーム ◦ Scalaで書いて見たテトリス風ゲームの話
自己紹介 岩井 雄一郎 (@dont_cocoa) • 札幌在住 • ソーシャルゲームのサーバサイドエンジニア • 業務ではScalaをAPI検証ツールなど、一部のサポートツールに活用
少しだけ宣伝させてください 札幌にScalaコミュニティーを形成すべく 草の根的に「Sapporo.scala」という Scala勉強会のイベントやってます。 https://sapporo-scala.connpass.com/
Scalaのユースケース
主要なScala実行プラットフォーム JVM scala-js scala-native JVM上で実行 Javaの一般的な用途と同等 (サーバ、GUI、バッチ、etc) JavaScriptとして実行 ブラウザ上、Node.js経由の コマンドライン等
LLVM経由で実行 高速起動を生かしたコマンド ラインツール、Cライブラリと の連携など
Scala on JVM • 既存のJavaの資産をほぼ全て利用可能 • JVM依存のため、Javaのリリースサイクルの影響を受ける • 起動時はどうしても遅いため、コマンドラインツールに難 →
いくつかの打開策(後述)
scala-js • Scalaの資産の多くを再利用可能 • 既存のJavaScriptの資産と連動可能 • サーバ/ブラウザ間の強固な連携 ◦ モデルの共有、通信部分の親和性 •
JS(Node.js)経由のソリューションへの展開 たとえば... ◦ Electronを利用したGUIアプリケーション ◦ AWS Lambdaでの利用
scala-native • LLVMを経由してネイティブバイナリにコンパイル • Scalaの資産に加え、一部のJavaとCライブラリを利用可能 • 最新のScalaへの追随は出来てはいない ◦ このスライドを書いている時点では2.12未サポート •
マルチスレッドなど、部分的に動かない機能がある
(+α) GraalVM • Oracle社製の多言語対応の仮想マシン ◦ JS, Python, Ruby, R, JVM,
LLVMをサポート ◦ Javaクラスファイルからネイティブなバイナリを生成 >> JVMの立ち上がりの遅さを解消出来る • Scalaからコンパイルしたjarでもいける ◦ が、全て動くわけではない
カジュアルゲーム
tetrics • という、テトリス風ゲームをScalaで書いてみました https://github.com/yuiwai/tetrics/tree/master • 一つのコア部分を共有し、ブラウザ (scala-js)、CLI(scala-native) そしてJVM版での実装があります
tetrics • という、テトリス風ゲームをScalaで書いてみました https://github.com/yuiwai/tetrics/tree/master • 一つのコア部分を共有し、ブラウザ (scala-js)、CLI(scala-native) そしてJVM版での実装があります これで、仕事中どんな環境でもカジュアルに遊べますね!
デモ https://lab.yuiwai.com/tetrics/
プロジェクト構成 core … ゲームのコアとなるロジック部分 js … scala-js用の実装。Canvasを利用して描画 native … scala-native実装。ncursesを利用して描画
libgdx … libGDXを利用したJVM用実装
cross-projectのやり方 sbtプラグインがあるので、これを使えば簡単にできます https://github.com/portable-scala/sbt-crossproject scala-js https://www.scala-js.org/ scala-native http://www.scala-native.org/
Scalaに集約することの旨味 • ロジックの拡散を防ぐ • 機能拡張時の恩恵を享受しやすい • 使い慣れたScalaで書ける
ご清聴ありがとうございました