Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
struct Drift: Bicycle, Swift
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yung-Luen Lan
October 21, 2018
Programming
1.5k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
struct Drift: Bicycle, Swift
台灣城市單車聯盟
https://tuba.org.tw
Yung-Luen Lan
October 21, 2018
More Decks by Yung-Luen Lan
See All by Yung-Luen Lan
我搞不懂浮點數
yllan
0
1k
Really Simple Cocoa Tips (2007)
yllan
0
41
Other Decks in Programming
See All in Programming
Creating Composable Callables in Contemporary C++
rollbear
0
170
dRuby over BLE
makicamel
2
390
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.6k
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.4k
さぁV100、メモリをお食べ・・・
nilpe
0
160
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
610
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
13
6.3k
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
190
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
200
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
AIで効率化できた業務・日常
ochtum
0
150
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.7k
Ruling the World: When Life Gets Gamed
codingconduct
0
260
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
350
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Joys of Absence: A Defence of Solitary Play
codingconduct
1
400
The Spectacular Lies of Maps
axbom
PRO
1
820
How to make the Groovebox
asonas
2
2.2k
Believing is Seeing
oripsolob
1
150
Transcript
struct Drift: Bicycle, Swift yllan@iPlayground
struct Drift: Bicycle, Swift { let author = Yllan() let
outline = [ Motivation(), Hacking(), Demo(), ] }
yllan: Swift
yllan: Bicycle 單⾞車車通勤勤⽇日 請你喝咖啡 城市繞圈賽 沈沈默的騎⾏行行 ⾞車車夫市集 台灣城市單⾞車車聯聯盟 Taiwan Urban
Bicycle Alliance 單⾞車車野餐、單⾞車車臨臨界量量、單⾞車車教學……
yllan: Bicycle
None
Motivation
None
None
「隔壁的同學都有玩具……」
「有可能⾃自⼰己做嗎?」
“Drift”
yllan, 2015
yllan, 2015
None
None
None
• 速度計算不精確,有延遲
• 速度計算不精確,有延遲
• 速度計算不精確,有延遲
• 速度計算不精確,有延遲
• 速度計算不精確,有延遲
• 速度計算不精確,有延遲
• 速度計算不精確,有延遲
• 速度計算不精確,有延遲
• 速度計算不精確,有延遲 ?
• 速度計算不精確,有延遲 ?
• 速度計算不精確,有延遲 ?
• 速度計算不精確,有延遲 ? • 影片中如果有其他在運動的物體會不⾃自然
• 速度計算不精確,有延遲 ? • 影片中如果有其他在運動的物體會不⾃自然
Let’s Ride!
「如何改善速度不精確的問題?」
「⋯⋯」
None
None
動!
None
None
CoreMotion
let motionManager = CMMotionManager() motionManager.deviceMotionUpdateInterval = 1.0 / 60.0 motionManager.startDeviceMotionUpdates(to:
OperationQueue.main) { (motion, error) in if let motion = motion { print(motion.gravity.x) print(motion.gravity.y) print(motion.gravity.z) } } x y Z
「如何改善速度不精確的問題?」 解決了了!
None
Network.framework
Bonjour (Rendezvous)
let server = NWEndpoint.service(name: "yllan", type: "_bicycle._tcp", domain: "local", interface:
nil) let connection = NWConnection(to: server, using: .tcp) connection.stateUpdateHandler = { (newState) in switch newState { case .ready: // can send data break default: // error, waiting, disconnected break } } connection.start(queue: q) let listener = try NWListener(using: .tcp) listener.service = NWListener.Service(name: "yllan", type: "_bicycle._tcp") listener.newConnectionHandler = { (newConnection) in newConnection.stateUpdateHandler = { (newState) in switch newState { case .ready: // can read break default: break } } newConnection.start(queue: q) } listener.start(queue: q)
60 fps x 32 bytes ≈ 2KB/s 隨便便寫寫就很順了了對吧! 我未婚妻很漂亮對吧! 這場仗打完以後我就要回故鄉結ㄏㄨㄣ……
你好~ 結果很 LAG。 有的時候會掉格到將近⼀一秒。
是不是我 MainQueue 做太多事情?!
是不是我沒開 Optimization?
先profile…
是網路路問題!
• 中華電信 MOD 送的 AP 太爛? • 減⼩小 Packet Size
• 設定 serviceClass • 改⽤用 UDP • 關閉藍藍牙
locationd
原來來,Mac 不適合玩 遊戲的傳⾔言是真的…… https://forums.developer.apple.com/thread/45283 https://forums.developer.apple.com/message/308461#308461
→ 「中途跑出來來的效能問題」 解決了了!
None
None
None
None
• CoreLocation • CLHeading • CoreMotion • Magneto Meter •
CMMagnetoMeterData • Device Motion • CMCalibratedMagneticField
None
None
None
None
??!!
None
None
「取得變速器檔位」 失敗
「⼀一個便便當吃不夠,你有吃兩兩個嗎?」
None
None
「取得變速器檔位」 下次好了了……
DEMO
結論 嗯……我好想去騎⾞車車 其實我是來來打廣告的啦~
11⽉月3⽇日上午10點,台北世貿3館 ⼯工商服務
None
None