Exciting announcements from Mammoth Interactive.

We’re excited to announce our newest courses. Get each for only 19 dollars with these special offers.

Do you want to learn to build beautiful, well-functioning web apps? Join web developer Chris Veillette in this course for beginners to start building web apps today.

Introduction to React and Redux is full of practical examples. We teach you theory while also building real projects that you can put in your web development portfolio. Enroll today to join the Mammoth community.

Introduction to React and Redux. Code Web Apps in JavaScript. 96% off

If you want to learn to code for the web, Beginner’s ES6 Programming is the place to start. Begin your career or hobby in web development today by enrolling in this course.

In Beginner’s ES6 Programming, you will learn the fundamentals of coding in JavaScript, including ES6. You will learn how to change what is displayed on a webpage using JavaScript.

No prior experience in JavaScript is required. 

Beginner’s ES6 Programming. Code for the Web in JavaScript. 96% off

In Beginner’s Guide to Elm Programming, web developer Chris Veillette will teach you how to code in the Elm language to build real websites and apps.

Elm is a programming language that you can use to build web apps. Elm is user-friendly, which makes it a great place to learn to build web apps.

Beginner’s Guide to Elm Programming. Build Web Apps! 96% off

In Mastering Core Image, you learn how to add unique features to the images in your apps. A CIImage is a representation of an image that can be altered with Core Image filters. These filters allow users to change and interact with images in cool and useful ways.

Mastering Core Image: XCode’s Image Recognition and Processing Framework. 96% off

Want to make apps and learn to code? With The Ultimate iOS 11 Course, you too can design and code practical apps from scratch. Expert programmers John Bura, Nimish Narang, and Chris Veillette from Mammoth Interactive will teach you everything you need to know to whet your palette in iOS 11.

The Ultimate iOS 11 Course. Learn to Build Apps! 96% off

Best of Reddit’s Inconvenient Volume Controllers

It all began one week ago, with a seemingly harmless post by PM_ME_YOUR_WATERMELO on Reddit. The question, “Who can make the best volume slider?” became the challenge that readers of the ProgrammerHumor subreddit took on. Let’s take a look at the best of the best.

Hope it isn’t too big of an inconvenience by TheDistantIsles:

Volumes should be unique by NeverMakesMistkes:

Don’t reach your daily limit by jetstream96r:

GPS Volume Control by mrzacharyjensen:

Volume in digits of Pi by renixreborn:

A new coloring book by Agne240:

View post on imgur.com

Resize your window by GiftOfDeath:

Very strict and precise volume slider by Zagged:

View post on imgur.com

A simple graphical volume control by mienys:

Keep ’em coming, Reddit! We love it. Read more at www.reddit.com/r/ProgrammerHumor.

Variables in C# | Unity Tutorial

Variables: the building blocks of code. When building a game in Unity, you often need to store information, such as a player’s age or the current time. Variables are perfect for storing data. If you are a beginner and want to learn how to build virtual reality games, check out our Unity3D course

In this tutorial, we will use an example of a cube to show some of the useful things variables can do. We will change the size, name, and rotation of a cube using variables in C#.

To simplify this example, you can delete the following lines from the C# script we created in the last tutorial.

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

Changing Size

Suppose we want to change the size of the cube we created last time. We can create a variable to store a change in size. In Unity, you can see that the default Scale values of Cube are 1 1 1. In the Cube script, you can modify Cube’s Scale values in the Cube class. Type the following bold line of code in the script:

using UnityEngine;
using System.Collections;

public class Cube : MonoBehaviour {

public float sizeModifier = 2.5f;

}

The preceding code declares a variable named sizeModifier. In C#, the naming convention for variables is to capitalize the first letter of every word after the first word.

float means that sizeModifier stores a floating-point number, also known as a float. Floats are numbers that can contain decimal places.

The public keyword means that classes other than Cube can access sizeModifier. As well, using public allows us to modify sizeModifier in the Unity editor.

To declare sizeModifier, we could have just typed public float sizeModifier;. To initialize the variable (store a value in it), we added = 2.5f.

= assigns a value to a variable. The code to the right of the equals sign will be placed in sizeModifier. 2.5f stores the value 2.5 as a float.

Save the script. Open Unity. The sizeModifier variable will be represented as the property “Size Modifier” in the Cube (Script) component. Note that the script must finish compiling before you can see changes.

To change sizeModifier, you do not need to go to the Cube script, change 2.5, and wait for another compilation. Instead, you can change the value of Size Modifier in the Inspector. As such, you can test your values faster.

Renaming

Let’s rename Cube. To store Cube’s name, create another variable in the Cube class.

public class Cube : MonoBehaviour {

public float sizeModifier = 2.5f;
public string newName = "";

}

newName is a variable of type String. A string variable is a collection of characters. The value of a string needs to be enclosed in double quotation marks. Currently, the string is empty. Use the following format to name the cube “Cubey1337”.

public class Cube : MonoBehaviour {

public float sizeModifier = 2.5f;
public string newName = "Cubey1337";

}

Save the script, and open Unity. When the compilation completes, the field “New Name” will appear in the Cube (Script) component. Here you can change the value of newName, for instance, to “Cubey42”.

Changing Rotation

Another type of variable is the Boolean. A Boolean variable can contain one of two values: true or false. Use the following code to create a Boolean variable that determines whether Cube will be rotated.

public class Cube : MonoBehaviour {

public float sizeModifier = 2.5f;
public string newName = "Cubey1337";
public bool isRotated = false;
}

The value of isRotated is initially false, which means the cube will not be rotated. Save the script, and open Unity. The property “Is Rotated” will appear in the Cube (Script) component.

Unlike the Size Modifier and New Name properties, which are text fields, Is Rotated is a checkbox. The checkbox is checked when isRotated is true and unchecked when isRotated is false.

Want to learn more about variables? Check out our Unity3D course, where you build 30 virtual reality games!

Creating a C# Script | Unity Tutorial

Do you want to customize the behavior and appearance of your game objects? You can use script to do just that. This tutorial will be the first of a series in which you will learn how to code a C# script for Unity. If you are a beginner and want to learn how to build virtual reality games, check out our Unity3D course

Setting up the Scene

Create a new project in Unity named “CodeIntroduction”. Create a cube in the Hierarchy. Give Cube the position 0 0 0 so that it is centered in the Scene.

Let’s change Cube’s color. Create a material named “ColorMaterial” in the Assets folder. In the Inspector, change the material’s color to an orange with RGB values 155 153 0.

Drag and drop ColorMaterial from Assets to Cube in the Scene to apply the color to the cube. Set Main Camera’s Z position to -4 so that it is closer to Cube.

Save the Scene as “Game.unity”. A file named “Game” will appear in the Assets folder.

Creating the Script

Every game object in the Hierarchy has components in the Inspector. Unity provides components such as materials, collisions, and 3D primitives. To create a more complex game, you can write custom behavior for an object. To this, you create a script and attach the script as a component of the game object.

In the Project window, let’s make a script for Cube. Right-click in Assets. Select Create > C# Script.

A new file will appear in Assets. Name the file “Cube”.

When you create or update a script, a wheel will spin in the bottom right corner of the Unity window. This wheel spins when a compilation occurs. A compilation takes lines of code and converts it to a format that is easier for your game to process.

When the compilation is complete, the script has been added or updated. Then you can run the game to see the changes the script applies.

Every time you change and save a script, Unity will re-compile the project to ensure that everything is correct. If there is a mistake in your code, such as a missing character or invalid variable name, a message will appear in the Console.

Currently, the Cube script will not execute any code because it is not attached to any object. Let’s attach the script to the Cube game object. Drag and drop the Cube script to the Cube game object in the Hierarchy or Scene. Alternatively, drag and drop the script to a blank space in the Cube object’s Inspector.

A Cube (Script) component will appear in Cube’s Inspector.

Double-click on the Cube script in Assets to open it. The file “Cube.cs” will open in MonoDevelop-Unity, as evident in the next image. MonoDevelop is a free, open-source coding interface that downloads when you download Unity if you do not unselect Unity’s default downloads.

Note that if you prefer to use other tools, such as Visual Studio, Sublime Text, or Notepad++, you can configure Unity to use that text editor by default.

The first line in the script is using UnityEngine;. This line means that the code in the script can use items already implemented in the Unity engine.

using System.Collections; means that the script can use certain parts of the code that are already written in the C# environment for collecting objects.

The other code in the file defines the Cube class. public class Cube defines a public class called Cube. : MonoBehaviour means the class extends MonoBehaviour, which is the base class for a game object. The code we write between the curly braces will change how Cube behaves.

The default methods in the Cube class are Start and Update. The Start method executes code when the game begins. The Update method executes code constantly. Want to learn more about methods? Check out our Unity3D course, where you build 30 virtual reality games! Don’t forget to save your project.

Build watchOS Apps for the Apple Watch | Course Release

Start now.

Do you want to build your own apps for the Apple Watch? Even if you have never coded before, you can build a watchOS app with our brand-new Apple Watch course.

You do not need any prior knowledge to take this course – it is perfect for beginners. The Apple Watch course begins by covering the fundamentals of the Swift programming language. You will learn how to use Xcode to create the layout and functionality of an iOS app.

If you do have experience developing for iOS, the Apple Watch course is your head start in developing for watchOS. You will learn the differences between coding for iOS and watchOS.

To learn how to develop for watchOS, we will create an Apple Watch app of our own in Xcode – from scratch. You will learn how to:

  • Add a basic label to create the layout of your app
  • Add and implement dates and timers
  • Insert switches, sliders, and pickers
  • Create different tables and context menus
  • Insert images and movies into your Apple Watch apps
  • Enable notifications

By the end of the Apple Watch course, you will have a functioning app that you can expand on to add your own ideas. You will be able to test the app like a user would. Let’s go!