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
46
Other Decks in Programming
See All in Programming
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.2k
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
170
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
R8 の設定見直しでアプリサイズ削減
andpad
0
220
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
220
The Rails Doctrine Decade
koic
2
590
AmebaブログはKMPから卒業します
kmars0605
0
180
Domain-Driven Transformation
hschwentner
2
2.3k
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
150
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.6k
Workers Cache を知る
syumai
0
360
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
109
250k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
Fireside Chat
paigeccino
43
4.1k
Paper Plane
katiecoart
PRO
5
54k
Rails Girls Zürich Keynote
gr2m
96
14k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
570
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
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