indiegamedev

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 – 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

C++ Unions

C++ Unions

Unions allow one portion of memory to be accessed as different data types.

The code below creates a new union type, identified by type_name, in which all its member elements occupy the same physical space in memory. The size of this type is the one of the largest member element.


// Syntax
union type_name {
  member_type1 member_name1;
  member_type2 member_name2;
  member_type3 member_name3;
  .
  .
} object_names;

// The Sample code...
union mytypes_t {
  char c;
  int i;
  float f;
} mytypes;

// ...declares an object (mytypes) with three members
mytypes.c
mytypes.i
mytypes.f	

For italian people: la peculiarità della union è che tutte le sue variabili membro (in questo caso l’intero non segnato intero e l’array di char caratteri) condividono la stessa area di memoria, a partire dallo stesso indirizzo: in altri termini intero e caratteri occupano gli stessi 4 byte in memoria.
Tale proprietà si rivela molto utile, ad esempio, nella gestione dei colori in un ambiente grafico come X11. In un simile contesto, una union come quella del presente esempio consente di accedere “istantaneamente” alle componenti alpha, rossa, verde e blu del colore di un pixel senza ricorrere ad alcuna operazione di “bit masking” o “scorrimento bit”.

By |C++, Video Games Development|Commenti disabilitati su C++ Unions