<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dickson Chui on Medium]]></title>
        <description><![CDATA[Stories by Dickson Chui on Medium]]></description>
        <link>https://medium.com/@dicksonzero?source=rss-aa159e89d43a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3bTfP3T5HLYJNZX8.</url>
            <title>Stories by Dickson Chui on Medium</title>
            <link>https://medium.com/@dicksonzero?source=rss-aa159e89d43a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 02:25:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dicksonzero/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[2021 Game Jam 感想]]></title>
            <link>https://dicksonzero.medium.com/2021-game-jam-%E6%84%9F%E6%83%B3-f2baf22156ae?source=rss-aa159e89d43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2baf22156ae</guid>
            <category><![CDATA[game-jams]]></category>
            <category><![CDATA[postmortem]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Dickson Chui]]></dc:creator>
            <pubDate>Mon, 06 Dec 2021 12:22:19 GMT</pubDate>
            <atom:updated>2021-12-06T12:52:27.228Z</atom:updated>
            <content:encoded><![CDATA[<p>2021 年我許下願望，希望可以平平地快d 整一隻遊戲推出市場，所以一早已經話唔會玩 Game Jam 架喇。而今年，我亦都成功 “將參與 game jam 數量減至 2”，都算少了。</p><p>你見～（究竟我同邊個交代？）今年我無參加 ggj，無參加 GMTK，無參加Extra-Credits，無參加好多嘢啊。但係……</p><blockquote>今年終於畀我捕到 Ludum Dare 舉行嘅日子，唔係唔參加下話？js13k 就係訓醒見到主題，諗下諗下覺得有得做，於是就參加咗。</blockquote><h3>tree-dungeon</h3><p>係我終於第一次參加 Ludum Dare 嘅作品。一直慕名嘅 ldgames 偏偏次次都 miss 咗 noti，4月終於趕到墟期而參加。玩落先知原來 Ludum Dare 有分 Jam 同埋 Compo (其實係 Easy mode 同埋 Hardcore mode)。咁我自然係試玩完 Compo 發覺太 chur 然後落返去 Jam mode。最終 tree-dungeon 變咗零繪圖嘅純 gameplay 遊戲。</p><p>LD48 主題係 Deeper and deeper，我嘅解讀就係 Depth-first-search，玩同一個 game loop 向地下城嘅深處進發。整 tree-dungeon 帶畀我 2個收穫。第一就係測試咗單手 card game UI 同埋 game loop，第二係學用 react 整 UI，學下 react hook pattern 間接令我正職嗰邊做得稱職d。</p><p>試玩： https://ldjam.com/events/ludum-dare/48/tree-dungeon</p><h3>rogue-hoarder</h3><p>係 js13k game jam 嘅參賽作，主題係 Space，我嘅解讀係 inventory space。遊戲講述地下城探險嘅玩家，佢嘅背包格數係同 HP 掛勾嘅。咁樣令玩家越深入地下城，越需要深思熟慮取捨可以攜帶嘅物品，甚至去到後期，需要捨棄身體嘅一部分先至夠位裝寶物，或者維生嘅武器。</p><p>遊戲比喻人生好多嘢都有取捨，要喺時機嚟之前就先作決定。</p><p>話說 rogue-hoarder 有成個月畀我寫，畀我 optimize，所以就算隻遊戲得 13kB size limit，我都可以塞好多內容落去。當然，圖同埋聲仍然係硬傷，我呢隻 game 又係d 抽象嘢嚟。</p><p>試玩： https://vicksonzero.itch.io/rogue-hoarder</p><p>Oh by the way, rogue-hoarder 贏咗 61/232 名，前100名有 T-shirt 收～</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2baf22156ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[mhrise-sim-import 外掛]]></title>
            <link>https://dicksonzero.medium.com/mhrise-sim-import-%E5%A4%96%E6%8E%9B-816f12e63520?source=rss-aa159e89d43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/816f12e63520</guid>
            <category><![CDATA[tampermonkey]]></category>
            <category><![CDATA[monster-hunter-rise]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[charm]]></category>
            <category><![CDATA[userscripts]]></category>
            <dc:creator><![CDATA[Dickson Chui]]></dc:creator>
            <pubDate>Sat, 08 May 2021 11:40:45 GMT</pubDate>
            <atom:updated>2022-07-27T10:53:43.704Z</atom:updated>
            <content:encoded><![CDATA[<h3>(Outdated) mhrise-sim-import 外掛</h3><h4>用 Tampermonkey 協助管理大量護石</h4><p>It is Outdated!! 而家官方已經整咗純文字 export, 唔使再自己 export 喇！！</p><p>我寫咗條 userscript 幫 excel 用家匯入護石落去而家好出名嘅 mhrise 配裝器</p><p><a href="https://gist.github.com/vicksonzero/42150282a8d776f38ad6c86747212569">https://gist.github.com/vicksonzero/42150282a8d776f38ad6c86747212569</a></p><h3>1. 個外掛有乜用 What it does</h3><p>Monster Hunter Rise 抽護石嘅功能令配裝體驗更多變，<br>而 <a href="https://mhrise.wiki-db.com/sim/">https://mhrise.wiki-db.com/sim/</a> （配裝器）嘅大神令玩家配裝生活更爲便利。</p><p>但！係！</p><p>個配裝器美中不足嘅地方就係：佢嘅護石列表無得排序。</p><p>唔緊要，喺等緊佢更新嘅時候，我哋可以用住 Google Sheets 排序先。<br>我呢條 Script 就可以將搬咗去 Google Sheets 嘅護石裝返落配裝器入面。</p><p>我哋今次利用一個 Chrome Extension，叫做 <a href="https://en.wikipedia.org/wiki/Tampermonkey">Tampermonkey</a>。佢可以讓我哋寫 Code 去修改網頁嘅使用體驗。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_NCX5sSnL6jIL9Lbgv0deQ.png" /><figcaption>正嘢！</figcaption></figure><h3>2. 用 Tampermonkey 要注意安全</h3><p>當然，能力越大，責任越大。用得 Tampermonkey 就意味你會增加被 Hack 嘅機會。不法之徒（括弧我）可以畀一段 Code 你行，然後攞哂你 D 個人資料，例如 Facebook 通訊記錄，或者信用咭資料。</p><p>所以，唔知 Tampermonkey 係乜嘢嚟嘅人就小心 D 勒。我份 Code 就攤開嚟任人睇嘅，所以識 programming 嘅人大可以驗證我d code 有無問題。有問題亦請指教，我雖然盡咗力，但係都有可能睇漏眼嘅。</p><p>頭盔戴完，其實個平台就係中性嘅，真正有機會 Hack 你嘅，係你抄落個平台嘅 Code。所以小心 D 就唔會有咩事。</p><h3>3. 點樣安裝 How to install</h3><h4>3.1. 安裝 Tampermonkey 平台</h4><ol><li>去 <a href="https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo">Chrome Web Store 呢一頁</a>，撳 Add to Chrome</li><li>留意你將幾多權限畀咗呢個平台之後，撳 Add extension</li><li>去外掛選單將 Tampermonkey 個 Icon 擺出嚟</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nxnZLRF21pOQRr9yGrT6XQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*14sw772UTPOETbo7DNg29Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*42efUXR6EQ9wSy1gJLqT3w.png" /><figcaption>安裝 Tampermonkey 的流程</figcaption></figure><h4>3.2. 安裝本外掛</h4><ol><li>(1)(2)開啓 tampermonkey 控制台</li><li>(1)開啓 Utilities 頁面，(2)在 Install from URL 貼上連結 <a href="https://gist.githubusercontent.com/vicksonzero/42150282a8d776f38ad6c86747212569/raw/mhrise-sim-import">https://gist.githubusercontent.com/vicksonzero/42150282a8d776f38ad6c86747212569/raw/mhrise-sim-import</a>，(3)然後按 “Install”</li><li>(1)(2) 留意呢條 Script 可以作用嘅範圍，即係話除咗 <a href="https://mhrise.wiki-db.com/sim/*">https://mhrise.wiki-db.com/sim/*</a> 之外，我條 Script 唔會有權掂到其他網頁嘅資料。睇完就撳 (3) 安裝</li><li>裝咗之後去下面呢一頁可以睇返我個 Script 嘅權限</li></ol><p>大功告成！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*5AXjMx8GVu2X93_G3_ADBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q7lQn23XMYF6dArkRHFmKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yk9BLldOdvxKNBiooT3DBQ.png" /><figcaption>安裝外掛嘅流程</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tkz94w1OaC51QM0yh5ErZA.png" /><figcaption>去呢一頁可以睇返裝咗嘅 Scripts</figcaption></figure><h3>4. 點樣用呢個外掛 How to use</h3><h4>4.1. 匯出，喺 Google Sheets 自己管理私伙護石列表</h4><ol><li>(1) 去返 <a href="https://mhrise.wiki-db.com/sim/?hl=zh-hant">配裝器</a> 嗰頁，(2) 撳 “護石” 嘅分頁，(3) 選取並複製所有現時擁有嘅所有護石</li><li>去 <a href="https://sheets.google.com/">https://sheets.google.com</a> 開一張試算表，貼上護石列表，隨意改動、執位、加減</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMZ1_3avcL1PlXXhG4lYsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*fBPrGx5q9jS7WoScOgZ7Iw.png" /></figure><h4>4.2. 準備匯入</h4><ol><li>去返 <a href="https://mhrise.wiki-db.com/sim/?hl=zh-hant">配裝器</a> 頁面，(1)匯出舊嘅護石列表用作後備，搵個地方貼上後備護石列表</li><li>(1)插入一粒空白護石用作隔行</li><li>選取私伙試算表中全部護石列表共 5 欄（唔好包含 “刪除” 嗰欄），按鍵盤 Ctrl-C 複製（注意：本外掛將所有空行視作合格嘅空白護石）</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwdnM1YcDSCcOOjAyAQWSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*kbf2GKfXxEZ_2v7-o8ofig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*Lj-qKnB8hb2K6wOG9LQU3A.png" /></figure><h4>4.3. 用 mhrise-sim-import 外掛，匯入私伙護石列表</h4><ol><li>(1)開啓 Tampermonkey 選單，(2)確定 Tampermonkey 已開啓，(3)確定 mhrise-sim-import 外掛已開啓，然後 (4)按 Import 開始匯入</li><li>又係免責嘅時候。記得 back up 舊嘅護石啊~</li><li>將鍵盤 Ctrl-C 複製嘅私伙護石列表貼落個 box 入面，然後撳 OK</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*Qi4ucuV3-L8qq31AGzEFmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*8r7TRuVH2MjZPyO7AMe6NQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*0N8ax0gM3pVqO0_NWkdmFQ.png" /></figure><h4>4.4. 搞掂，食碗麵</h4><p>匯入後就可以<strong>喪撳交叉</strong>刪除匯入前嗰一批護石。如果你備份得宜嘅話，可以匯入前<strong>刪除所有護石</strong></p><p>你亦可以開啓開發者工具，睇返頭先匯入嘅時候發生咩事</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*PtBtUQHbyfZaMrF8Xq2lUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*f4VVLMjABIc4v8gonAx4MA.png" /></figure><h3>5. 點樣更新呢個外掛 How to update</h3><p>隻外掛喺 Github Gist 公佈，可以自動更新。如果想更新嘅話，可以噉做：</p><ol><li>可以去 Tampermonkey 開/關總掣，或者</li><li>(1)撳 Last Updated 手動從 Github Gist 獲取更新，或者</li><li>(2)編輯 mhrise-sim-import 外掛，喺 Settings 入面修改 Updates 嘅設定</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_hpmvLEPJp7RazSLfOAJ0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-Lq_TurusFJaDLCMjjMBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N2XkRegnauBzItYhOU-iyA.png" /></figure><h3>6. 點樣熄 / 移除呢個外掛 How to disable / remove</h3><h4>6.1. 關閉/移除 mhrise-sim-import 外掛</h4><p>Toggle enabled 開關，或者撳垃圾桶移除 mhrise-sim-import 外掛</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-mK6S8BGNy9koMoOkvu8kw.png" /></figure><h4>6.2. 移除 Tampermonkey 平台</h4><p>右鍵點選 Tampermonkey 圖示，按 Remove from Chrome</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*tYi0d0Q-gVdHlOB6gO0aOQ.png" /></figure><p>(woo，寫 code 用咗唔夠2個鐘，寫 doc 用咗 3個幾鐘頭)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=816f12e63520" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swingzip Progress Blog (In-Dev 05)]]></title>
            <link>https://dicksonzero.medium.com/swingzip-progress-blog-in-dev-05-de85193a56e2?source=rss-aa159e89d43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/de85193a56e2</guid>
            <category><![CDATA[speedrun]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[spider-man]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[mario]]></category>
            <dc:creator><![CDATA[Dickson Chui]]></dc:creator>
            <pubDate>Mon, 22 Feb 2021 11:30:35 GMT</pubDate>
            <atom:updated>2021-02-22T11:30:35.991Z</atom:updated>
            <content:encoded><![CDATA[<p>In December 2020, I started a <strong>year-long project</strong> to create a video game that actually gets released to the market. This game is codenamed “Swingzip” because you swing about and zip about.</p><p>Today, I have made it to a new milestone, now that my player can actually move his arms and legs, it also means demo is around the corner!</p><p>是咁的，2020年 12月，我開始咗個<strong>一年計劃</strong>。今次我一定要完整寫到一隻賣錢嘅 game，仲要踢埋佢出街為止。隻game 暫時叫 <em>Swingzip</em>，因為又要 swing 又要 zip 嚟 zip 去。</p><p>而今日我達到新嘅里程碑，因為我隻角色而家識郁了，即係話我就快可以出 Demo 了！</p><h3>The Game</h3><blockquote>Swingzip is a 2d Grapple Delivery-man Platformer Game Inspired by Spider-Verse.<br>Swingzip 是橫向卷軸的競速送貨遊戲，靈感來自《跳入蜘蛛宇宙》。</blockquote><h3>The Prototype</h3><p>Being a man believing in “Iterate fast, follow the fun”[1], I whipped up this demo early in December and made a video demo out of it.</p><p>我信奉「好嘅遊戲自己識得設計自己，而設計師嘅職責就係傾聽個遊戲」[1]，所以我12月花咗一個禮拜就揼起咗個雛形，整咗以下呢兩個版本試水溫，睇吓有唔有趣：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHH7Nhvz318PKeziMuk8FQ.png" /><figcaption>First draft: Swingzip In-dev 01</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-GkZCvy_j3U%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-GkZCvy_j3U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-GkZCvy_j3U%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/543406dc2fd24b4f0813ab8cc7ed7620/href">https://medium.com/media/543406dc2fd24b4f0813ab8cc7ed7620/href</a></iframe><h3>Better Artwork = Better Gameplay</h3><p>For a platformer to appear smooth and fluid, I can’t work alone anymore. Luckily I have got my friend Brian, who is an experienced artist, to help me design visual arts, especially for the movesets and the stage styles.</p><p>However, in January I haven’t been making good progress because of life. Now that I made myself a long holiday, I took a long-needed rest and got myself some time and energy to actually achieve some milestones.</p><p>要整好嘅動作遊戲，空有 gameplay 係唔成事嘅，仲需要流暢嘅動畫同埋引人入勝嘅故事。呢方面我請到敗人大大幫手整動畫，補足返我美術嘅不足。有佢幫手，我精心設計畀主角嘅動作就唔使要用罐頭或者用 Ai 慢慢鬥。</p><p>不過一月都比較忙，寫唔到幾多行 code。咁啱新年假請4日放10日，我就趁機唞足同埋趕工勒。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0qQ0taPTV-YpHmNJfXIxQ.png" /><figcaption>Making a video game part time can be a tough task</figcaption></figure><h3>Pre-production Analysis, Gameplay Testing</h3><p>I made a draft for all possible movesets the player is ever going to make, and put them together in a chronological order. It is laid out like a golden path, so readers can follow through.</p><p>新年假適逢敗人大大加入，可以整多d 同畫有關嘅嘢，唔使再對住個紅色方形。於是我畫咗以下呢幅草圖，勾劃出最常見嘅動態流程。因為係單向流程，似返玩家一路遇到嘅障礙，所以更容易入口。（其實之前已經畫過好多幅流程圖，但係呢幅最簡潔）</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mt_47hTktEfElR3er6rpNw.jpeg" /><figcaption>Stickman (haha) is still a quick and dirty way to start laying out what kind of obstacles the player is going to encounter, presented in a user-journey fashion, so to make it easy for a reader to follow</figcaption></figure><p>I gave it to Brian, who turns the stickman into muscleman. We deliberately downgrade the drawings into silhouettes to make sure it can convey the motion and game state well enough. It is an important step because the player psychologically identifies the silhouette first before anything else.</p><p>I then put these drawings in the game and generated this internal demo (In-dev 05) for Brian to generate feedbacks.</p><p>整完之後畀敗人大大變返做有血有肉嘅公仔，就可以落下一步。</p><p>下一步就係齋睇輪廓放落 game，睇下無任何輔助嘅情況下，主角嘅畫格係咪仍然清楚表達到佢做緊咩。呢步好重要，因為玩家電光火石之間就係首先靠輪廓辨認資訊嘅。</p><p>然後呢，加咗公仔落遊戲之後就係咁樣嘅：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1wymtNCYpgQ1A7r2Q7M5Uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NL9tuPX20tLZw2EOXalAfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sj2jhNydY8TWcEEqUX6vTQ.png" /><figcaption>In-dev 05:Hooray for shoot / jump / run poses!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qnSwqhGur15DQKRvpx39Bw.png" /><figcaption>What it looks like inside Unity. To the left you can still see a few states waiting to be implemented, and the states in (…) are future moves that I wont just yet put into the game.</figcaption></figure><h3>State Diagram</h3><p>As you can see, although the move set is still rather simple, the amount of states is still quite daunting. I have prepared a number of different versions of the same state-machine so that any kind of readers can still make sense out of it.</p><p>如閣下所見，就算唔係好多動作都好，Unity 隻 State Diagram 都係唔係幾討好。所以我除咗以上幾款 Diagram 之外，另外畫多咗一個 List format 嘅列表。希望咁多款表加起來能夠表達到每款動作可以點派生啦。</p><p>After this article, I will try to finish the demo by the end of February and make a public release by the first week of March (original plan was within Feb😥). If you are interested, you can follow me using one of the following ways:</p><p>出完呢篇文之後我會喳喳淋搞埋D 手尾，然後出一個概念公測版，用來收集意見，同埋改進遊戲嘅操作體驗。遊戲目前都係會以PC 版爲主，mobile 版爲輔。希望 3月第一個禮拜出到街啦（原定2月內😥）。有興趣可以 follow 我得到最新資訊：</p><p>Follow me on Itch: <a href="https://vicksonzero.itch.io/">https://vicksonzero.itch.io</a>​<br>Follow me on Twitter: <a href="https://twitter.com/vicksonzero">https://twitter.com/vicksonzero</a>​<br>Follow me on GitHub: <a href="https://github.com/vicksonzero">https://github.com/vicksonzero</a>​<br>Subscribe to my Youtube Channel: <a href="https://www.youtube.com/dicksonZero">https://www.youtube.com/dicksonZero</a></p><p>Next up: I am sharing the two pillars for the Swingzip project and my vision of it. Maybe also share how I manage all the complex movement states in the code using the same State Pattern.</p><p>次回預告：Swingzip 兩大支柱：我的設計願景</p><p>或者可以講埋我點樣應用 State Pattern 管理複雜嘅動作遊戲邏輯都好喎…</p><p>[1] https://youtu.be/kMDe7_YwVKI</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de85193a56e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bash Batch rename, with preview]]></title>
            <link>https://dicksonzero.medium.com/bash-batch-rename-with-preview-ae9372f2122f?source=rss-aa159e89d43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae9372f2122f</guid>
            <category><![CDATA[batch-processing]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[de]]></category>
            <category><![CDATA[regular-expressions]]></category>
            <dc:creator><![CDATA[Dickson Chui]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 01:52:52 GMT</pubDate>
            <atom:updated>2020-03-31T09:53:12.245Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bash Batch Rename, with Rreview</h3><p>As developers, we all have that time when we need to batch do something with our large tree of files. While there are batch utility out there, they may not be that easy to customize to our needs.</p><p>Since i use <em>bash</em>, and i know some Regular Expressions, i can use find and sed to generate commands for me.</p><p>I have been using this method for two years, and it saves me lots of clicking into/out of folders, with great features that grants me <strong>safety</strong>, knowing exactly what this script will do, before i actually run it.</p><p>(<em>tl;dr</em>: Skip to the <strong>Summary </strong>for the whole command)</p><h3>Example: New translation for all of your submodules</h3><p>Let’s say you have a lot of games that share the same folder structure, each has its pack of language assets, like below:</p><pre>tree of ~/project</pre><pre>project<br> |--game1<br> |   |--lang<br> |   |   |--EN/ (4 files)<br> |   |   |--TR/ (4 files)<br> |   |   `--ZH/ (4 files)<br> |   `--code and stuff<br> |--game2<br> |   |--lang<br> |   |   |--EN/ (4 files)<br> |   |   |--TR/ (4 files)<br> |   |   `--ZH/ (4 files)<br> |   `--code and stuff<br> |--game3<br> |   |--lang<br> |   |   |--EN/ (4 files)<br> |   |   |--TR/ (4 files)<br> |   |   `--ZH/ (4 files)<br> |   `--code and stuff<br> `--game4<br>     |--lang<br>     |   |--EN/ (4 files)<br>     |   |--TR/ (4 files)<br>     |   `--ZH/ (4 files)<br>     `--code and stuff</pre><p>Your designer gave you a list of Japanese language assets, structured a bit differently:</p><pre>tree of ~/newStuff</pre><pre>lang<br> |--game1/ (4 JP files)<br> |--game2/ (4 JP files)<br> |--game3/ (4 JP files)<br> `--game4/ (4 JP files)</pre><p>Now you want to add these new JP language to each of the games, without having to go into each game (24 of them!) and manually copy a file.</p><p>If you are using bash, i have a quite convenient way, pure bash script:</p><h4>Find all files you need</h4><pre>cd ~/newStuff<br>find -type f -path ./node_modules -prune -o -path ./dist -prune -o -wholename &#39;./lang/*&#39;</pre><p>This selects all paths in ~/newStuff that fulfills the glob pattern</p><p>Breakdown:</p><ul><li>find: find in this directory</li><li>-type f: of type file</li><li>-path ./node_modules -prune: if encounter this directory, skip</li><li>-o else</li><li>-path ./dist -prune: if encounter that directory, skip</li><li>-o else</li><li>-wholename &#39;./lang/*&#39;: with this name, match path (glob pattern) <br>(it is case sensitive. To use insensitive, use -iwholename instead.)<br>(note: I did not use regex here, but you can use -regextype sed -regex &quot;.*&quot; like this: <br><a href="https://stackoverflow.com/questions/6844785/how-to-use-regex-with-find-command">https://stackoverflow.com/questions/6844785/how-to-use-regex-with-find-command</a>)</li></ul><p>The result should look like this:</p><pre>./lang/game1/text.json<br>./lang/game1/texture.png<br>./lang/game1/atlas.json<br>./lang/game1/icon.png<br>./lang/game2/text.json<br>./lang/game2/texture.png<br>./lang/game2/atlas.json<br>./lang/game2/icon.png<br>./lang/game3/text.json<br>./lang/game3/texture.png<br>./lang/game3/atlas.json<br>./lang/game3/icon.png<br>./lang/game4/text.json<br>./lang/game4/texture.png<br>./lang/game4/atlas.json<br>./lang/game4/icon.png</pre><p>The nice thing about this command is that it gives you a list of paths in string. Now you can pipe| it into sed to make whatever command you choose:</p><h4>Sed them into a list of commands</h4><pre>sed -r -e &#39;s/.\/lang\/game(.+?)\/(.+)/cp -n &amp; ~\/project\/game\1\/lang\/JP\/\2/&#39;</pre><p>sed breakdown:</p><ul><li>-r: replace</li><li>-e: use regex</li><li>&#39;s/.../.../&#39;: the regex replace complex</li><li>.\/lang\/game(.+?)\/(.+): reads ./lang/game*/*, capturing the first and second *</li><li>cp -n &amp; ~\/project\/game\1\/lang\/JP\/\2/: Replaces the above pattern into a cp -ncommand.</li><li>cp -n means no override<br>&amp; means the whole match, \1 means the first capture group, and so on</li></ul><p>using sed, the first line…</p><pre>./lang/game1/text.json</pre><p>…will be transformed into:</p><pre>cp -n ./lang/game1/text.json ~/project/game1/lang/JP/text.json</pre><h4>Putting all together</h4><p>When you execute the whole find sed command:</p><pre><strong>find </strong>-type f -path ./node_modules -prune -o -path ./dist -prune -o -wholename &#39;./lang/*&#39; <strong>|</strong> <strong>sed </strong>-r -e &#39;s/.\/lang\/game(.+?)\/(.+)/cp -n &amp; ~\/project\/game\1\/lang\/JP\/\2/&#39;</pre><p>the file list will be transformed into:</p><pre>cp -n ./lang/game1/text.json ~/project/game1/lang/JP/text.json<br>cp -n ./lang/game1/texture.png ~/project/game1/lang/JP/texture.png<br>cp -n ./lang/game1/atlas.json ~/project/game1/lang/JP/atlas.json<br>cp -n ./lang/game1/icon.png ~/project/game1/lang/JP/icon.png<br>cp -n ./lang/game2/text.json ~/project/game2/lang/JP/text.json<br>cp -n ./lang/game2/texture.png ~/project/game2/lang/JP/texture.png<br>cp -n ./lang/game2/atlas.json ~/project/game2/lang/JP/atlas.json<br>cp -n ./lang/game2/icon.png ~/project/game2/lang/JP/icon.png<br>cp -n ./lang/game3/text.json ~/project/game3/lang/JP/text.json<br>cp -n ./lang/game3/texture.png ~/project/game3/lang/JP/texture.png<br>cp -n ./lang/game3/atlas.json ~/project/game3/lang/JP/atlas.json<br>cp -n ./lang/game3/icon.png ~/project/game3/lang/JP/icon.png<br>cp -n ./lang/game4/text.json ~/project/game4/lang/JP/text.json<br>cp -n ./lang/game4/texture.png ~/project/game4/lang/JP/texture.png<br>cp -n ./lang/game4/atlas.json ~/project/game4/lang/JP/atlas.json<br>cp -n ./lang/game4/icon.png ~/project/game4/lang/JP/icon.png</pre><p>Now you can pipe | the whole thing into bash to run it:</p><h4>Fire!</h4><pre><strong>find </strong>-type f -path ./node_modules -prune -o -path ./dist -prune -o -wholename &#39;./lang/*&#39; <strong>| sed</strong> -r -e &#39;s/.\/lang\/game(.+?)\/(.+)/cp -n &amp; ~\/project\/game\1\/lang\/JP\/\2/&#39; <strong>| bash</strong></pre><p>And don’t cross your fingers because you knew what’s going to happen.</p><h3>Summary</h3><p>to preview:</p><pre><strong>find </strong>-type f -path ./node_modules -prune -o -path ./dist -prune -o -wholename &#39;./lang/*&#39; <strong>| sed</strong> -r -e &#39;s/.\/lang\/game(.+?)\/(.+)/cp -n &amp; ~\/project\/game\1\/lang\/JP\/\2/&#39;</pre><p>to run:</p><pre><strong>find </strong>-type f -path ./node_modules -prune -o -path ./dist -prune -o -wholename &#39;./lang/*&#39; <strong>| sed</strong> -r -e &#39;s/.\/lang\/game(.+?)\/(.+)/cp -n &amp; ~\/project\/game\1\/lang\/JP\/\2/&#39; <strong>| bash</strong></pre><h3>Other examples</h3><p>As an example, let’s use the same ~/newStuff and ~/project</p><h4>Extract files into a folder, eg: for deploy</h4><pre><strong>find </strong>-type f -path ./node_modules -prune -o -path ./dist -prune -o -wholename &#39;./lang/**/*.json&#39; <strong>| sed</strong> -r -e &#39;s/.\/lang\/game(.+?)\/.+/cp -n --parents &amp; ~\/some_folder/&#39;</pre><p>This one copies all language <strong><em>.json</em></strong> files into some_folder. Add | bash to run</p><ul><li>cp --parents: create the intermediate parent directories if needed</li></ul><h4>Simple batch rename</h4><p>For all <strong><em>.json</em></strong> files, Replaces the first occurrence of <strong>JP</strong> with <strong>EN</strong>. Add | bash to run.</p><pre><strong>find </strong>-type f -path ./node_modules -prune -o -path ./dist -prune -o -wholename &#39;./lang/**/*.json&#39; <strong>| sed</strong> -r -e &#39;s/.\/(.+?)JP(.+?)\/.+/mv &amp; .\/\1EN\2/&#39;</pre><p>This is my way of using these commands. To be honest, they kind of feels too long.</p><p>Let me know if you have better styles in doing batch work in bash.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae9372f2122f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extra-Laser-Unity #01 Building a Space Fighter with Colors]]></title>
            <link>https://dicksonzero.medium.com/extra-laser-unity-01-building-a-space-fighter-with-colors-91efce6ac0a?source=rss-aa159e89d43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/91efce6ac0a</guid>
            <category><![CDATA[illustrator]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[shoot-em-ups]]></category>
            <category><![CDATA[game-design]]></category>
            <category><![CDATA[2d-game-development]]></category>
            <dc:creator><![CDATA[Dickson Chui]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 16:47:44 GMT</pubDate>
            <atom:updated>2019-03-18T16:50:56.924Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*7KD4jIjqdfT2FbyPULLZSg.png" /><figcaption>Result first. Kinda neat</figcaption></figure><h3>Switching to Unity2d from Phaser3</h3><p>Ok, so I made extra-laser for the Extra Credit game jam within 48 hours. I did it in Phaser3 and I learnt tons from it (plus evaluated it for my day job’s tech change). As much as I enjoyed using it and its readiness to go cross-platform, it is not yet through its infant stage. I let my friend play it and it went crawling on his phone. So I guess I give it one more year and also give unity in 2d a try.</p><p>I start with unity 2018, and it already greets me with a long-waited tool. You can now edit prefabs in-place, just like how you do with movie clips in <em>Flash</em>.</p><p>With my unity experience, I quickly start the project and organize my assets in namespaces (such as <em>dicksonmd</em> and <em>kenney</em>)</p><h3>Sprite from kenney: separate sprite parts with Illustrator</h3><p><strong>Kenney.nl</strong> provides really nice free assets. He is even generous enough to share vector source files. I am very grateful of this, and this paragraph is dedicated to his credits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y18gRrO7R3K1-yqVmizduw.png" /><figcaption>Kenney.nl has really good graphics, and most are shared with very permissive license</figcaption></figure><p>I opened the svg in Illustrator, copied a line of wing parts that has the most contrast in shade (say the green color), and move on in a new .ai file</p><p>The components were very nicely organized. Each colored component is its own shape or compound shape. I separated all the wing parts by color (green parts) and light color (gray parts), into 2 layers.</p><p>I then select all parts of the exact same color, and <strong>tune their saturation to 0</strong>. Repeat the same thing for each shade of the green, and you get a nice grayscale for all wing parts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*R8Jgs8WRmgz8MMWQCwdYuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*n2linu42xHJhsqCNqFGVaw.png" /><figcaption>Tune s to 0 to get gray color</figcaption></figure><h3>Illustrator: Artboard tricks</h3><p>And then there is the part to export the graphics. This is actually <strong>done first</strong>, before separating the svg components, but artboard is sort of the minor one so i arrange this section to be later.</p><p>There is a tool called <strong>artboard tool</strong> (shift-o) that takes care of organizing individual exports, so you can edit multiple sprites in the same file, and export all at the same time.</p><p>I have already known this and I ll skip to the new trick i learnt. you can <strong>double click the artwork</strong> with your tool to auto resize to said artwork! Massive time save for the otherwise “double click artboard in artboard panel and dropdown and select fit to selection” routine that i was using.</p><p>And then you can use the <strong>File&gt;export…</strong> menu to batch export all artboards and auto-name them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*xwzXIYIl2evQqvU_6DWAIg.png" /><figcaption>Artboard tool</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*LCzO3hVGIFSAHNzitKqUAA.png" /><figcaption>Quick export of multiple artboards, with their names auto composed</figcaption></figure><h3>Unity: BWingPart script</h3><p>Now all i need to do is to overlap the exports, one from light and one from dark, in the same GameObject and link them with a single script. I added an editor script to update tint in editor, so i can use it later to create prefab ships directly. You will see the code at Github soon enough.</p><p>Next up: add engines, guns, and serialize the craft design.</p><p>That’s it for now, See you next time.</p><blockquote>Battle control, terminated</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*ahHXANLNHTUarM24x5WYmw.png" /><figcaption>Gray scale (before coloring)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CAdvg6Jf2kWtjmXVryx-6A.png" /><figcaption>With a simple button press, mirrors wing parts left and right or propagate color preferences across individual wing parts</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0JRMLD4FddkdUuQswvAQ2Q.png" /><figcaption>Another color scheme</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91efce6ac0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do level design with google sheets]]></title>
            <link>https://dicksonzero.medium.com/how-to-do-level-design-with-google-sheets-8139c0312125?source=rss-aa159e89d43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8139c0312125</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[level-design]]></category>
            <category><![CDATA[google-sheets]]></category>
            <category><![CDATA[phaser]]></category>
            <dc:creator><![CDATA[Dickson Chui]]></dc:creator>
            <pubDate>Tue, 29 Jan 2019 14:54:43 GMT</pubDate>
            <atom:updated>2023-04-24T06:39:22.796Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://developers.google.com/sheets/api/guides/authorizing">Authorize Requests | Sheets API | Google Developers</a></p><ol><li>Publish your google sheets in any forms (eg: file &gt; publish &gt; click publish)<br><em>(Edit: perhaps you would want to share the sheet with “anyone with the link” instead of publishing it)</em></li><li>get an <strong>API key</strong> following instruction from the above link:<br><a href="https://developers.google.com/workspace/guides/create-credentials#api-key">https://developers.google.com/workspace/guides/create-credentials#api-key</a></li><li>do a GET request with <a href="https://sheets.googleapis.com/v4/spreadsheets/1HDSI0MWzxZkxUpwpW3fK1sq2Wg6BawSuiuASgn_RLGI/values/Stage1!A1%3AAD41?key=AIzaSyCEuuqvO7H2jyiIPt2GoWcMqjUa337p3tM">https://sheets.googleapis.com/v4/spreadsheets/YOUR_SHEET_NAME/values/Stage1!A1%3AZ10?key=</a>YOUR_API_KEY</li><li>no authentication needed. Just an API key that you can restrict to only accept requests from your website</li><li>Luckily, Phaser does all the XHR loading for me, so the GET request feels like a breeze to me</li></ol><pre>this.load.json(&#39;sheetMap&#39;,&#39;https://sheets.googleapis.com/v4/spreadsheets/YOUR_SHEET_NAME/values/Stage1!A1%3AAD41?key=YOUR_API_KEY&#39;);</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7V-Qe8H_UFONDLPy0s5ecA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*6XSsbG8T0SqORlGu5wY5Hg.png" /><figcaption>Sheet data and result game layout. $0 is the cave-exit-stuff and $2 is the little item floating below the player</figcaption></figure><p>result JSON:</p><pre>{<br>  &quot;range&quot;: &quot;Stage1!A1:AD41&quot;,<br>  &quot;majorDimension&quot;: &quot;ROWS&quot;,<br>  &quot;values&quot;: [<br>    [<br>      &quot;0&quot;,<br>      &quot;redacted&quot;,<br>    ]<br>  ]<br>}</pre><p>Also See this to limit access to only trusted domains:</p><p><a href="https://cloud.google.com/docs/authentication/api-keys">Authenticate by using API keys | Authentication | Google Cloud</a></p><p>References:</p><ul><li><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get">https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get</a></li><li><a href="https://stackoverflow.com/questions/51081462/using-google-sheets-api-without-client-side-login">https://stackoverflow.com/questions/51081462/using-google-sheets-api-without-client-side-login</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8139c0312125" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The double door problem]]></title>
            <link>https://dicksonzero.medium.com/the-double-door-problem-67604478993?source=rss-aa159e89d43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/67604478993</guid>
            <category><![CDATA[mathematics-education]]></category>
            <category><![CDATA[geometry]]></category>
            <category><![CDATA[daydreaming]]></category>
            <category><![CDATA[doors]]></category>
            <dc:creator><![CDATA[Dickson Chui]]></dc:creator>
            <pubDate>Wed, 19 Dec 2018 14:41:23 GMT</pubDate>
            <atom:updated>2019-01-06T07:50:34.688Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine one day you are in a hurry, and you walk up to a double door. Sometimes you just open one side and get on, the other day you think again and open both sides, thinking it will be faster. But then the gap seems a bit smaller or not?</p><p>Obviously it gets small at first, but with both doors opening at the same time, perhaps it will open faster than just one side after some point.</p><p>The million dollar question is going to be answered with college maths:</p><blockquote>When is it cost-efficient to open the door by both sides?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ea_DGbAUaec_4r5cTk_MRA.png" /><figcaption>The door we are trying to open. Yellow denotes dist, and green denotes dist’</figcaption></figure><p>Let’s assume something first. We open the door quite uniformly, if we differ the opening rate at any amount, the comparison becomes pointless right?</p><blockquote>θ ∝ time t</blockquote><p>Great, so it turns out time can be totally represented by angle (θ)</p><p>We write down the coordinate of A and B here:</p><blockquote>A (dcosθ, dsinθ)<br>B (2d-dcosθ, dsinθ)</blockquote><p>and with a bit of Pythagoras theorems, we get the openness in terms of distance between A and B:</p><blockquote>openness when opening both doors<br>= dist = √( (2d-dcosθ — dcosθ)² + (dsinθ-dsinθ)² )<br>dist = √( (2d-dcosθ — dcosθ)² + 0 )</blockquote><p>since dist is &gt;=0, sqrt and squared can just be thrown away, therefore</p><blockquote>dist = 2d-2dcosθ<br>dist = 2d(1-cosθ)</blockquote><p>Now we do A and B&#39;</p><p>openness (distance between A and B’):</p><blockquote>A (dcosθ, dsinθ)<br>B’ (d, 0)</blockquote><blockquote>dist’ = √( (dcosθ-d)² + (dsinθ)² )<br>dist’ = d√(2–2 cosθ)</blockquote><p>Plot all of them in wolfram Alpha, we can see the immediate winners. Note that door size d is an actually arbitrary constant. Might as well throw in a prime number (13) to let wolfram plot a meaningful graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*5VBu-PvLYBhXmyhjMRcFmQ.png" /><figcaption>Plot dist against dist’. They cross at θ=pi/3, in which dist is exactly the width of one door (Corrected screenshot with θ capped at <strong>π</strong>/2)</figcaption></figure><p>Blue is dist (both doors)</p><p>Purple is dist&#39; (only one door)</p><p>The lesson to take away is: if you have one person, it is better to open one door, and if you have two, open two or just cramp through one! More importantly, doors only open till <strong>π</strong>/2, so the difference isn’t really that big (duh!)</p><p>(Finally getting this question out of my head. Phew.)</p><p>(Wait, what happens if doors open in different directions? Simple thought experiment says opening both is faster, but given the little gain, is it worth it? 😏)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67604478993" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>