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

חזרה למפגשBack
PythonPython

Pixel PlatformerPixel Platformer

מפגש 45: Tilemap, מצלמה, Coyote Time, Jump Buffer ומצבי אנימציה.Session 45: Tilemaps, a camera, coyote time, jump buffering and animation states.

מה נעשה היוםToday's plan

  • אריחיםTiles
  • קפיצהJump
  • התנגשותCollision
  • מצלמהCamera
  • אויביםEnemies
  • משחקGame
נושאTopic 1

אריחיםTiles

מפת אריחיםA tilemap

  • מפה: # קרקע, c מטבע, e אויבA map: # ground, c coin, e enemy
  • אריח = Rect בגודל TA tile = a Rect of size T
  • מפה גדולה מהמסךA map bigger than the screen

אנלוגיהAnalogy

מפת אריחים היא כמו לגו: כמה סוגי לבנים בגודל אחיד, ומהם בונים כל עולם שרוצים.A tilemap is like Lego: a few kinds of same-size bricks, and from them you build any world you like.
נושאTopic 2

קפיצהJump

קפיצה ועמידהJumping and standing

  • על הקרקע רק אחרי נחיתהGrounded only after landing
  • קפיצה = vy = -6 רק אם groundedA jump = vy = -6 only if grounded
  • שחרור מוקדם = קפיצה נמוכהAn early release = a short jump

אנלוגיהAnalogy

זה כמו לזרוק כדור למעלה: את הגובה קובעת הזריקה, והכבידה מחליטה מתי הוא חוזר. שחרור מוקדם הוא כמו לזרוק חלש יותר.It's like throwing a ball up: the throw sets the height, and gravity decides when it returns. Releasing early is like throwing softer.
נושאTopic 3

התנגשותCollision

התנגשות באריחיםColliding with tiles

  • הפרדת צירים: x ואז yAxis separation: x then y
  • ב-x: עוצרים בקירOn x: stop at the wall
  • ב-y: נוחתים או נתקלים בתקרהOn y: land or bump the ceiling

אנלוגיהAnalogy

התנגשות באריחים היא כמו ללכת בחדר חשוך עם יד מושטת: כשנוגעים בקיר, עוצרים בדיוק לידו, לא בתוכו.Tile collision is like walking in a dark room with your hand out: touch a wall and you stop right next to it, not inside it.
נושאTopic 4

מצלמהCamera

מצלמה שעוקבתA following camera

  • מצלמה = היסט אופקיA camera = a horizontal offset
  • מציירים ב-rect.move(-camera, 0)Draw at rect.move(-camera, 0)
  • מגבילים לגבולות העולםClamp to the world's edges

אנלוגיהAnalogy

מצלמה היא כמו חלון ברכבת: הנוף עצמו לא זז, אתם זזים לאורכו ורואים בכל רגע רק את החלק שמול החלון.A camera is like a train window: the landscape itself doesn't move, you move along it and see only the part in front of the window.
נושאTopic 5

אויביםEnemies

מטבעות ואויביםCoins and enemies

  • מטבע: נגיעה = נקודה ומחיקהA coin: a touch = a point and removal
  • סיור: מסתובב בקצה הפלטפורמהA patrol: turns at the platform's edge
  • קפיצה על אויב מלמעלה = הוא מתJumping on an enemy from above = it dies

אנלוגיהAnalogy

אויב מסייר הוא כמו שומר שהולך לאורך חומה: מגיע לפינה, מסתובב, וחוזר, בלי לחשוב יותר מזה.A patrolling enemy is like a guard walking a wall: reaches the corner, turns, comes back, and thinks no further.
נושאTopic 6

משחקGame

Pixel Platformer: המשחקPixel Platformer: the game

  • עולם מאריחים, מצלמה שעוקבתA tile world, a following camera
  • קפיצות, מטבעות ואויביםJumps, coins and enemies
  • מגיעים לדגלReach the flag

אנלוגיהAnalogy

פלטפורמר הוא אוסף של חוקים קטנים שכל אחד מהם פשוט: כבידה, מגע בקרקע, מצלמה. החוויה נוצרת מהשילוב.A platformer is a collection of small rules, each simple: gravity, ground contact, a camera. The experience comes from combining them.

מפה: # קרקע, c מטבע, e אויבA map: # ground, c coin, e enemy

אריח = Rect בגודל TA tile = a Rect of size T

מפה גדולה מהמסךA map bigger than the screen

על הקרקע רק אחרי נחיתהGrounded only after landing

קפיצה = vy = -6 רק אם groundedA jump = vy = -6 only if grounded

שחרור מוקדם = קפיצה נמוכהAn early release = a short jump

הפרדת צירים: x ואז yAxis separation: x then y

ב-x: עוצרים בקירOn x: stop at the wall

ב-y: נוחתים או נתקלים בתקרהOn y: land or bump the ceiling

מצלמה = היסט אופקיA camera = a horizontal offset

מציירים ב-rect.move(-camera, 0)Draw at rect.move(-camera, 0)

מגבילים לגבולות העולםClamp to the world's edges

מטבע: נגיעה = נקודה ומחיקהA coin: a touch = a point and removal

סיור: מסתובב בקצה הפלטפורמהA patrol: turns at the platform's edge

קפיצה על אויב מלמעלה = הוא מתJumping on an enemy from above = it dies

עולם מאריחים, מצלמה שעוקבתA tile world, a following camera

קפיצות, מטבעות ואויביםJumps, coins and enemies

מגיעים לדגלReach the flag

מה למדנוWhat we learned

  • מפה: # קרקע, c מטבע, e אויבA map: # ground, c coin, e enemy
  • על הקרקע רק אחרי נחיתהGrounded only after landing
  • הפרדת צירים: x ואז yAxis separation: x then y
  • מצלמה = היסט אופקיA camera = a horizontal offset
  • מטבע: נגיעה = נקודה ומחיקהA coin: a touch = a point and removal
  • עולם מאריחים, מצלמה שעוקבתA tile world, a following camera

עכשיו לתרגולNow, practice

5 תרגילים ו-2 אתגרים, עם בדיקה אוטומטית5 exercises and 2 challenges, auto-checked
הערות מרצהSpeaker notes

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