Scratch To Unity: Operators

Beginner Scratch Tutorial Unity

This post provides a handy reference guide to go from Scratch’s “Operators” category of code blocks to C# with Unity.

German States
Wednesday October 24, 2018

Baden-Wurttemberg Size: 35,751 square kilometers Capital: Stuttgart Population: 11 million residents The state of Baden-Wurttemberg is located in the southwest of Germany and it covers an area of 35,751 square kilometers. This region is home to around 11 million inhabitants with around 600,000 of them residing in the capital and the largest city in this […]

The post German States appeared first on Dua xe moto.

Code Blocks
Click on the picture of any of these Scratch code blocks to see how to write similar code statements in C#.

Film & Game Releases: Week of May 3
Tuesday April 30, 2019

CHECK OUT OUR LIST OF MOVIE RELEASES FOR THE WEEK OF May 3, 2019! From The Intruder to UglyDolls, here is a schedule of the films and games coming out soon! Film Release Schedule El Chicano Synopsis from The NumbersWhen L.A.P.D. Detective Diego Hernandez is assigned a career-making case investigating a vicious cartel, he uncovers […]

The post Film & Game Releases: Week of May 3 appeared first on Dua xe moto.

int score = 5 + 6; // 11
int age = score + 1; // 12
int total = score + age; // 23
score += 1; // 12
score++; // 13

int score = 10 – 5; // 5
int age = score – 1; // 4
int total = score – age; // 1
score -= 1; // 4
score–; // 3

int score = 3 * 5; // 15
int age = score * 2; // 30
int total = score * age; // 450
score *= 3; // 45

German Language Course Visa
Tuesday October 23, 2018

You need a German language course visa if you’ve been confirmed as a participant in a non-academic German language course, lasting 3-12 months, covering at least 18 hours of lessons each week. This course shouldn’t be predestined to prepare you for further university studies in Germany. A German language course visa is valid initially for […]

The post German Language Course Visa appeared first on Dua xe moto.

int score = 10 / 3; // 3
double amount = 7.0 / 2.0; // 3.5
int total = score / score; // 1
score /= 3; // 1

int score = Random.Range(1, 11); // Could be one of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
float time = Random.Range(0f, 1f); // Could be any value between 0 (inclusive) and 1 (inclusive)
float amount = Random.value; // Could be any value between 0 (inclusive) and 1 (inclusive)

bool result = 10 > 3; // true
result = 3 > 10; // false

bool result = 10 < 3; // false
result = 3 < 10; // true

bool result = 10 == 10; // true
result = 10 == 3; // false

bool result = true && true; // true
result = true && false; // false
result = false && true; // false
result = false && false; // false

bool result = true || true; // true
result = true || false; // true
result = false || true; // true
result = false || false; // false

bool test = false; // false
test = !test; // true

string name = "Jon" + " the great!"; // "Jon the great!"
string firstName = "Jon";
string lastName = "Parham";
string fullName = string.Concat(firstName, " ", lastName); // "Jon Parham"
string[] fruits = { "banana", "grape", "strawberry" };
string allFruits = string.Join(", ", fruits); // "banana, grape, strawberry"

string name = "Jon";
string firstLetter = name.Substring(0, 1); // "J"
string secondLetter = name.Substring(1, 1); // "o"
string lastTwoLetters = name.Substring(1, 2); // "on"

string fruit = "apple";
int letterCount = fruit.Length; // 5

string fruit = "apple";
bool test = fruit.Contains("a"); // true
test = fruit.Contains("app"); // true
test = fruit.Contains("b"); // false

int mod = 10 % 3; // 1

float result = Mathf.Round(3.2f); // 3
result = Mathf.Round(3.7f); // 4

float result = Mathf.Abs(-3f); // 3

float result = Mathf.Floor(3.7f); // 3

float result = Mathf.Ceil(3.3f); // 4

float result = Mathf.Sqrt(4f); // 2

float result = Mathf.Sin(4f); // -0.7568025

float result = Mathf.Cos(4f); // -0.6536436

float result = Mathf.Tan(4f); // 1.157821

float result = Mathf.Asin(0.5f); // 0.5235988

float result = Mathf.Acos(0.5f); // 1.047198

float result = Mathf.Atan(0.5f); // 0.4636476

float result = Mathf.Log10(100f); // 2

float e = (float)System.Math.E;
float result = Mathf.Pow(e, 2); // 7.389056

float result = Mathf.Pow(10, 2); // 100

Links
Here are a few links that are relevant to this material and can help you dive a little deeper if you need more help.

Random
Mathf
String
Scratch Wiki for Operators Block

Summary
This should cover all of the code blocks in Scratch’s “Operators” category. If you have any questions about this reference guide feel free to ask below.
If you find value in my blog, you can support its continued development by becoming my patron. Visit my Patreon page here. Thanks!