Chi-Feng Tsai
    • 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

      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.
      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

    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.
    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
    --- tags: 資訊營 --- # Challenge 2020 作業 * 需求 Python >= 3.6 Pygame >= 1.9.6 * 目的 熟悉 Python 稍微熟悉 Pygame 稍微熟悉 git * Folder Hierarchy ``` homework |--main.py |--Const.py |--Model.py |--View.py |--Controller.py |--EventManager.py ``` * 螢幕座標: (800, 800) ``` --------------------- |(0, 0) (800, 0)| | | | | | | | | | | |(0, 800) (800, 800)| --------------------- ``` * 遊戲規則(裡面的參數都可以自己改): 1. 按空白鍵開始玩遊戲 2. 兩個玩家各自操控(上下左右&WASD)一個圓 (半徑=75),出生在 (200, 400) 和 (200, 600)。地圖有邊界。玩家一(上下左右)先當攻,玩家零(WASD)先當受。 3. 以下流程每 t 秒跑一次: a. 攻擊方的移動速度是 100 (pixel per sec),防守方的速度是 70 (pixel per second)。 b. 攻方碰到受方的話,就會把受方吃掉。這樣受方就輸了,遊戲結束。 c. t 秒到了,攻受交換! * 程式碼 你可以想像 Model, View, Controller, EventManager 是四個不同的人,各自負責不同的事情。Model 負責遊戲的程式,Controller 負責把 user input 處理成 Model 的 input,View 負責把 Model 的狀態畫出來,Event Manager 負責不同的人之間的通訊。 舉個例子,如果 Controller 收到了一個 W 的按鍵,他就會往 Event Manager 送一個 `EventPlayerMove('W')` 的 event。這個時候,Event Manager 就會通知 model,model 就會把 player 的狀態給更新。 * 現在遊戲已經有的功能: 1. 有很陽春的背景跟玩家圖示 2. 可以用鍵盤操作玩家 3. 整個遊戲目前有 3 個 state,分別是 `STATE_MENU`, `STATE_PLAY`, `STATE_ENDGAME` * 作業流程: 1. Fork [這個作業](https://github.com/ktpss95112/Challenge2020-Homework) 然後 clone 到你的電腦,開新的 branch 叫作 new_feature。做完作業之後把 new_feature merge 回 master。 2. 先看懂 code (沒有很多)(這份 code 是化簡了去年的 code,所以看懂了的話會幫助你之後去看去年 code 更細節的部份)。如果你真的完全看不懂 Pygame 的話,強烈建議先花兩個小時跟著 [這個 tutorial](https://nerdparadise.com/programming/pygame/part1) 走過一遍。 3. 改 `Model.py` 加上玩家的碰撞判斷 4. 改 `Model.py` 加上攻受交換的功能 5. 改 `View.py` 顯示出現在的攻受狀態和交換的倒數 6. 改 `View.py` 顯示遊戲的倒數計時器 7. 改 `View.py` 跟 `Controller.py` 新增遊戲的暫停功能 * Optional(自由練習) 1. 遊戲結束後,顯示勝負或計分版 3. 把地圖改成無邊界(左進右出)(上進下出) 4. 讓遊戲獲勝的條件從「碰到」變成「蓋過去」(類似 agar.io)(可能要讓攻的半徑變大) 5. 新增道具(加速果實)(變大果實)(??果實) 6. 修改遊戲背景、玩家圖示 7. 可以調整玩家數量(兩人、三人、四人) 8. 讓遊戲跑得更快? 9. 如果今天電腦比較爛,沒辦法跑到 60 fps,要怎麼調整程式,讓遊戲的進行跟 fps 無關?(提示:$\Delta x = v \cdot \Delta t$) 10. 讓遊戲可以 restart 11. 發揮你的創意?

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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