# A Virtual Playground to Easily Learn Loops and Coding

Thanks to the generous support of Intel and Microsoft, we have been able to work for already 6 weeks in Zenva Sky – the world’s first app to teach coding in a virtual reality environment. The road has certainly been challenging – we’ve had to invent the whole wheel as this has not been done before, but that is also what’s been the most exciting about this journey.

As we shared in our weekly updates, finding the right mechanics for this educational experience took some fine-tunning. Once we found the right system we moved on to implementing core features and demo content that covers some of the computer science and coding concepts we want to teach. This is the process we’ve been following:

We are currently in an early to mid alpha stage, still implementing some of the core features of the product. In terms of content, Zenva Sky has now 8 coding challenges or levels. We’ve been polishing and improving this content based on user feedback.

# Expanding the set of commands

One of the things we’ve observed at Zenva is that a lot of people who are learning to code find it difficult to grasp the concepts of loops or iterations, so that was our main focus this week.

So far, Zenva Sky offers the following commands to the user, who can use them to code a robotic vehicle and complete challenges:

• Move (in straight line)
• Rotate 90 degrees to the left or right
• Activate adjacent Boolean switches (to unlock Boolean gates)

We’ve now also added the ability to create basic loops, where one or more commands can be repeated multiple times.

# Looping commands

To illustrate how loops work in Zenva Sky we created two new levels which can only be solved by using such elements.

Let’s take a look at Level 7 from a top-down perspective:

As you can see, this level could be solved in theory by using two commands: Move and Rotate. The player would move one cell, then rotate, then move, and so forth.

The problem with this approach other than the fact that it is very repetitive is that the number of commands needed to solve the challenge in that manner is greater than the limited space programs in Zenva Sky can have.

Level 7 can also be solved by repeating the following 4 times:

1. Move
2. Rotate left
3. Move
4. Rotate right

For that, we can use a loop as shown below:

The image below shows how loops are entered in the vehicle’s dashboard. These buttons are pressed with hand-tracked controllers:

# Combining loops and Boolean gates

In order to illustrate how this system can be combined with the different interactive elements we have already developed, we created a coding challenge which can only be solved with loops which incorporates Boolean switches connected to doors that open when the switch is activated.

This could be easily extended to use some of the gates we’ve already implemented (AND, OR and XOR).

# Next steps

One element we've been wanting to include from the start is conditionals. The ability for the program to check whether a condition is true, and take action depending on that. This could allow the robot to navigate changing environments for instance. So that will be the next item on our list!

What should we focus on next? Feel free to reach out on Twitter @ZenvaTweets if you have any questions or ideas!

For more complete information about compiler optimizations, see our Optimization Notice.