CoBlocks - The Basics!

tutorial

#1

CoBlocks - The Basics

Hi and welcome to our CoBlocks tutorial section! This thread is part of an ongoing series that will help you use CoBlocks to create math riddles, animate items, code fun interactions and more. Without further ado, let’s get started with CoBlocks.


What is CoBlocks?

CoBlocks is a block-based programming language. With CoBlocks you code by drag & drop. Blocks represent a snippet of code, or statement, which tells CoSpaces to do something. You can use CoBlocks on the web with your laptop, or code on the fly with your tablet!

1. How do I use CoBlocks?

You can find the code editor for CoBlocks in the top-right toolbar of your space. Click on the code-icon and select CoBlocks. The empty space on the right is the CoBlocks workspace. The list with blocks on the left is the CoBlocks toolbox.

1.1 Where are the items?

To program an item with CoBlocks, you need to add it to CoBlocks from the item inspector first.

2. What kind of blocks can I use?

CoBlocks has two kind of blocks. Expression and Statement - blocks.

  • Statement blocks often perform an action. For example, you let an item talk with the item say - block, while moving it forward with the move item forward - block.

    Forum_StatementBlock

  • Expression blocks contain values. These values can be…

    • Numbers like 5 and 0.25
    • Texts like "Hi there!"
    • Colors (red, green, blue)
    • Other items in the scene

    Forum_ExpressionBlock

    Expression blocks are recognized by their round shape. They can be placed into other blocks.

    Click to show example

    You can place expression blocks into the workspace to easily combine them!

    Click to show example

    Keep in mind that expression blocks won’t do anything when placed on their own in the workspace.

2.1 Special blocks

There are blocks with special behaviours, such as variables, functions and lists. They deserve their own tutorials which you can find at the end of this post :slight_smile:


3. Tutorial: A simple click-interaction in under a minute

In this tutorial we’ll make a character cheer in joy! Let’s start:

  1. Drag & drop one of our animated characters from the library to your scene.
  2. Double tap or right click your character to open the item inspector, then navigate to the nametag-icon and enable “Use in CoBlocks/Blockly”. Now, your item can be found in CoBlocks.
  3. Open CoBlocks by pressing the Code button in the toolbar and select CoBlocks.
  4. To make a click-event, we’re using the when [item] clicked - block. Drag it from the events-category to the workspace!
  5. To make our character say something, we’re using the say - block from the actions-category
  6. Now our item will say something, but it won’t cheer yet. Let’s change that with the play animation - block from the same category.
  7. Click Play, then click your character. See how they’ll animate and say something?

Congrats! You’ve made your first interactive scene :smiley:


4. I want to learn more!

Hope you enjoyed learning the basics! Here you can find our tutorials for…

Cheers,
Stefan


How to get items?
#2

#3

#6

Is there a tutorial on Coblocky for physics?


#7

Hi @mpage,

a physics tutorial is in the works and will be the next tutorial we’ll release here in the forum :slight_smile:


#8

Were can I find more tutorials like this ?


#9

Hi @chistosK!

More tutorials will be added to this forum over time :slight_smile:

Below you can check out:
-Working with variables!
-How to use functions
-Using lists in CoBlocks


#10

A post was split to a new topic: Infinity loop in CoBlocks


#11

Thank you @Stefan !
The tutorials are often the best way to lean something !


#12

Good job,@Stefan ! Now, I need some time to read, understand and put in practice. Thanks so much.


#13

Greeting Everyone,

My names is David, I love CoSpacesEdu

This is amazing co blocks the basics I will put it in practice and learn more about it. Awesome job!