Can we have another book? LaserGame would fit in fine too. I've started writing a chapter explaining PhlappyBird !PhlappyBird PhlappyBird is a smalltalk clone of the well-known little game. It is a nice example of building a small Morphic application and well suited for a tutorial. +file://figures/PhlappyBird.png+ !! The top level window The top level window is a SystemWindow containing a game scene and a button to restart the game. The scene will be recreated when the button is pressed, and it is easiest to just have an instance variable refering to it. [[[ SystemWindow subclass: #PhlappyBirdGame instanceVariableNames: 'scene' classVariableNames: '' category: 'PhlappyBird' ]]] The game can be started by typing ==PhlappyBirdGame play <DoIt>==. That creates a new game, opens it window in te world and sets its width and height. [[[ PhlappyBirdGame class>>play PhlappyBirdGame new openInWorld; extent: 298@510. ]]] In Pharo, ==new== calls ==initialize==. In the initialization, the scene is created, the window is given a title and made unresizable, the scene is told that when the space key is pressed the bird should flap its wings and the restart button is added. [[[ PhlappyBirdGame>>initialize super initialize. scene := self newScene. self setLabel: 'Phlappy Bird'; beUnresizeable; on: Character space do: [ scene flapTheBird ]; addMorph: self createRestartButton frame: (0@0.92 corner: 1@1) ]]]. The ==addMorph:frame:== message is the morphic implementation of the composite pattern. All Morphs can be composites. Most Morphs use ==addMorph:fullFrame:== where the frame provides a layout object, but a SystemWindow adds a simpler variant where a proportional layout can be used with a rectangle with values between 0 and 1 for the relative size. The button takes the 8% of the bottom part of the user-draw area of the window. The scene takes the rest. [[[ PhlappyBirdGame>>newScene | newScene | newScene := Scene new. self addMorph: newScene frame: (0@0 corner: 1@0.92). ^ newScene ]]] !!! The restart button The button is a ==PluggableButtonMorph==. A PluggableButtonMorph is a themeable button, that takes colors, borders and corner radius from the currently selected theme. ;SystemWindow is also a theme-aware object. [[[ PhlappyBirdGame>>createRestartButton ^ PluggableButtonMorph on: self getState: nil action: #restartPressed label: #restartButtonLabel ]]] The PluggableButtonMorph will react to being clicked by performing the ==restartPressed== action method on its model (self), and gets its label from the ==restartButtonLabel== method. The label is just a string. A PluggableButtonMorph can show a binary value, and by ==setState: nil== it is indicated that this is just a plain button. [[[ PhlappyBirdGame>>restartButtonLabel ^ 'New Game' ]]] When the button is pressed, the current scene is removed as submorph from the window and a new one is created and added. [[[ PhlappyBirdGame>>restartPressed scene delete. scene := self newScene. ]]]
Well not everything in there is an Enterprise solution so I think it would be better if renamed to "Pharo Bible" or "Pharo Encyclopedia" , for example Pharo Sound is not exactly Enterprise material, though its my favorite chapter :) By the way great work and thanks for reminding to try this out now, I keep forgetting. This can go also inside our Updated PBE as a nice chapter, its after all ... an example ;) On Wed, Jul 16, 2014 at 6:03 PM, Stephan Eggermont <stephan@stack.nl> wrote:
Can we have another book? LaserGame would fit in fine too.
I've started writing a chapter explaining PhlappyBird
!PhlappyBird
PhlappyBird is a smalltalk clone of the well-known little game. It is a nice example of building a small Morphic application and well suited for a tutorial. +file://figures/PhlappyBird.png+
!! The top level window
The top level window is a SystemWindow containing a game scene and a button to restart the game. The scene will be recreated when the button is pressed, and it is easiest to just have an instance variable refering to it.
[[[ SystemWindow subclass: #PhlappyBirdGame instanceVariableNames: 'scene' classVariableNames: '' category: 'PhlappyBird' ]]]
The game can be started by typing ==PhlappyBirdGame play <DoIt>==. That creates a new game, opens it window in te world and sets its width and height.
[[[ PhlappyBirdGame class>>play PhlappyBirdGame new openInWorld; extent: 298@510. ]]]
In Pharo, ==new== calls ==initialize==. In the initialization, the scene is created, the window is given a title and made unresizable, the scene is told that when the space key is pressed the bird should flap its wings and the restart button is added.
[[[ PhlappyBirdGame>>initialize super initialize. scene := self newScene. self setLabel: 'Phlappy Bird'; beUnresizeable; on: Character space do: [ scene flapTheBird ]; addMorph: self createRestartButton frame: (0@0.92 corner: 1@1) ]]].
The ==addMorph:frame:== message is the morphic implementation of the composite pattern. All Morphs can be composites. Most Morphs use ==addMorph:fullFrame:== where the frame provides a layout object, but a SystemWindow adds a simpler variant where a proportional layout can be used with a rectangle with values between 0 and 1 for the relative size. The button takes the 8% of the bottom part of the user-draw area of the window. The scene takes the rest.
[[[ PhlappyBirdGame>>newScene | newScene | newScene := Scene new. self addMorph: newScene frame: (0@0 corner: 1@0.92). ^ newScene ]]]
!!! The restart button The button is a ==PluggableButtonMorph==. A PluggableButtonMorph is a themeable button, that takes colors, borders and corner radius from the currently selected theme.
;SystemWindow is also a theme-aware object.
[[[ PhlappyBirdGame>>createRestartButton ^ PluggableButtonMorph on: self getState: nil action: #restartPressed label: #restartButtonLabel ]]]
The PluggableButtonMorph will react to being clicked by performing the ==restartPressed== action method on its model (self), and gets its label from the ==restartButtonLabel== method. The label is just a string. A PluggableButtonMorph can show a binary value, and by ==setState: nil== it is indicated that this is just a plain button.
[[[ PhlappyBirdGame>>restartButtonLabel ^ 'New Game' ]]]
When the button is pressed, the current scene is removed as submorph from the window and a new one is created and added. [[[ PhlappyBirdGame>>restartPressed scene delete. scene := self newScene. ]]]
On 16/7/14 17:41, kilon alios wrote: > Well not everything in there is an Enterprise solution so I think it > would be better if renamed to "Pharo Bible" or "Pharo Encyclopedia" , > for example Pharo Sound is not exactly Enterprise material, though its > my favorite chapter :) Yes it should be called Pharo Limbo and once chapters are ready to get out they should be dispatched to the corresponding book > By the way great work and thanks for reminding to try this out now, I > keep forgetting. > > This can go also inside our Updated PBE as a nice chapter, its after > all ... an example ;) I would prefer to keep Pharo by Example as close as the current one and produce - Fun With Pharo - Pharo for the entreprise - Laser Game Tutorial > > > On Wed, Jul 16, 2014 at 6:03 PM, Stephan Eggermont <stephan@stack.nl > <mailto:stephan@stack.nl>> wrote: > > Can we have another book? LaserGame would fit in fine too. > > I've started writing a chapter explaining PhlappyBird > > !PhlappyBird > > PhlappyBird is a smalltalk clone of the well-known little game. It > is a nice example of building a small Morphic application and well > suited for a tutorial. > +file://figures/PhlappyBird.png+ > > !! The top level window > > The top level window is a SystemWindow containing a game scene and > a button to restart the game. The scene will be recreated when the > button is pressed, and it is easiest to just have an instance > variable refering to it. > > [[[ > SystemWindow subclass: #PhlappyBirdGame > instanceVariableNames: 'scene' > classVariableNames: '' > category: 'PhlappyBird' > ]]] > > The game can be started by typing ==PhlappyBirdGame play <DoIt>==. > That creates a new game, opens it window in te world and sets its > width and height. > > [[[ > PhlappyBirdGame class>>play > PhlappyBirdGame new > openInWorld; > extent: 298@510. > ]]] > > In Pharo, ==new== calls ==initialize==. In the initialization, the > scene is created, the window is given a title and made > unresizable, the scene is told that when the space key is pressed > the bird should flap its wings and the restart button is added. > > [[[ > PhlappyBirdGame>>initialize > super initialize. > scene := self newScene. > self > setLabel: 'Phlappy Bird'; > beUnresizeable; > on: Character space do: [ scene flapTheBird ]; > addMorph: self createRestartButton > frame: (0@0.92 corner: 1@1) > ]]]. > > The ==addMorph:frame:== message is the morphic implementation of > the composite pattern. All Morphs can be composites. Most Morphs > use ==addMorph:fullFrame:== where the frame provides a layout > object, but a SystemWindow adds a simpler variant where a > proportional layout can be used with a rectangle with values > between 0 and 1 for the relative size. The button takes the 8% of > the bottom part of the user-draw area of the window. > The scene takes the rest. > > [[[ > PhlappyBirdGame>>newScene > | newScene | > newScene := Scene new. > self > addMorph: newScene > frame: (0@0 corner: 1@0.92). > ^ newScene > ]]] > > !!! The restart button > The button is a ==PluggableButtonMorph==. A PluggableButtonMorph > is a themeable button, that takes colors, borders and corner > radius from the currently selected theme. > > ;SystemWindow is also a theme-aware object. > > [[[ > PhlappyBirdGame>>createRestartButton > ^ PluggableButtonMorph > on: self > getState: nil > action: #restartPressed > label: #restartButtonLabel > ]]] > > The PluggableButtonMorph will react to being clicked by performing > the ==restartPressed== action method on its model (self), and gets > its label from the ==restartButtonLabel== method. The label is > just a string. A PluggableButtonMorph can show a binary value, and > by ==setState: nil== it is indicated that this is just a plain button. > > [[[ > PhlappyBirdGame>>restartButtonLabel > ^ 'New Game' > ]]] > > When the button is pressed, the current scene is removed as > submorph from the window and a new one is created and added. > [[[ > PhlappyBirdGame>>restartPressed > scene delete. > scene := self newScene. > ]]] > >
Hi Stephan, Maybe you should use http://pillarhub.pharocloud.com/hub/pillarhub/about to write and share it. Pharo and Smalltalk is nice for simulations and gaming - maybe a book is suitable. For instance Marco Leberfing from Germany will soon finish his game written in Smalltalk. The game is about ... writing games and the life of game developers. It is written in Dolphin Smalltalk http://gamersgomakers.com Also "Aura - Fate of the Ages" was written with the help of SmalltalkMT. Dont know what happened to it, the site http://www.auragame.com is now gone but the wayback machine still knows about it https://web.archive.org/web/20070202123316/http://www.auragame.com/ Also there is Ludus - a game framework for Amber Smalltalk http://lists.gforge.inria.fr/pipermail/pharo-project/2013-April/077133.html Gaming is interesting, also the part of writing emulators like the existing Nintendo emulator so you can run them on Pharo: http://www.jarober.com/blog/blogView?entry=3555679919 So a book for my library is appreciated and if your time permits to write one ... Thanks Torsten
Gesendet: Mittwoch, 16. Juli 2014 um 17:03 Uhr Von: "Stephan Eggermont" <stephan@stack.nl> An: "Pharo Development List" <pharo-dev@lists.pharo.org> Betreff: [Pharo-dev] Pharo Not For The Enterprise
Can we have another book? LaserGame would fit in fine too.
I've started writing a chapter explaining PhlappyBird
!PhlappyBird
PhlappyBird is a smalltalk clone of the well-known little game. It is a nice example of building a small Morphic application and well suited for a tutorial. +file://figures/PhlappyBird.png+
!! The top level window
The top level window is a SystemWindow containing a game scene and a button to restart the game. The scene will be recreated when the button is pressed, and it is easiest to just have an instance variable refering to it.
[[[ SystemWindow subclass: #PhlappyBirdGame instanceVariableNames: 'scene' classVariableNames: '' category: 'PhlappyBird' ]]]
The game can be started by typing ==PhlappyBirdGame play <DoIt>==. That creates a new game, opens it window in te world and sets its width and height.
[[[ PhlappyBirdGame class>>play PhlappyBirdGame new openInWorld; extent: 298@510. ]]]
In Pharo, ==new== calls ==initialize==. In the initialization, the scene is created, the window is given a title and made unresizable, the scene is told that when the space key is pressed the bird should flap its wings and the restart button is added.
[[[ PhlappyBirdGame>>initialize super initialize. scene := self newScene. self setLabel: 'Phlappy Bird'; beUnresizeable; on: Character space do: [ scene flapTheBird ]; addMorph: self createRestartButton frame: (0@0.92 corner: 1@1) ]]].
The ==addMorph:frame:== message is the morphic implementation of the composite pattern. All Morphs can be composites. Most Morphs use ==addMorph:fullFrame:== where the frame provides a layout object, but a SystemWindow adds a simpler variant where a proportional layout can be used with a rectangle with values between 0 and 1 for the relative size. The button takes the 8% of the bottom part of the user-draw area of the window. The scene takes the rest.
[[[ PhlappyBirdGame>>newScene | newScene | newScene := Scene new. self addMorph: newScene frame: (0@0 corner: 1@0.92). ^ newScene ]]]
!!! The restart button The button is a ==PluggableButtonMorph==. A PluggableButtonMorph is a themeable button, that takes colors, borders and corner radius from the currently selected theme.
;SystemWindow is also a theme-aware object.
[[[ PhlappyBirdGame>>createRestartButton ^ PluggableButtonMorph on: self getState: nil action: #restartPressed label: #restartButtonLabel ]]]
The PluggableButtonMorph will react to being clicked by performing the ==restartPressed== action method on its model (self), and gets its label from the ==restartButtonLabel== method. The label is just a string. A PluggableButtonMorph can show a binary value, and by ==setState: nil== it is indicated that this is just a plain button.
[[[ PhlappyBirdGame>>restartButtonLabel ^ 'New Game' ]]]
When the button is pressed, the current scene is removed as submorph from the window and a new one is created and added. [[[ PhlappyBirdGame>>restartPressed scene delete. scene := self newScene. ]]]
On Wed, Jul 16, 2014 at 5:03 PM, Stephan Eggermont <stephan@stack.nl> wrote:
Can we have another book? LaserGame would fit in fine too.
I would vote to put your chapter in an existing book for now: either UpdatedPharoByExample or EnterprisePharo. That way you benefit from the architecture in place (the jenkins job for example). Then, we can always move the chapter someplace else. -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
On 16/7/14 17:55, Damien Cassou wrote:
On Wed, Jul 16, 2014 at 5:03 PM, Stephan Eggermont <stephan@stack.nl> wrote:
Can we have another book? LaserGame would fit in fine too.
I would vote to put your chapter in an existing book for now: either UpdatedPharoByExample or EnterprisePharo. That way you benefit from the architecture in place (the jenkins job for example). Then, we can always move the chapter someplace else.
In Fun with Pharo: the Next Fun Book :)
Can we have another book? LaserGame would fit in fine too.
I started Fun With Pharo :) https://github.com/SquareBracketAssociates/FunWithPharo I want to write about fun project like Boids, WebCam in Japan with Zinc and other fun stuff :) I'm converting my old tex svn into pillar git :) Feel free to add **fun** chapters :) Stef
I've started writing a chapter explaining PhlappyBird
excellent idea.
!PhlappyBird
PhlappyBird is a smalltalk clone of the well-known little game. It is a nice example of building a small Morphic application and well suited for a tutorial. +file://figures/PhlappyBird.png+
!! The top level window
The top level window is a SystemWindow containing a game scene and a button to restart the game. The scene will be recreated when the button is pressed, and it is easiest to just have an instance variable refering to it.
[[[ SystemWindow subclass: #PhlappyBirdGame instanceVariableNames: 'scene' classVariableNames: '' category: 'PhlappyBird' ]]]
The game can be started by typing ==PhlappyBirdGame play <DoIt>==. That creates a new game, opens it window in te world and sets its width and height.
[[[ PhlappyBirdGame class>>play PhlappyBirdGame new openInWorld; extent: 298@510. ]]]
In Pharo, ==new== calls ==initialize==. In the initialization, the scene is created, the window is given a title and made unresizable, the scene is told that when the space key is pressed the bird should flap its wings and the restart button is added.
[[[ PhlappyBirdGame>>initialize super initialize. scene := self newScene. self setLabel: 'Phlappy Bird'; beUnresizeable; on: Character space do: [ scene flapTheBird ]; addMorph: self createRestartButton frame: (0@0.92 corner: 1@1) ]]].
The ==addMorph:frame:== message is the morphic implementation of the composite pattern. All Morphs can be composites. Most Morphs use ==addMorph:fullFrame:== where the frame provides a layout object, but a SystemWindow adds a simpler variant where a proportional layout can be used with a rectangle with values between 0 and 1 for the relative size. The button takes the 8% of the bottom part of the user-draw area of the window. The scene takes the rest.
[[[ PhlappyBirdGame>>newScene | newScene | newScene := Scene new. self addMorph: newScene frame: (0@0 corner: 1@0.92). ^ newScene ]]]
!!! The restart button The button is a ==PluggableButtonMorph==. A PluggableButtonMorph is a themeable button, that takes colors, borders and corner radius from the currently selected theme.
;SystemWindow is also a theme-aware object.
[[[ PhlappyBirdGame>>createRestartButton ^ PluggableButtonMorph on: self getState: nil action: #restartPressed label: #restartButtonLabel ]]]
The PluggableButtonMorph will react to being clicked by performing the ==restartPressed== action method on its model (self), and gets its label from the ==restartButtonLabel== method. The label is just a string. A PluggableButtonMorph can show a binary value, and by ==setState: nil== it is indicated that this is just a plain button.
[[[ PhlappyBirdGame>>restartButtonLabel ^ 'New Game' ]]]
When the button is pressed, the current scene is removed as submorph from the window and a new one is created and added. [[[ PhlappyBirdGame>>restartPressed scene delete. scene := self newScene. ]]]
participants (5)
-
Damien Cassou -
kilon alios -
Stephan Eggermont -
stepharo -
Torsten Bergmann