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
struct Drift: Bicycle, Swift
Search
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
43
Other Decks in Programming
See All in Programming
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
110
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
590
Intent as Code
shoppingjaws
4
650
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
450
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
150
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.6k
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
140
Webの地図
yosuke_furukawa
PRO
3
3.5k
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
480
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
110
Featured
See All Featured
Deep Space Network (abreviated)
tonyrice
0
300
Ruling the World: When Life Gets Gamed
codingconduct
0
330
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Rails Girls Zürich Keynote
gr2m
96
14k
Building the Perfect Custom Keyboard
takai
2
870
Facilitating Awesome Meetings
lara
57
7.1k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
490
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
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