Yao Hsiao
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # SDL 開發環境設置  ###### tags: `資訊之芽2018 Midterm Project` SDL,全名Simple DirectMedia Layer, 是一套跨平台多媒體開發函式庫,由C語言寫成,他提供了各種控制圖像、聲音、基本IO的function給大家使用。因此我們這次遊戲的主要架構會建構在SDL C++這個框架上。我們使用的SDL版本是2.0.8 . 接下來就是設置的步驟. Mac 請看:[Mac](#For-MacnbspUsers) Window 請看:[Win](#For-Window-Users) ## <a name="mac">For Mac Users</a> 這次主要會在終端機(Terminal)做操作。 ### Step 1 #### Step 1.1 安裝Xcode & brew 請先到App Store 安裝XCode,檔案有點大,會需要一段時間。 Xcode ? > 在mac上做開發的一個IDE(像是dev c++也是ide),可以開發iphone或mac上的應用程式,他文字編輯器、編譯器等等的都有包含,不過我們這次只是利用他來建立你c++編譯器(g++) > **UPDATE** **------------------------------------------------** [**homebrew**](https://brew.sh/index_zh-tw.html) ? > 簡單來說,他是一個套件管理軟體,而套件就是人家寫好的一些可以用的程式。所以你可以用homebrew安裝一些你會用到的而且別人寫好的code(省時間呀~),或者更新那個套件等等。 在安裝完Xcode後,開啟Xcode同意授權,等Xcode授權完畢且開啟完成後,開啟 終端機(在 finder 點 /應用程式/工具程式/終端機) 之後,輸入並執行(按Enter): `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"` 這段指令會安裝brew. **---------------------------------------** #### Step 1.2 安裝sdl2 打開終端機,執行: ``` brew install sdl2 brew install sdl2_image brew install sdl2_ttf ``` brew(也就是homebrew)就會去找編譯好的sdl2 函數庫,下載到你的電腦上。 可以執行`ls /usr/local/Cellar/`(ls是一個指令,叫終端機list出 /usr/local/Cellar/ 這個資料夾有什麼東西) **會出現一個`sdl2, sdl2_image, sdl2_ttf`項目** ### Step 2 創建new project 你可以單獨地創建一個project,然後把sdl2等之前裝的東西include到你的project,不過有點耗時,所以我們直接提供你包裝好的template project,這樣你只要專心把main.cpp寫好。請[點選](https://drive.google.com/file/d/1nywQ6koov2mGNVCqZpRctG-MZJ9pXhHs/view?usp=sharing)下載後解壓縮,裡面的main.cpp是測試程式。 現在打開終端機,cd 到這個資料夾的路徑(如果不知道路徑,直接把資料夾拉進終端機就可以了),然後執行: `make game` 這個指令會根據makefile編譯你的program。 編譯完成,會有一個叫做play的執行檔可以執行 接著run 整個program: `./play` 如果有一個白色的視窗跑出來兩秒,就大功告成了~~~~ 也就是說這個資料夾現在編譯、執行時可以成功地include到SDL2的函數庫,也就是說可以畫畫、做互動了。 **UPDATE** ~~**現在你可以把[作業檔案](https://tw-csie-sprout.github.io/c2018/#!project1.md) 裡的pong.cpp跟 util.hpp 加入這個project,並把pong.cpp檔名改成main.cpp,開始創建你的遊戲了~**~~ **UPDATE 2** **把[作業檔案](https://tw-csie-sprout.github.io/c2018/#!project1.md) 裡的pong.cpp取代前面測試用的main.cpp,開始創建你的遊戲了~** Happy Coding~! --- ## <a name="win">For Window Users</a> ** **update 3** ** **For Window user,除了底下安裝環境設定說明,請同時參考**[**影片**]https://youtu.be/_sC-Qz1f8PI)。 **問問題前也請先確認自己做的跟影片完全一樣謝謝。** ### Step 1 假設已安裝Dev C++ #### Step 1.1 下載裝有SDL2, SDL2_image, SDL2_ttf 的 template project 基本上,可以單獨地安裝這三種套件,不過為了節省時間,助教已經把他們打包成一個資料夾了, 請點[**此網址**](https://drive.google.com/file/d/1G_aiZXnkZLwrtBWZiEoH93LjUG_pYnSa/view?usp=sharing)並解壓縮。 #### Step 1.2 在dev c++ 設定 打開Dev C++,按`工具(T)/編譯器選項(E)` ![](https://i.imgur.com/RXVaVuz.png) 到`目錄(Directories`)的`C++印入檔(C++ includes)`點擊`開啟`(藍色框框裡的) ![刪除無所作用的(Delete Invalid)的右上角icon] ![](https://i.imgur.com/nQWHFKR.png) 從剛剛下載並解壓縮後的裡面有三個資料夾, 選擇名叫SDL2-2.0.8這個資料夾其中的`x86_64-w64-mingw32`的 **`include`** 資料夾,如下圖。 ![](https://i.imgur.com/GFRNFqK.png) 按確定後,再按`新增(Add)` ![](https://i.imgur.com/tfdBw77.png) 出現: ![](https://i.imgur.com/jkZcoGy.png) 再重複類似的動作,到`程式庫(Libraries)`,開啟`x86_64-w64-mingw32`的 **`lib`** 資料夾,按確定。 ![](https://i.imgur.com/hlvMAtW.png) 最後出現 ![](https://i.imgur.com/o7YBO44.png) ### Step 2 configure project options 請進到`project`這個資料夾,並點選裡面的`project.dev`打開project,接著到`專案Project/專案選項(project options)`,選擇`General(一般)`,點選 **`Win32 GUI`**(這樣跑的時候,console 不會跳出來), ![](https://i.imgur.com/sh2SKT4.jpg) ![](https://i.imgur.com/1HZV3qG.png) 接著選擇`參數(Parameters)/`,在`Linker`輸入(如下圖): ``` -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf ``` 在`C++ compiler`輸入:`--std=c++11` 基本上現在這個project可以連接到sdl, sdl_image等函式庫了。 現在來測試一下。project本身已經幫各位設定了一個測試的`main.cpp`,直接按編譯並執行整個project,如果有一個白色的視窗跑出來兩秒就消失,**就大功告成了**~~~~ **UPDATE** ~~**現在你可以把[作業檔案](https://tw-csie-sprout.github.io/c2018/#!project1.md) 裡的pong.cpp跟 util.hpp 加入這個project,並把pong.cpp檔名改成main.cpp,開始創建你的遊戲了~**~~ **UPDATE 2** **把[作業檔案](https://tw-csie-sprout.github.io/c2018/#!project1.md) 裡的pong.cpp取代前面測試用的main.cpp,開始創建你的遊戲了~** Happy Coding~!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully