Video Games Development

CSharp – ArrayList

CSharp – ArrayList

To use ArrayList you need: using System.Collections;


using System;
using System.Collections; // class for ArrayList

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // <type> <name of the list> = new ArrayList()
            ArrayList list = new ArrayList();
            // add an element
            list.Add("Mario");
            list.Add("Luca");
            list.Add("Giovanni");

            // per ogni elemento nella lista
            foreach (string name in list)
                Console.WriteLine(name);

            Console.ReadLine();
        }
    }
}

The result is:
Mario
Luca
Giovanni

Complete Reference: http://msdn.microsoft.com/it-it/library/system.collections.arraylist(v=vs.110).aspx

By |CSharp, Video Games Development|Commenti disabilitati su CSharp – ArrayList

CSharp – Array

CSharp – Array

Array – foreach


using System;
using System.Collections;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // <un array di stringhe> <nome array> = new string[numero elementi nell'array]
            string[] names = new string[2];

            // array[indice] = assegna il valore
            names[0] = "Andrea";
            names[1] = "Mario";

            // visualizza tutti i valori contenuti
            foreach (string s in names)
                Console.WriteLine(s);

            Console.ReadLine();
        }
    }
}

The result is:
Andrea
Mario

Array – for

...
for(int i = 0; i < names.Length; i++)
    Console.WriteLine("Item number " + i + ": " + names[i]);
...

Array – short syntax

...
int[] numbers = new int[5] { 4, 3, 8, 0, 5 };
...
int[] numbers = { 4, 3, 8, 0, 5 };
...

My website: http://www.lucedigitale.com

Reference: http://csharp.net-tutorials.com/basics/arrays/

By |CSharp, Video Games Development|Commenti disabilitati su CSharp – Array

CSharp – Variables and Data Types

CSharp – Variables and Data Types

Data types

You are required to inform the compiler about which data types you wish to use every time you declare a variable.

byte —> 0 .. 255

sbyte —> -128 .. 127

short —> -32,768 .. 32,767

ushort —> 0 .. 65,535

int —> -2,147,483,648 .. 2,147,483,647

uint —> 0 .. 4,294,967,295

long —> -9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807

ulong —> 0 .. 18,446,744,073,709,551,615

float —> -3.402823e38 .. 3.402823e38

double —> -1.79769313486232e308 .. 1.79769313486232e308

decimal —> -79228162514264337593543950335 .. 79228162514264337593543950335

char —> a Unicode character.

string —> a string of Unicode characters.

bool —> true or false.

object —> an object.

Example with strings:


// Working with strings

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // <datatype> <name>
            string firstName = "John";
            string lastName = "Doe";

            Console.WriteLine("Name: " + firstName + " " + lastName);

            Console.WriteLine("Please enter a new first name:");
            // get new value from console 
            firstName = Console.ReadLine();

            Console.WriteLine("New name: " + firstName + " " + lastName);

            Console.ReadLine();
        }
    }
}

Example with math:


// Working with math

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            // integer numbers
            int number1, number2;

            Console.WriteLine("Please enter a number:");
            // It reads a string and converts it into an integer. 
            number1 = int.Parse(Console.ReadLine());

            Console.WriteLine("Thank you. One more:");
            number2 = int.Parse(Console.ReadLine());

            Console.WriteLine("Adding the two numbers: " + (number1 + number2));

            Console.ReadLine();
        }
    }
}

Constants

The constants refer to fixed values that the program may not alter during its execution.

The syntax is:

const <data_type> <constant_name> = value;

Example:


using System;
using System.Collections;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            const double pi = 3.14159; // constant declaration 
            double r;
            Console.WriteLine("Enter Radius: ");
            r = Convert.ToDouble(Console.ReadLine());
            double areaCircle = pi * r * r;
            Console.WriteLine("Radius: {0}, Area: {1}", r, areaCircle);
            Console.ReadLine();
        }
    }
}

By |CSharp, Video Games Development|Commenti disabilitati su CSharp – Variables and Data Types

CSharp – Basic Structure

CSharp – Basic Structure

CSharp or C# is an Object Oriented language and does not offer global variables or functions. Everything is wrapped in classes, even simple types like int and string, which inherits from the System.Object class.
C# could theoretically be compiled to machine code, but in real life, it’s always used in combination with the .NET framework.

Hello World

1. Open Visual Studio> MAIN TOP MENU> File> New Project> Visual C#> Console Application

2. RIGHT COLUMN> Solutions Explorer> click over ‘yourProgram.cs’

3. Write:

// using keyword imports a namespace, and a namespace is a collection of classes.
using System;
using System.Collections.Generic;
using System.Text;

// tutto lo script è contenuto all'interno del namespace con il nome del nostro file
namespace ConsoleApplication1
{
    // we define our class, every line of code that actually does something, is wrapped inside a class.
    class Program
    {
        // Main is the entry-point of our application,  the first piece of code to be executed
        static void Main(string[] args)
        {
            // Console output
            Console.WriteLine("Hello, world!");
            Console.ReadLine();
        }
    }
}

Reference: http://csharp.net-tutorials.com/basics/introduction/

By |CSharp|Commenti disabilitati su CSharp – Basic Structure

Unreal Engine – Class Blueprint

Unreal Engine – Class Blueprint

A Class Blueprint is a Blueprint that can be reused many times in your world.
If you will have more than one or two instances (e.g., a TV set that can be shot or turned on/off), then it probably makes sense to create a Class Blueprint. Inside a Class Blueprint you can store Meshes, Lights and connects their behaviours with visual Scripts.

Create a Class Blueprint

1. Content Browser> click un ‘New’> Blueprint> Choose a Parent Class example: Actor

When your Blueprint is first created, or when you make changes to it in the Blueprint Editor, an asterisk will be added to the Blueprint’s icon in the Content Browser. This indicates that the Blueprint is not saved.

2. Content Browser> ‘Save’ button -> TO SAVE YOUR ASSET

3. Editor> MAIN TOP MENU> File> Save, to save the corrent level -> TO SAVE YOUR LEVEL (level.umap)

OR

1. MAIN TOP TOOL BAR> Blueprints> New Class Blueprint> Choose a Parent Class example: Actor> Give it a name and a folder (usually Blueprints/yourBlueprint)

When your Blueprint is first created, or when you make changes to it in the Blueprint Editor, an asterisk will be added to the Blueprint’s icon in the Content Browser. This indicates that the Blueprint is not saved.

2. Blueprint window> ‘Save’ -> TO SAVE YOUR ASSET

3. Editor> MAIN TOP MENU> File> Save, to save the corrent level -> TO SAVE YOUR LEVEL (level.umap)

Search a Class Blueprint

The best way it is put all your Blueprints inside a Blueprints folder (Content Browser/Game/Blueprints).
To find a Blueprint inside another location go to Content Browser> Game (the top folder)> ON THE RIGHT: Filters and/or Search

Edit a Class Blueprint

1. Content Browser> double click over yourBlueprint, the Class Blueprint Editor will appear.

Defaults mode
Setup of default parameters:
– Rendering
– Replication
– Input
– Actor
– Tags

Components mode
Use the roolout menu ‘Add Components’ to add components as:
– Audio
– Skeletal Mesh
– Static Mesh

– Paper Flipbook
– Paper Sprite
– Paper Tile Map Render

etc…

OR

DRAG AND DROP assets from Content Browser to Components List

Navigate inside the View using Autodesk Maya-style controls:
– LMB to move foward/backward
– ALT + LMB to move up/dowm/left/right
– PRESS MOUSE WHELL to move up/down
– ROTATE MOUSE WHELL to dolly in/out

– RMB to look around
– RMB + WASD to move

– F to frame an object
– Select a Component + ALT + LMB to tumble around selected object
– Select a Component + ALT + RMB to dolly in/out selected object

Component List> RMB> Cut, Copy, Paste, Duplicate, Rename, Add Event (OnComponentHit, OnComponentBeginOverlap etc…)

Graph mode
Here we create all nodes and connects between blocks.

Navigate the window with:
– RMB to drag the view
– ROTATE MOUSE WHELL to zoom in/out
– LMB single click to select single block
– LMB single click + SHIFT to add block to selection
– LMB + DRAG to select multiple blocks

Put your Blueprint assets in scene

Content Browser> DRAG AND DROP items into Editor Viewport

NOTICE: you are not be able to adjust Components of Blueprint inside Editor Viewport, but only inside Class Blueprint Editor

Compile a Class Blueprint

1. Change something in your Blueprint

2. Class Blueprint Editor> TOP LEFT> ‘Compile’ button -> the Editor Window will be updated.

By |Unreal Engine, Video Games Development|Commenti disabilitati su Unreal Engine – Class Blueprint