Skip to content

Latest commit

 

History

History
82 lines (52 loc) · 2.34 KB

README.md

File metadata and controls

82 lines (52 loc) · 2.34 KB

Tutorials for Bloc and Brick

License Test

This repository contains examples of Bloc and Brick.

Installation

In Pharo 9 or 10, evaluate:

Metacello new
    baseline: 'BlocBrickTutorials';
    repository: 'github://pharo-graphics/Tutorials/src';
    load

Memory Game Tutorial

This is a Memory Card game. Please, find the code at the Bloc-Memory package.

The present code is the result of following the Bloc tutorial in this booklet, with some little name adaptations. The source code for such booklet can be found here.

Window

To start it, evaluate this code:

"Create the game model and the Bloc element."
aGameElement := MGGameElement new
	memoryGame: MGGame withNumbers;
	yourself.

"The space represents the window"
space := BlSpace new.
space addChild: aGameElement. 

"Calculate the extent of the game board for the first time, to set it to the window."
space pulse.
space extent: aGameElement extent.

"Show the window"
space show. 

By default, a Morphic window will popup. It is also possible to open a OS "external" window. To do it, open "System Settings > Appearance > Bloc" and select "OSWindow - SDL2" in "Preferable Host".

Reordering

This example shows how to use drag-and-drop, and it's written using Bloc and Brick.

Reordering Capture

To execute it, evaluate the following code:

pane := DTPaneCreatingReorderingHandler new 
        fittingColumns   
        constraintsDo: [ :c | 
            c horizontal matchParent.
            c vertical matchParent ];
        yourself.
space := BlSpace new extent: 800@600.

space root addChild: pane.
space show.

Thanks @StephanEggermont for the contribution.

License

This code is licensed under the MIT license.