From 846be526adb128196ddc2d140b247269bf646d0e Mon Sep 17 00:00:00 2001 From: Simon Venzlaff Date: Fri, 12 Jul 2024 19:17:48 +0200 Subject: [PATCH] Readd 0301 explanations --- .../IPTBall.class.st | 26 +++++++++---------- .../IPTGame.class.st | 26 +++++++++---------- .../IPTPlayer.class.st | 24 ++++++++--------- .../IPTLevel0301.class.st | 9 +++++-- 4 files changed, 45 insertions(+), 40 deletions(-) diff --git a/src/InteractivePongTutorial-Game/IPTBall.class.st b/src/InteractivePongTutorial-Game/IPTBall.class.st index 1bd3715..92b85d7 100644 --- a/src/InteractivePongTutorial-Game/IPTBall.class.st +++ b/src/InteractivePongTutorial-Game/IPTBall.class.st @@ -14,7 +14,7 @@ Class { { #category : #collision, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> checkCollisionWithPlayer [ "Check collision with Players using 'intersects:' message." @@ -22,7 +22,7 @@ IPTBall >> checkCollisionWithPlayer [ { #category : #collision, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> checkCollisionWithWalls [ (self position x between: self game left and: self game right - self width) @@ -50,7 +50,7 @@ IPTBall >> defaultExtent [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> defaultSpeed [ ^ 10. @@ -58,7 +58,7 @@ IPTBall >> defaultSpeed [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> game [ ^ game. @@ -66,7 +66,7 @@ IPTBall >> game [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> game: aGame [ game := aGame. @@ -74,7 +74,7 @@ IPTBall >> game: aGame [ { #category : #initialization, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> initialize [ super initialize. @@ -86,7 +86,7 @@ IPTBall >> initialize [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> speed [ ^ speed. @@ -94,7 +94,7 @@ IPTBall >> speed [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> speed: aNumber [ speed := aNumber. @@ -102,7 +102,7 @@ IPTBall >> speed: aNumber [ { #category : #initialization, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> startOver [ self @@ -112,7 +112,7 @@ IPTBall >> startOver [ { #category : #stepping, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> step [ "Check for collision with a Player." @@ -123,7 +123,7 @@ IPTBall >> step [ { #category : #stepping, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> stepTime [ ^ 10. @@ -131,7 +131,7 @@ IPTBall >> stepTime [ { #category : #movement, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> turnHorizontal [ self speed: self speed x negated @ self speed y. @@ -139,7 +139,7 @@ IPTBall >> turnHorizontal [ { #category : #movement, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTBall >> turnVertical [ self speed: self speed x @ self speed y negated. diff --git a/src/InteractivePongTutorial-Game/IPTGame.class.st b/src/InteractivePongTutorial-Game/IPTGame.class.st index d2ac436..6f8c532 100644 --- a/src/InteractivePongTutorial-Game/IPTGame.class.st +++ b/src/InteractivePongTutorial-Game/IPTGame.class.st @@ -23,7 +23,7 @@ IPTGame class >> open [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> ball [ ^ ball. @@ -31,7 +31,7 @@ IPTGame >> ball [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> ball: aBall [ ball := aBall. @@ -39,7 +39,7 @@ IPTGame >> ball: aBall [ { #category : #'event handling', - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> handlesKeyboard: anEvent [ ^ true. @@ -47,7 +47,7 @@ IPTGame >> handlesKeyboard: anEvent [ { #category : #initialization, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> initialize [ super initialize. @@ -58,7 +58,7 @@ IPTGame >> initialize [ { #category : #initialization, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> initializeBall [ self @@ -70,7 +70,7 @@ IPTGame >> initializeBall [ { #category : #initialization, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> initializePlayers [ | offset | @@ -88,7 +88,7 @@ IPTGame >> initializePlayers [ { #category : #'event handling', - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> keyDown: anEvent [ (anEvent keyCharacter asUppercase = $W ) ifTrue: [self playerLeft up]. @@ -99,7 +99,7 @@ IPTGame >> keyDown: anEvent [ { #category : #'event handling', - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> keyUp: anEvent [ ({$W.$S} anySatisfy: [ :key | @@ -129,7 +129,7 @@ IPTGame >> mouseLeave: anEvent [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> playerBounds [ "Return a colletion of the bounds of all Players. Use 'bounds' message of Morphs." @@ -137,7 +137,7 @@ IPTGame >> playerBounds [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> playerLeft [ ^ playerLeft. @@ -145,7 +145,7 @@ IPTGame >> playerLeft [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> playerLeft: aPlayer [ playerLeft := aPlayer. @@ -153,7 +153,7 @@ IPTGame >> playerLeft: aPlayer [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> playerRight [ ^ playerRight. @@ -161,7 +161,7 @@ IPTGame >> playerRight [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTGame >> playerRight: aPlayer [ playerRight := aPlayer. diff --git a/src/InteractivePongTutorial-Game/IPTPlayer.class.st b/src/InteractivePongTutorial-Game/IPTPlayer.class.st index 1da000f..2b4e439 100644 --- a/src/InteractivePongTutorial-Game/IPTPlayer.class.st +++ b/src/InteractivePongTutorial-Game/IPTPlayer.class.st @@ -14,7 +14,7 @@ Class { { #category : #'as yet unclassified', - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> defaultExtent [ ^ (15@100). @@ -22,7 +22,7 @@ IPTPlayer >> defaultExtent [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> defaultSpeed [ ^ 10. @@ -30,7 +30,7 @@ IPTPlayer >> defaultSpeed [ { #category : #movement, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> down [ self speed: self defaultSpeed. @@ -38,7 +38,7 @@ IPTPlayer >> down [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> game [ ^ game. @@ -46,7 +46,7 @@ IPTPlayer >> game [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> game: aGame [ game := aGame. @@ -54,7 +54,7 @@ IPTPlayer >> game: aGame [ { #category : #initialization, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> initialize [ super initialize. @@ -66,7 +66,7 @@ IPTPlayer >> initialize [ { #category : #movement, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> move: aNumber [ | dist | @@ -77,7 +77,7 @@ IPTPlayer >> move: aNumber [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> speed [ ^ speed. @@ -85,7 +85,7 @@ IPTPlayer >> speed [ { #category : #accessing, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> speed: aNumber [ speed := aNumber. @@ -93,7 +93,7 @@ IPTPlayer >> speed: aNumber [ { #category : #stepping, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> step [ self move: self speed. @@ -109,7 +109,7 @@ IPTPlayer >> stepTime [ { #category : #movement, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> stop [ self speed: 0. @@ -117,7 +117,7 @@ IPTPlayer >> stop [ { #category : #movement, - #'squeak_changestamp' : 'sv 7/12/2024 19:11' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTPlayer >> up [ self speed: self defaultSpeed negated. diff --git a/src/InteractivePongTutorial-Levels/IPTLevel0301.class.st b/src/InteractivePongTutorial-Levels/IPTLevel0301.class.st index d65291d..69a5832 100644 --- a/src/InteractivePongTutorial-Levels/IPTLevel0301.class.st +++ b/src/InteractivePongTutorial-Levels/IPTLevel0301.class.st @@ -24,11 +24,16 @@ IPTLevel0301 class >> description [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'FH 7/10/2024 19:01' + #'squeak_changestamp' : 'sv 7/12/2024 19:17' } IPTLevel0301 class >> explanations [ - ^ {''.}. + ^ {'We want the ball to check if it collides with one of players. For that, the ball needs to know where the players are and how big they are. This information is held by playerBounds.'. + 'Then, actually check for a collision in checkCollisionWithPlayer. Luckily, you do not need to implement all the details yourself since Squeak already provides a function that does what we want.'. + 'Now, since the ball could start colliding with a player on every new step it takes, we therefore want to check on every step of the ball if there is a collision happening. We do this by calling the function we just wrote.'. + 'Hint: playerBounds is a collection, where every entry are the bounds of one player'. + 'Hint: checkCollisionWithPlayer checks for collision between ball and every player. So we need to look at every entry of our playerBounds collection.'. + 'Hint: To recall: step is called every time we want to move the ball. So we will then need to check for collisions, too.'}. ] {