Tutorials

Description

I contain the code that results from tutorials on Bloc.

Details

Source
GitHub
Dialect
pharo (40% confidence)
License
MIT
Stars
9
Forks
2
Created
May 10, 2017
Updated
March 12, 2026
Topics
bloc memory-game pharo tutorial

Categories

UI / Graphics Games Education / Howto

README excerpt

# Tutorials for Bloc

[![License](https://img.shields.io/github/license/pharo-graphics/Tutorials.svg)](./LICENSE)
[![Tests](https://github.com/pharo-graphics/Tutorials/actions/workflows/test.yml/badge.svg)](https://github.com/pharo-graphics/Tutorials/actions/workflows/test.yml)

This repository contains examples of [Bloc](https://github.com/pharo-graphics/Bloc).


## Installation

In [Pharo](https://pharo.org/download), evaluate:

```smalltalk
Metacello new
    baseline: 'BlocTutorials';
    repository: 'github://pharo-graphics/Tutorials:master/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](https://files.pharo.org/books-pdfs/booklet-Bloc/2017-11-09-memorygame.pdf), with some little name adaptations.
The source code for such booklet can be found [here](https://github.com/SquareBracketAssociates/Booklet-BuildingMemoryGameWithBloc).

![Cards](https://github.com/user-attachments/assets/832d8ec9-d521-4d50-a8f2-8ac89637be18)

To start it, evaluate this code:

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

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

"Resize the space to the extent of the game board for the first time (this is known when the layout is applied)"
space root whenLayoutedDoOnce: [ space extent: aGameElement size ].

"Show the window"
space show.
```

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


## Reordering Examples

![dragDrop](https://github.com/user-attachments/assets/37df5a54-59e4-4233-868e-6cafebcc1178)

This package shows the Bloc drag-and-drop examples. Evaluate any the following sentences:

```smalltalk
BlReorderingHandler new inplaceSortingExample.
BlMultiPaneReorderingHandler new threeColumnsExample.
BlMultiPaneReorderingHandler new cardsExample.
BlPaneCreatingReorderingHandler new fittingColumnsExample.
```

Thanks @StephanEggermont for the contribution.


## License

This code is licensed under the [MIT license](./LICENSE).
← Back to results