Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Criação de Jogos
com Stencyl
How to do something this book explains
1st Edition
by
Gurigraphics
www.address.com
Content
INTRODUCTION............................................................................02
CONCLUSION................................................................................37
Introduction
Stencyl is one of the best opensource engines for learning how to create games. It is the most
organized and productive engine of all. It does not require knowledge of a programming
language. Requires only programming logic. But you can also use code.
The Engine is written in Haxe which is a cross-platform language similar to C++, C# and Action
Script. With Haxe and Openfl libraries it is possible to create extensions to extend the
possibilities of Stencyl.
In the Starter version of Stencyl it is possible to export in formats: Flash and HTML5.
In the Indie version you can export to Flash, HTML5, Windows, Mac and Linux.
And in the Enterprise version it is possible to export to Flash, HTML5, Mac, Linux,
Windows, Iphone and Android.
Stencyl uses the same code to export in native code for all these platforms. The performance is
about 10x better than a HTML5 game running on a smartphone's browser when it's not a native
app.
Stencyl is the best option for those who do not want to be just a programmer. And neither take
the whole afternoon to just make a character walk the screen.
In this book you will learn the basics about how the Stencyl works. All exposed in a simple and
step-by-step way, without excess of words and explanations. You will learn here, in a practical
method, what it would take you several weeks to learn alone.
Welcome to Level 01
youtube.com/gurigraphics
On the Stencyl website click the "download" button. You will be redirected to another page
where you can choose the version of Stencyl for your operating system: Mac, Windows or
Linux. The program has about 100Mb. Download the program.
If you want to choose a specific folder to install Stencyl click "Browse ...".
After that click "Install".
Finally, if you want to run Stencyl check the "Run Stencyl" option and click "Finish".
Access the folder that you installed the program. Right click on the Stencyl icon and choose the
option "Create shortcut".
A new icon will be created. Copy this icon (Ctrl + C) and paste (Ctrl + V) into your desktop or
wherever you prefer.
In the next window will appear the question: "What kind of game do you want to create?".
Select the "Blank Game" option and click "Next".
Then choose a name for your game and the resolution that is the size of the game screen.
What is a scene? A scene is one of the game screens. A scene can be the home screen of the
game, the screen of credits of the game, a phase of the game, etc.
1- Click on the area: "This Game contains no Scenes. Click here to create one ".
2- Click the button: "Create New".
3- Click on: File → Create New → Scene.
4- Use keys: Ctrl + N.
Name: The name of the scene (which should not contain accents and special characters).
Width: The width of the scene. (Measured in tiles or pixels)
Height: The height of the scene.
Tile Width: The width of the tile.
Tile Height: The height of the tile.
Color: The color of the background.
What is a Tile?
Tile is like a slice of an image. In a game, to save memory and the game does not get too heavy,
we do not use whole images, but pieces of images that repeat themselves. These pieces of images
are the tiles.
For example, in a game, the lives of the characters are usually represented by the images of
hearts.
On the game screen you can see 3 or 4 images of hearts about 32px by 32px. However, repeated
pictures are not used in the game. It is the same image that repeats 3 or 4 times on the screen.
What is a Tileset?
Tileset is like a kind of mosaic. It's a set of tiles like the image above.
Since we do not need repeated images inside a game, we can construct an image equal to the
image above with this simplified tileset below. For, we can only repeat these images as a kind of
stamp.
With the scene open, in the upper right corner you choose the options:
After choosing the format you want to test the scene click on "Test Scene".
To duplicate a scene click the "Dashboard" tab. Select the scene you want to duplicate. Then
right click on it. And click on "Duplicate".
After duplicating the scene, double-click on the newly created scene or press "Enter".
Then click "Properties" to open the scene settings and change the name, for example, from "1
Copy" to "2". Finally, click "ok".
Then you will go to: File → Export Game. And export the game project in * .stencyl format
With this, the project will always be available in the home screen: "Welcome Center".
Then select the "Save" options to save changes or "Don't Save" to close without saving.
From the home screen "Welcome Center", double-click the project or select the project and press
"Enter."
This way, if you click on "Test Game" instead of "Test Scene", the whole game will open, and
the selected Scene will be the first one to be displayed. However, in these our examples
obviously the scenes are still blank.
First open the scene with a double click. Or select the scene and press "enter".
Then: 1- Click the tab "Events". 2- Click "Add Event". 3- Click "Basics" and select "When
Drawing".
On the right choose "Drawing" and drag the "draw text" block to the left.
Write the text "Hello World" and the positions x = 32, y = 32.
Then click "Test Scene" to save, compile the game and run:
The result:
As before we chose X = 32, Y = 32, the text was displayed in that position.
What are variables? Variables are spaces in the temporary memory of the computer that we use
to store data.
In Stencyl there are two types of variables: Attributes and Game Attributes.
Attributes work as local variables. When you create an attribute in a scene, this data is only
available in this scene.
Game Attributes work as global variables. They store data that can be accessed in any scene.
An attribute can be used, for example, to store a text or the position of an element on the screen.
For, this value needs to be accessed only in this scene.
A game attribute can be used, for example, to store the player's score or level of progress. For
these values need to be accessed in several scenes.
In Stencyl there are 21 types of Attributes. And only 5 types of Game Attibutes.
To create an attribute:
1- Click on "Attributes".
2- Click on "Create an Attribute ...".
3- Enter the name of the attribute.
4- Choose the type of attribute, for example, type: "Text".
5- Click "ok".
When you create an attribute two types of blocks are generated: Getters and Setters
A "Setter" block is used to define the value that will be stored in the attribute.
A "Getter" block is used to access the value that was defined by the "Setter" block.
Example:
In the first block we define the value of the attribute text with the phrase: "My first attribute".
In the second block we draw on the screen the attribute text value in the positions x: 32, y: 32 of
the screen.
What is the advantage of using variables / attributes? The advantage is that we can change the
value only once, and it will be changed in all places that the same attribute is used.
Click in:
1- Add event
2- Basics
3- When Creating
When Creating is used to perform events only when the scene is created.
For example:
When the scene is created the attribute text will be set to the value "My first Attribute".
Click in:
1- Add event
2- Basics
3- When Updating
As a game is updated at the speed of about 60FPS (frames per second), this event will run about
60 times per second.
For example:
The result will be a kind of timer because whenever the game is updated (When updating) +1
will be added to the "number" value. And this will occur 60 times per second.
TIP: "Slowdown" in games usually occurs just in these constant updates. So avoid using "When
updating" as much as possible.
To remove an event:
You do not need to know how all the blocks work. You need to learn to use only the most
commonly used blocks. So:
With this you will learn how to make a sum, subtraction, division, multiplication.
The "random integer between" block will draw a random integer number between the first and
second value. And "random float between" will do the same with non-integer numbers -
Remember to use point (.) and no comma (,) between numbers.
With the scene open, click: Events → Add Event → Input → Click
When this occurs everything that is placed inside the block is executed.
For example:
In the first block we define the following: whenever the left mouse button is pressed, the value of
the attribute number must be set to a random value and integer between 1 and 6, as a dice.
In the second block we define the following: draw a text on the screen with the value that is
stored in the attribute number in positions x: 32, and: 32.
If you do not want to delete an event, you can only deactivate it. To do this simply click on the
"text-box" of the event.
Do this and click "Test Scene" to verify that the mouse click did not really work.
Conclusion of LEVEL 01
youtube.com/gurigraphics
facebook.com/gurigraphics
twitter.com/gurigraphics
You can use and share this book for free, licensed under a
https://creativecommons.org/licenses/by-nc/3.0/
By Gurigraphics
Made in Brazil