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

חזרה למפגשBack
PythonPython

Brick Breaker: שובר לבניםBrick Breaker

מפגש 41: מחלקות במשחק, שלבים מנתוני טקסט, power-ups ומטמון תמונות.Session 41: Classes in a game, levels from text data, power-ups and an image cache.

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

  • שלבLevel
  • צדדיםSides
  • מנהורTunneling
  • חיזוקיםPower-ups
  • שלביםLevels
  • משחקGame
נושאTopic 1

שלבLevel

שלב מתוך טקסטA level from text

  • מפת שלב: כל תו הוא לבנהA level map: each character is a brick
  • . = ריק. = empty
  • מילון תו → צבעA dict character → colour

אנלוגיהAnalogy

מפת שלב היא כמו תווים של שיר: סדרה של סימנים פשוטים שמישהו אחר (הקוד) יודע לנגן.A level map is like sheet music: a series of simple symbols someone else (the code) knows how to play.
נושאTopic 2

צדדיםSides

מאיזה צד הייתה הפגיעה?Which side was hit?

אנלוגיהAnalogy

הפרדת צירים היא כמו לבדוק דלת בשני שלבים: קודם דוחפים ימינה ורואים אם נתקעים, אחר כך דוחפים קדימה. כך יודעים בדיוק איפה המכשול.Axis separation is like testing a door in two steps: push right and see if you're blocked, then push forward. That's how you know exactly where the obstacle is.
נושאTopic 3

מנהורTunneling

מהירות ומנהורSpeed and tunneling

  • כדור מהיר יכול "לדלג" מעל לבנהA fast ball can "skip" a brick
  • צעדים קטנים: מחלקים את התנועהSmall steps: split the motion
  • מהירות מקסימלית < עובי הלבנהMax speed < brick thickness

אנלוגיהAnalogy

מנהור הוא כמו לצלם רץ מהיר פעם בשנייה: בתמונה אחת הוא לפני המכשול ובבאה אחריו, ונראה שקפץ דרכו.Tunneling is like photographing a sprinter once a second: in one shot they're before the hurdle and in the next past it, as if they went through it.
נושאTopic 4

חיזוקיםPower-ups

חיזוקיםPower-ups

  • לבנה שנשברת מפילה חיזוק לפעמיםA broken brick sometimes drops a power-up
  • תופסים במחבט → אפקטCatch it with the paddle → an effect
  • אפקט זמני עם מונה פריימיםA temporary effect with a frame counter

אנלוגיהAnalogy

חיזוק זמני הוא כמו כרטיס "פי שניים נקודות לשעה" בפארק שעשועים: יש שעון, וכשהוא נגמר הכול חוזר לרגיל.A temporary power-up is like a "double points for an hour" pass at a fun fair: there's a clock, and when it runs out everything goes back to normal.
נושאTopic 5

שלביםLevels

חיים ושלביםLives and levels

  • כדור מתחת למחבט = חיים פחותBall below the paddle = a life lost
  • אין לבנים = שלב הבאNo bricks = next level
  • רשימת שלבים = רשימת מפותA list of levels = a list of maps

אנלוגיהAnalogy

שלבים הם כמו פרקים בספר: כשמסיימים אחד, מדפדפים לבא, ובסוף הספר מגיע הסוף הטוב.Levels are like chapters in a book: finish one, turn to the next, and at the end comes the happy ending.
נושאTopic 6

משחקGame

Brick Breaker: המשחקBrick Breaker: the game

  • שלב מטקסטA level from text
  • הפרדת צירים בפגיעותAxis separation on hits
  • זווית מהמחבט, ניקודAngle off the paddle, score

אנלוגיהAnalogy

Brick Breaker משלב את כל מה שבנינו: Rect, התנגשויות, זווית, מצבים. כמו מתכון שמשתמש בכל הכלים במטבח.Brick Breaker combines everything we've built: Rects, collisions, angles, states. Like a recipe that uses every tool in the kitchen.

מפת שלב: כל תו הוא לבנהA level map: each character is a brick

. = ריק. = empty

מילון תו → צבעA dict character → colour

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

פגיעה ב-x → vx = -vxA hit on x → vx = -vx

פגיעה ב-y → vy = -vyA hit on y → vy = -vy

כדור מהיר יכול "לדלג" מעל לבנהA fast ball can "skip" a brick

צעדים קטנים: מחלקים את התנועהSmall steps: split the motion

מהירות מקסימלית < עובי הלבנהMax speed < brick thickness

לבנה שנשברת מפילה חיזוק לפעמיםA broken brick sometimes drops a power-up

תופסים במחבט → אפקטCatch it with the paddle → an effect

אפקט זמני עם מונה פריימיםA temporary effect with a frame counter

כדור מתחת למחבט = חיים פחותBall below the paddle = a life lost

אין לבנים = שלב הבאNo bricks = next level

רשימת שלבים = רשימת מפותA list of levels = a list of maps

שלב מטקסטA level from text

הפרדת צירים בפגיעותAxis separation on hits

זווית מהמחבט, ניקודAngle off the paddle, score

מה למדנוWhat we learned

  • מפת שלב: כל תו הוא לבנהA level map: each character is a brick
  • הפרדת צירים: קודם x, אז yAxis separation: x first, then y
  • כדור מהיר יכול "לדלג" מעל לבנהA fast ball can "skip" a brick
  • לבנה שנשברת מפילה חיזוק לפעמיםA broken brick sometimes drops a power-up
  • כדור מתחת למחבט = חיים פחותBall below the paddle = a life lost
  • שלב מטקסטA level from text

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

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

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