Fandom

Project Spark Wiki

How the brains work

233pages on
this wiki
Add New Page
Comments0 Share

Before ReadingEdit

Before we get into the major kode concepts, make sure you've played the tutorial level on Project Spark. This guided tour to Project Spark is necessary to help you learn the controls and the components of the game.

Untitled-1

What is "Kode"?Edit

In Project Spark, all logic happens inside the "brain" of every prop. By "brain", we mean a place where all the WHEN and DOs are stored. All these lines of WHEN and DO are called kode. The reason it is called kode instead of code, is because Project Spark is based on the evolution of Kodu, a simplified programming language published by Microsoft FUSE Labs in 2009.

How To Create Games in Project Spark-015:47

How To Create Games in Project Spark-0











When/DoEdit

The whole concept of WHEN/DO is something that spans in all programming languages. Ever since the evolution of coding languages in the 1950’s, the concept of “when” and “do” became integral concepts of code. They’ve been called and combined with other words like “if”, “while”, “until”, “else” and “for”, to name a few.

These commands in code are used to tell a computer system what to do, how to do it, and when to do it. Project Spark simplifies all these different buzzwords into just two: WHEN this happens, DO that thing

Ss (2014-08-13 at 12.39.34)

The WHENs and DOs contain a succession of Kode tiles, which must execute a specific action when read. Each tile has got a description detailing what it does and how to use it in kode.

Execution OrderEdit

A brain is run from beginning to end every frame, and every time a brain is run it is called a tick. The brain runs lines in sequence, and will always run line 1 before it runs line 2 if it runs both lines.

Tick

For each line that the brain goes to run, first the When side is evaluated, then, if the conditions on the when side are met, the do side is executed. When a rule is evaluated, if the conditions are not met, then the brain will not execute the Do side or any subrules, nor will it evaluate any subrules for that tick.

PagesEdit

Each brain contains one or more pages. When it is time to run a brain in Spark, first the brain must know which page to run. Each brain keeps track of its [current page] which defines the page that the brain starts running from each tick. This can be changed through execution to change your object's behavior, or a page can be called while running another page for more complex behaviors.

Ss (2014-08-26 at 07.21.18)


Object OrderingEdit

Project Spark does not currently guarantee the order that the object's brain will run in a tick. The brains will run one at a time, and in a single play session the brain's are guaranteed to continually execute in the same order but if you restart the game, the order of your next play session may be different. This can be important if you have different brains reliant on each other. Your kode should be able to handle the order of execution being different.

Ss (2014-08-26 at 07.22.46)

Default Behaviors And ModifiersEdit

A single tile in Spark can perform surprisingly complex tasks. For example, the shoot tile will cause your character to shoot a fireball directly ahead which will destroy itself on contact or after a preset amount of time. In order for shoot to be easy to use, all that information is set by having smart defaults for the shoot tile, but the default isn't always what you want in your game.


Ss (2014-08-26 at 07.24.26)

After the shoot tile, check out the modifiers folder in the tile picker to really customize how your shooting works. Most modifiers require a specific piece of information to function. For example, the [in direction] modifier requires a vector, whereas the [at speed] modifier needs a number. However, some modifiers, like the [disallow friendly fire] modifier, when specified, immediately causes your shots to be unable to harm your allies.

Not all modifiers are found under the modifiers folder. For example, the shoot tile allows you to select an object to shoot. There is no modifier for [shoot this object], it simply knows that if you specify an object after the shoot tile, that is what you want to shoot. Make sure you check out each tile's description to get a better understanding of what you can make it do.


Read NextEdit

Variables


Further readingEdit

Timing and Logic

Brain Tiles


< Back to Koding Curriculum

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.