נבנה על ידיBuilt by Ariel Yohimovich

JavaJava
45
חלקPart 8: משחקים ב-JavaGames in Java כ-3 שעות (כולל הפסקה)About 3 hours (with a break)

התנגשויות ו-spritesCollisions & sprites

מלבנים ועיגולים שמתנגשים, sprites מתמונות, אנימציה מפריימים וניקוד.

Rectangles and circles that collide, sprites from images, frame animation and scoring.

איך מריצים את הקוד של המפגשRunning this session's code

הפלט שמופיע ליד כל דוגמה הוא הפלט האמיתי שלה מהרצה על JDK 21. בתרגילים כותבים קוד בעורך שבעמוד, מעתיקים ל-IntelliJ ומריצים שם, ומדביקים את הפלט בחזרה: האתר משווה אותו לפלט של הפתרון שלנו. במחשב: ב-IntelliJ יוצרים מחלקה חדשה בתיקייה src, מדביקים ולוחצים על המשולש הירוק. בטרמינל: javac Main.java ואז java Main.

The output next to every example is its real output from a run on JDK 21. In the exercises you write code in the page's editor, copy it to IntelliJ and run it there, then paste the output back: the site compares it with our solution's output. On your computer: in IntelliJ create a new class in src, paste and click the green triangle. In a terminal: javac Main.java then java Main.

פעולהActionMacMacWindowsWindows
קומפילציהCompilejavac Main.javajavac Main.java
הרצהRunjava Mainjava Main
קובץ אחד בלי קומפילציה נפרדתOne file without a separate compilejava Main.javajava Main.java
לנסות שורותTry lines outjshelljshell
להריץ ב-IntelliJRun in IntelliJCtrl+Shift+RCtrl+Shift+F10

פתרון בעיותTroubleshooting

בעיהProblemסיבהCauseפתרוןFix
'javac' is not recognized / command not found: javac'javac' is not recognized / command not found: javacה-JDK לא מותקן, או שהתיקייה bin שלו לא ב-PATHThe JDK isn't installed, or its bin folder isn't on PATHמתקינים JDK 21 (מפגש 1) ופותחים טרמינל חדש. ב-Windows בודקים את JAVA_HOME ואת PATHInstall JDK 21 (session 1) and open a new terminal. On Windows check JAVA_HOME and PATH
class Main is public, should be declared in a file named Main.javaclass Main is public, should be declared in a file named Main.javaשם הקובץ לא זהה לשם המחלקה הציבוריתThe file name doesn't match the public class nameמשנים את שם הקובץ (או את שם המחלקה) כך שיהיו זהים, כולל אותיות גדולותRename the file (or the class) so they match, capital letters included

נבנה על ידיBuilt by Ariel Yohimovich