Skip to content

Commit

Permalink
Merge branch 'main' into code-execution3
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlDuda committed Jun 28, 2024
2 parents 66ece27 + 118da03 commit f684623
Show file tree
Hide file tree
Showing 27 changed files with 3,458 additions and 28 deletions.
48 changes: 28 additions & 20 deletions .squot-materialize
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,50 @@
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'Cloverleaf.png'
'stop.png'
],
#encoding : Class [ #PNGReadWriter ]
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'play.png'
'Kara-FacingDown.png'
],
#encoding : @4
},
SquotTonelMapper {
#package : MCPackage {
#name : 'SqueakKara-Tests'
},
#path : FSAbsolutePath [
'src'
]
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'stop.png'
'Trunk.png'
],
#encoding : @4
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'Kara-FacingUp.png'
'pause.png'
],
#encoding : @4
},
SquotTonelMapper {
#package : MCPackage {
#name : 'SqueakKara-Core'
#name : 'SqueakKara'
},
#path : @9
#path : FSAbsolutePath [
'src'
]
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'pause.png'
'Kara-FacingRight.png'
],
#encoding : @4
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'Trunk.png'
'play.png'
],
#encoding : @4
},
Expand All @@ -64,22 +58,36 @@
},
SquotTonelMapper {
#package : MCPackage {
#name : 'BaselineOfSqueakKara'
#name : 'SqueakKara-Tests'
},
#path : @9
#path : FSAbsolutePath [
'src'
]
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'Kara-FacingRight.png'
'Kara-FacingUp.png'
],
#encoding : @4
},
SquotTonelMapper {
#package : MCPackage {
#name : 'SqueakKara-Core'
},
#path : @22
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'Kara-FacingDown.png'
'Cloverleaf.png'
],
#encoding : @4
},
SquotTonelMapper {
#package : MCPackage {
#name : 'BaselineOfSqueakKara'
},
#path : @22
}
]
Binary file modified assets/Kara-FacingRight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 113 additions & 6 deletions src/SqueakKara-Core/SKEnvironment.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Class {
'workspace',
'executer',
'kara',
'executeControls'
'executeControls',
'gameWidth',
'gameHeight'
],
#category : #'SqueakKara-Core'
}
Expand Down Expand Up @@ -84,6 +86,42 @@ SKEnvironment >> executionSpeed: aSpeed [
self executer speed: aSpeed.
]

{
#category : #accessing,
#'squeak_changestamp' : 'jt 6/24/2024 00:14'
}
SKEnvironment >> gameHeight [

^ gameHeight ifNil: [gameHeight := self grid height + (self grid pixelPerBlock * 4)]
]

{
#category : #accessing,
#'squeak_changestamp' : 'jt 6/24/2024 00:16'
}
SKEnvironment >> gameHeight: aNumber [

gameHeight := aNumber
]

{
#category : #accessing,
#'squeak_changestamp' : 'jt 6/24/2024 00:15'
}
SKEnvironment >> gameWidth [

^ gameWidth ifNil: [gameWidth := self grid width + (self grid pixelPerBlock * 2)]
]

{
#category : #accessing,
#'squeak_changestamp' : 'jt 6/24/2024 00:15'
}
SKEnvironment >> gameWidth: aNumber [

gameWidth := aNumber
]

{
#category : #accessing,
#'squeak_changestamp' : 'JJG 6/17/2024 16:40'
Expand Down Expand Up @@ -113,10 +151,11 @@ SKEnvironment >> initialize [

{
#category : #initialization,
#'squeak_changestamp' : 'KD 6/23/2024 20:56'
#'squeak_changestamp' : 'jt 6/24/2024 00:17'
}
SKEnvironment >> initializeWithChallenge1 [

| gameWindow startPoint |

self grid: (SKGrid newWithExtent: 7 @ 7).
self kara: self grid challenge1.
Expand All @@ -125,14 +164,32 @@ SKEnvironment >> initializeWithChallenge1 [
(self executer kara) kara: self kara.
self executeControls: SKExecuteControls new.
executeControls environment: self.

gameWindow := SystemWindow new.
gameWindow setLabel: 'Kara'.
gameWindow extent: self gameWidth @ self gameHeight.
gameWindow setWindowColor: self grid backgroundColor.

gameWindow addMorph: self executeControls.
gameWindow addMorph: self grid.

startPoint := self grid pixelPerBlock @ (3 * self grid pixelPerBlock).
self grid position: gameWindow position + startPoint.

startPoint := ((self gameWidth / 2) - (executeControls width / 2)) @ ( 1.5 * self grid pixelPerBlock).
self executeControls position: gameWindow position + startPoint.

gameWindow openInHand.

]

{
#category : #initialization,
#'squeak_changestamp' : 'KD 6/23/2024 20:56'
#'squeak_changestamp' : 'jt 6/24/2024 00:23'
}
SKEnvironment >> initializeWithChallenge2 [

| gameWindow startPoint |

self grid: (SKGrid newWithExtent: 9 @ 2).
self kara: self grid challenge2.
Expand All @@ -141,14 +198,31 @@ SKEnvironment >> initializeWithChallenge2 [
(self executer kara) kara: self kara.
self executeControls: SKExecuteControls new.
executeControls environment: self.

gameWindow := SystemWindow new.
gameWindow setLabel: 'Kara'.
gameWindow extent: self gameWidth @ self gameHeight.
gameWindow setWindowColor: self grid backgroundColor.

gameWindow addMorph: self executeControls.
gameWindow addMorph: self grid.

startPoint := self grid pixelPerBlock @ (3 * self grid pixelPerBlock).
self grid position: gameWindow position + startPoint.

startPoint := ((self gameWidth / 2) - (executeControls width / 2)) @ ( 1.5 * self grid pixelPerBlock).
self executeControls position: gameWindow position + startPoint.

gameWindow openInHand.
]

{
#category : #initialization,
#'squeak_changestamp' : 'KD 6/23/2024 20:57'
#'squeak_changestamp' : 'jt 6/24/2024 00:23'
}
SKEnvironment >> initializeWithChallenge3 [

| gameWindow startPoint |

self grid: (SKGrid newWithExtent: 9 @ 3).
self kara: self grid challenge3.
Expand All @@ -157,22 +231,55 @@ SKEnvironment >> initializeWithChallenge3 [
(self executer kara) kara: self kara.
self executeControls: SKExecuteControls new.
executeControls environment: self.

gameWindow := SystemWindow new.
gameWindow setLabel: 'Kara'.
gameWindow extent: self gameWidth @ self gameHeight.
gameWindow setWindowColor: self grid backgroundColor.

gameWindow addMorph: self executeControls.
gameWindow addMorph: self grid.

startPoint := self grid pixelPerBlock @ (3 * self grid pixelPerBlock).
self grid position: gameWindow position + startPoint.

startPoint := ((self gameWidth / 2) - (executeControls width / 2)) @ ( 1.5 * self grid pixelPerBlock).
self executeControls position: gameWindow position + startPoint.

gameWindow openInHand.
]

{
#category : #initialization,
#'squeak_changestamp' : 'EB 6/22/2024 14:11'
#'squeak_changestamp' : 'jt 6/24/2024 00:23'
}
SKEnvironment >> initializeWithKaraAt: aPoint [


| gameWindow startPoint |

self grid: (SKGrid newWithExtent: 7 @ 7).
self kara: (SKKara newInGrid: self grid at: aPoint).
self workspace: (SKWorkspace newWithKara: self kara).
self executer: (SKExecuter new).
(self executer kara) kara: self kara.
self executeControls: SKExecuteControls new.
executeControls environment: self.

gameWindow := SystemWindow new.
gameWindow setLabel: 'Kara'.
gameWindow extent: self gameWidth @ self gameHeight.
gameWindow setWindowColor: self grid backgroundColor.

gameWindow addMorph: self executeControls.
gameWindow addMorph: self grid.

startPoint := self grid pixelPerBlock @ (3 * self grid pixelPerBlock).
self grid position: gameWindow position + startPoint.

startPoint := ((self gameWidth / 2) - (executeControls width / 2)) @ ( 1.5 * self grid pixelPerBlock).
self executeControls position: gameWindow position + startPoint.

gameWindow openInHand.
]

{
Expand Down
6 changes: 4 additions & 2 deletions src/SqueakKara-Core/SKExecuteControls.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,15 @@ SKExecuteControls >> getTexture: aFilename [

{
#category : #widgets,
#'squeak_changestamp' : 'EB 6/22/2024 14:03'
#'squeak_changestamp' : 'jt 6/23/2024 23:59'
}
SKExecuteControls >> initialize [

super initialize.
self bounds: self defaultBounds.
self color: Color white.
self color: Color lightGreen lighter.
self borderWidth: 1 px.
self borderColor: Color lightGray.
self addAllWidgets.
self openInWorld.
]
Expand Down
23 changes: 23 additions & 0 deletions src/SqueakKara/SKCloverleaf.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Class {
#name : #SKCloverleaf,
#superclass : #SKGridObject,
#category : #'SqueakKara-Core'
}

{
#category : #type,
#'squeak_changestamp' : 'jt 6/11/2024 13:02'
}
SKCloverleaf >> isCloverleaf [

^ true
]

{
#category : #appearance,
#'squeak_changestamp' : 'jt 6/11/2024 19:55'
}
SKCloverleaf >> textureFilename [

^ 'Cloverleaf.png'
]
50 changes: 50 additions & 0 deletions src/SqueakKara/SKDirection.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Class {
#name : #SKDirection,
#superclass : #Object,
#category : #'SqueakKara-Core'
}

{
#category : #directions,
#'squeak_changestamp' : 'LK 5/24/2024 11:28'
}
SKDirection class >> above [

^ 0 @ -1
]

{
#category : #directions,
#'squeak_changestamp' : 'LK 5/24/2024 11:28'
}
SKDirection class >> below [

^ 0 @ 1
]

{
#category : #directions,
#'squeak_changestamp' : 'LK 5/24/2024 11:28'
}
SKDirection class >> here [

^ 0 @ 0
]

{
#category : #directions,
#'squeak_changestamp' : 'LK 5/24/2024 11:28'
}
SKDirection class >> left [

^ -1 @ 0
]

{
#category : #directions,
#'squeak_changestamp' : 'LK 5/24/2024 11:28'
}
SKDirection class >> right [

^ 1 @ 0
]
Loading

0 comments on commit f684623

Please sign in to comment.