Jumat, 05 Januari 2018

Basic Scripting Unity C# - Part 1 Debugging


Hello guys welcome to my first tutorial in Unity Game Engine using C# for scripting. Basic Scripting Unity C# - Part 1 Debugging.
There is list that what i will do:
  • Getting know the modifier (common programming language)
  • Declaring (Creating) variables of types,
  • Initializing (instantiate, assign or whatever you called) a value,
  • Log Debugging (printing the value of variables).
I will share what i know. I just make it into my words so if there is a miss a thing about the code or  what i say. You can just comment in below with a respectful. We should respect each other. Okay, back to the topic.

1.      Getting know the modifier
Figure 1. Access Modifiers by Dotnetbull
1.      Declaring variables of types
There are many types in any language included C#. I just give some types which is primitive.
    private char character;
    private string characters;
    private int integer;
    private float floatSingle;
    private double floatDouble;
There are some types. Which are char, string, int, float, double.
2.      Initializing a value
So in Unity there are many methods that have been created by Unity itself which are
    void Start ();
    void Update ();
    void OnDestroy ();
    void OnTriggerEnter ();
    void OnTriggerStay ();
    void OnTriggerExit ();

There are still many of them.
So there is 2 way to initialize the variables

2.     Declaring and Initializing
It means that you declare it and initialize it directly.
//Declare & Initialize
   private char character = 'C';
   private string characters "Coretan Kas";

   private int integer = 20;

   private float floatSingle
11.071997f;
   private double floatDouble = 11.07199705012018d;

3.     Declaring and Initializing

It means that you declare it then initialize it undirectly. You just initialize it in methods. Suppose you declare it in world space of program, and declare it inside of start method.
//Declare
    private char character = 'C';
    private string characters "Coretan Kas";

    private int integer = 20;

    private float floatSingle
11.071997f;
    private double floatDouble = 11.07199705012018d;

    private void Start () {
//Initialize
        character = 'C';
        characters = "Coretan Kas";
        integer = 20;
        floatSingle = 11.071997f;
        floatDouble = 11.07199705012018d;
    }
With these methods of initializing a value of variables you can adjust it with your needs. Not every type can be write in Declaring & Initializing, there are not primitive types like GameObject, Transform will be discussed in next tutorials.

4.     Log Debugging
Sometimes you need to debug your program to know is your code works or not. If you want to know the output you can write a Debug.Log then you can called which variables you want to know the value itself.
//Declare
    private char character = ‘C’;
    private string characters “Coretan Kas”;

    private int integer = 20;

    private float floatSingle
11.071997f;
    private double floatDouble = = 11.07199705012018d;
    private void Start () {
//Initialize
        character = ‘C’;
        characters = “Coretan Kas”;
        integer = 20;
        floatSingle = 11.071997f;
        floatDouble = 11.07199705012018d;

//Debugging – Log
        Debug.Log (“character: “ + character);
        Debug.Log (“characters: “ + characters);
        Debug.Log (“integer: “ + integer);
        Debug.Log (“floatSingle: “ + floatSingle);
        Debug.Log (“floatDouble: “ + floatDouble);

    }
Here is the output of the program

Figure 2. Output Program
Share:

Rabu, 03 Januari 2018

Matrix Thinker Opengl 2 Game

// Ilagaray-Matrix.cpp : Defines the entry point for the console application.
//Builded in Visual Studio 2017
//Game Name: Matrix Thinker
//Created in 03/1/2018 by Kas Raygaputra Ilaga
/*Description: This game was made to make people played it think wider and use his/her eyes to see all possibility to gain the conditions for winning the game, inspired from how i play UNO playing card. in 30/12/2017, i played UNO and i just think how to win but with more challenge, so i don't sort the cards to its couple, i just handle it wider so i can see all the card i have. so every single step i take i should be focus to my card pattern. It was made me think wider. The result is i never lose a single game in the game that night.. seriously haha XD. this flow of thinking is good to challenge yourself and let your mind think with high effort. The result is it helped me when i'm coding the programs, how the programs will works with the conditions i made. It's all not about the programs or just a game!. With this kind of thinking, you can solve the problem in your life easier, because there are many conditions that you can find out in your minds. There is no one stupid, there is just a lazy person to think*/

//World position full screen in my notebook fhd(1920 * 1080) ver.(MSI GL62M 7REX), i guess it's not supported in all resolution screens.
//Basic code (gl) is belong to Mr.Hanny Haryanto
//Advanced code belong to me
//Feel free to email me at kas.rayga2012@gmail.com
//Feel pleasure to welcome you at Coretankas.blogspot.com

Figure 1. Menu Scene

Figure 2. Play Scene

Figure 3. Win Scene

Download the game
 Download

Share: