熊育霆
    • 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
    2
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 資訊之芽一階大作業 - Tetris 作業繳交表單:https://forms.gle/AKotzxUeXfhmZUWP8 **死線 $5/2$!** [投影片連結](https://docs.google.com/presentation/d/1bYe5lW9eU_jDoh1m3Wj8Qnryd9ysFfuwxRrX1btjqH0/edit) [toc] ## 事前準備 ### 安裝 python3 大家應該早就有了(吧? ### 安裝 [pygame](https://www.pygame.org/news) #### Win10 以系統管理員身份打開命令提示字元 (cmd),執行以下指令: **如果是使用 Anaconda 安裝 python 的,請打開「開始功能表 $\rightarrow$ Anaconda3 $\rightarrow$ Anaconda Prompt」** ![](https://i.imgur.com/KkJ0IDB.png) **並輸入以下指令:** ``` pip install pygame ``` (失敗的話,請試試 `python3 -m pip install pygame`) #### MacOS / Linux 打開終端機 / Terminal,輸入指令: ``` pip3 install pygame ``` ### 安裝 VSCode (可選) 如果要同時看很多檔案會比較舒服![link](https://code.visualstudio.com/download) ![](https://code.visualstudio.com/assets/docs/getstarted/userinterface/tabs-hero.png =500x) ### 下載作業檔(重要) 下載下來後右鍵點選解壓縮。 [作業檔案連結](https://drive.google.com/file/d/17jkDH6NHel_Deo253CW-5ZjZc5btAHbD/view) ### 執行 1. 在作業資料夾打開 cmd 或是 terminal 2. 使用 `cd [位置]` 跳到正確的資料夾 3. `python3 main.py` 現在你應該要看到下面這個畫面 ![](https://i.imgur.com/r916rr6.png =500x) ### 調整尺寸 如果視窗大小對你的電腦來說太大的話,可以修改`config.py`裡面的 `unit`。 ![](https://i.imgur.com/KJQST25.png) ### 玩 現在你可以按按看上下左右 動不了?很正常,因為你的作業是讓他動起來 **怎麼做?趕快把 `Handler.py` 填起來吧!** 建議可以看看整份 code 寫了哪些東西 ![](https://i.imgur.com/R2zh9Jy.png =500x) ## 說明 ```python shot.status[y][x] == 0 -> 沒東西 shot.status[y][x] == 1 -> 移動中的方塊 shot.status[y][x] == 2 -> 已被佔據 ``` ## Tasks 以下只是把相關性比較大的工作綁在一起,請按照你覺得合理的順序做 (? 為了可讀性,建議多使用`config`內的常數 繳交時只須繳交`Handler.py`,其他檔案除了`main.py`的`DEBUG = True`那行以外**你們不太需要去動**,但鼓勵你們研究看看。詳細的pygame用法會在二階教 建議早點開始做,這樣有問題時才有時間找講師或同學討論喔 為了方便你們寫作業,注意到`main.py`第8行是`DEBUG = True`,最後會用`DEBUG = False`來評分 ### Task 0 - 方塊左右移動 `moveLeft` `moveRight` - [x] (10 pts) 方塊可以左右移動(按左方向鍵、右方向鍵會有反應)(in class) - [x] (5 pts) 不會讓方塊超出邊界,若會超過就不給移動 (hint: 要做某些判斷) - [ ] (5 pts) 方塊左右移動時不會穿過其他方塊,若會穿過就不給移動 (hint: 判斷某個方格是否已被佔據,使用`shot.status[y][x] == 2`) ### Task 1 - 方塊掉落 如果你做完了可以把`main.py`第8行改成`DEBUG = False`試試 `drop` `instantDrop` - [x] (10 pts) 讓方塊可以往下掉 (in class) - [x] (5 pts) 方塊落地不會超出邊界 (in class) - [x] (5 pts) 方塊落地時把方塊停下來 (in class) (使用`fixPiece`函數) - [ ] (5 pts) 方塊落到其他方塊上方後不會穿過其他方塊 - [ ] (5 pts) 方塊落到其他方塊上方後,把方塊停下來 (使用`fixPiece`函數) - [ ] (5 pts) 實做`instantDrop`,方塊可以直接落地,適合沒耐心的人(? ### Task 2 - 方塊旋轉 `rotate` - [x] (10 pts) 讓方塊可以旋轉 - [ ] (5 pts) 讓方塊旋轉時不會超過邊界,若會超過就不能旋轉 - [ ] (5 pts) 讓方塊旋轉時不會穿過其他方塊 ### Task 3 - 可以死掉 `isDefeat` 如果新方塊生出來的地方已經被佔據就要`return True`,否則`return False` - [ ] (10 pts) 實做`isDefeat`,方塊滿出來時會game over ### Task 4 - 消去列與計算分數 `eliminateFilledRows` 分數算法寫在`config.py` `score_count`: 一次消幾行就加幾分 - [x] (10 pts) 實做`eliminateFilledRows`,可以正常地把一列消掉 - [x] (5 pts) 順便將消掉的行數以及加分更新至shot.line_count和shot.score ## 可能會用到的小技巧 ### print 大法 可以把你要處理的資料印出來看看 * 印出多層list可以使用 [`pprint`](https://docs.python.org/zh-tw/3/library/pprint.html#example) 套件 ## 參考影片 [俄羅斯方塊也有世界大賽? 冠軍的手速快到你無法想像! | 啾啾鞋](https://youtu.be/Dh9VaezvVnU) [16 Y/O UNDERDOG vs. 7-TIME CHAMP - Classic Tetris World Championship 2018 Final Round](https://youtu.be/L_UPHsGR6fM) [5 Essential Tips To Look Like A Pro In Tetris](https://youtu.be/rOQg6q6f6u4) ## FAQ Q: 方塊的格式是什麼? A: 詳細可以看`piece.py`這個檔案,他是一個物件,簡單來說就是存放一些資料的東西。在大作業中需要直接去操作的值基本上只有`y`, `x`, `rotation`

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