התכונן לאתגר

הושלם

יהיה עליך להשתמש ב- Visual Studio Code כדי לפתח משחק קטן. האפליקציה שלך צריכה לבסס את היסודות של המשחק, כולל עדכון מצב שחקן, טיפול בתנועה נגן, וצריכה ויצירה מחדש של אובייקט מזון. עליך לפתח כל אחת מתכונות אלה ולהפעיל מבחן משחק פשוט יותר.

מפרט פרוייקט

פרוייקט קוד Starter עבור מודול זה כולל קובץ Program.cs עם תכונות הקוד הבאות:

- The code declares the following variables:
    - Variables to determine the size of the Terminal window.
    - Variables to track the locations of the player and food.
    - Arrays `states` and `foods` to provide available player and food appearances
    - Variables to track the current player and food appearance

- The code provides the following methods:
    - A method to determine if the Terminal window was resized.
    - A method to display a random food appearance at a random location.
    - A method that changes the player appearance to match the food consumed.
    - A method that temporarily freezes the player movement.
    - A method that moves the player according to directional input.
    - A method that sets up the initial game state.

- The code doesn't call the methods correctly to make the game playable. The following features are missing:
    - Code to determine if the player has consumed the food displayed.
    - Code to determine if the food consumed should freeze player movement.
    - Code to determine if the food consumed should increase player movement.
    - Code to increase movement speed.
    - Code to redisplay the food after it's consumed by the player.
    - Code to terminate execution if an unsupported key is entered.
    - Code to terminate execution if the terminal was resized.

המטרה שלך באתגר זה היא להשתמש בתכונות הקיימות וליצור את התכונות החסרות כדי להפוך את המשחק לניתן להפעלה.

ההתקנה

השתמש בשלבים הבאים כדי להתכונן לתרגילים בפרוייקט האתגר:

  1. כדי להוריד קובץ מיקוד המכיל את קוד הפרוייקט של Starter, בחר את הקישור הבא: Lab Files.

  2. בטל את דחיסת קבצי ההורדה.

    בטל את דחיסת הקבצים בסביבות הפיתוח שלך. שקול להשתמש במחשב כסביבת הפיתוח שלך כדי שתוכל לגשת לקוד שלך לאחר השלמת מודול זה. אם אינך משתמש במחשב כסביבת הפיתוח שלך, באפשרותך לבטל את דחיסת הקבצים בארגז חול או בסביבה מתארחת.

    1. במחשב המקומי שלך, נווט אל תיקיית ההורדות.
    2. לחץ באמצעות לחצן העכבר Challenge-project-Create-methods-in-CSharp.main.zipולאחר מכן בחר חלץ הכל.
    3. בחר הצג קבצים שחולצו לאחר השלמת, ולאחר מכן בחר חלץ.
    4. רשום לעצמך את מיקום התיקיה שחולצה.
  3. העתק את התיקיה ChallengeProject לתיקיה שולחן העבודה של Windows.

    הערה

    אם תיקיה בשם ChallengeProject כבר קיימת, באפשרותך לבחור החלף את הקבצים ב- כדי להשלים את פעולת ההעתקה.

  4. פתח את התיקיה ChallengeProject החדשה Visual Studio Code.

    1. פתח את Visual Studio Code בסביבת הפיתוח שלך.

    2. ב- Visual Studio Code, בתפריט קובץ, בחר פתח תיקיה.

    3. נווט אל תיקיית שולחן העבודה של Windows ואתר את התיקיה "ChallengeProject".

    4. בחר ChallengeProject מכן בחר בחר תיקיה.

      התצוגה של סייר הקודים של Visual Studio אמורה להציג את התיקיה ChallengeProject ושתי תיקיות משנה בשם Final ו- Starter.

כעת אתה מוכן להתחיל בתרגילי הפרוייקט אתגר. בהצלחה!