Chapter 1: Introduction - hpi-swa-teaching/InteractivePongTutorial GitHub Wiki
- Newly visible classes and methods:
- Initial state:
- Explain/Task:
Level 01: Intro
-
Newly visible Classes and Methods:
- Game: initialize
-
Initial state:
- Game with constructor, grey Background in initialize
-
Explain:
- UI Elements: Squeaky has hints, reset and solution buttons, home to chapter view, play starts game (again)
- Navigation through classes
- what Game initialize does and besticky, Game is a Morph, has basic Morph methods
-
Task:
- Change color of Game to Black
Level 02: Create Ball
- Visible Classes and Methods:
- Game: initialize, initializeBall, ball, ball:
- Ball: initialize, game, game:
- Initial state:
- Game: accessors, initializeBall empty, initBall in init
- Ball>>game has setter, Ball>>initialize has just extent
- Explain/Task:
- Write Ball>>initialize: set color and extent to self defaultExtent
- Complete Game:ball getter and setter
- create Ball in initalizeBall in Game via Ball new and set to variable, , self addMorph, explain subMorph behavior
Level 03: Ball movement
- Newly Visible Classes and Methods:
- Ball>>step, stepTime, speed, turnHorizontal, turnVertical
- Initial state:
- step empty, stepTime is set
- Explain/Task:
- set speed in initialize to default speed in x and y direction (hint: point with x @ y)
- update position in step by adding speed
- negate x/y respectively in turnHor/turnVert
- Tips:
- Point with x @ y
- negate with aNumber negated
Level 04: Wall collision
- Newly visible classes and methods:
- Ball>>checkCollisionWithWalls, startover
- Initial state:
- new methods empty
- Explain/Task:
- Game has methods top,bottom,left,right for coordinates of walls and center for center
- Speed has been removed from initialize, we need startOver: set Ball position to center and it speed to random defaultSpeed in all directions
- Hint: you can use *{1 . -1} atRandom for a random positive or negative Value
- between: aNumber and: aNumber checks if something is inbetween
- (condition) ifFalse: [then] is if
- Write Collide withWalls, should turnHorizontal on left/right and vertical on top/bottom