Programming Tips

Showing posts with label Programming Tips. Show all posts
Showing posts with label Programming Tips. Show all posts

A Quick Way To Solve a Problem With Unity Game Programming


A good way to solve unity game programming
Unity Game Design is a platform to design games. It is a very huge platform which is used by many big organisations for game design. Companies such as Disney, Lego, Electronic Arts, Microsoft, NASA, Nickelodeon, Square Enix, Ubisoft, Obsidian, Insomniac, and Warner Bros totally depend on tools and technologies of Unity. It is a complete platform for designing and constructing both 2D and 3D games. But it is specialised in making of 2D games. Unity Game Design makes you to completely bring every single detail in action, develop and optimize the games, engage the audience and achieve success commercially.

The Designing and Development process involved

Unity Game Designer is the best platform for designing and making the figures come to move. In the world of Unity Game Designer, the basic purpose of it is to design the characters and make the animated objects into motion in a 3D environment. The input of the character comes totally from the vector algebra in which we consider X and Y coordinate in which we want to move the character. The animated object is also provided with a force which makes it be standing on the floor while moving. We really need to take care about the coordinates of the objects so as to avoid collisions. But if collisions occur, it would result in a big disaster for the developers. It is really disheartening to know that OverlapSpheres is the only solution to avoid a collision or if it occurs is used to manage the collision. OverlapSpheres deals manually with the problem of collisions.

The different types of colliders provided by Unity Game designer

Unity 5 provides four different types of colliders:

  1. SphereCollider
  2. BoxCollider
  3. CapsuleCollider 
  4. MeshCollider

There are two different methods for correcting collisions:-

  1. Correct the overlapping colliders and force them to be outside each other.
  2. Avoiding collisions at the initial stage.
Among both the methods to correct collisions, It is preferable to correct the overlapping colliders and force them to be outside each other as it will create a different environment and stop them in any way from collisions. It would ensure that the animated object is always outside the collider no problem from where it came from. 

To correct the overlapping problem we first need to find the closest point on the collider and place the object next to it using the Overlap Sphere. The closest point would be found out mathematically in each case.

The additional designs/ Reasons why animation is exciting youngsters:-

There are a lot of additional design features that are added in the Unity Game Design like it has gravity information, it can jump, sliding in slopes, velocity tracker and detection of ground.

Reasons why animation has become exciting for youngsters:-
  1. Animated Advertisements are very exciting.
  2. Animated Advertisements are very enjoyable.
  3. Animated videos are easy to understand.
  4. The animated advertisement is modernized.
  5. The animated advertisements are memorable.

Summary of Unity Game Design:-

Unity Game Design is the best platform for creating beautiful and amazing 2D and 3D designs. In the game of world where creating 3D space in the focus of every game but one who knows how to control a character is the King in today's world. The controller of the character is the heart of the game and is very important for the successful working of the game. It takes very long to think about how to control a character as all of the characters actions are need to be defined.

Author Bio:
Sunny Chawla is a Marketing Manager at AIS Technolabs – a Web design and Development Company. Helping global businesses with unique and engaging tools for their business. He would love to share thoughts on Ecm Services, Web Designing and Unity Game Developer.

PHP Functions - array_merge() and array_combine()


PHP has lots of built-in functions. So that you may not remember all the the functions. Among those functions, array_merge and array_combine are 2 very useful php functions that are very useful for core php programmer.

array_merge() function:

array_merge() is a built-in php function that is used to merge two or more arrays in one place. Unlike array_combine, it does not need equal number of elements in the each array. Here is a simple example of array_merge();

Example
<?php
$data1 = array("id"=>"21","name"=>"RKA","contact"=>"9843XXXXXX");
$data2 = array("address"=>"Kathmandu, Nepal");
$arrayMerge = array_merge($data1,$data2);
print_r($arrayMerge);

?>

Output
Array ( [id] => 21 [name] => RKA [contact] => 9843XXXXXX [address] => Kathmandu, Nepal )


array_combine() function: 


array_combine() is also a built-in php function which is used for combine only 2 arrays. And both the array of parameters must have equal number of elements. In fact, array_combine function combines 2 array together and generates index array.

Example: 
<?php
$data3 = array("1","3","5","7");
$data4 = array("a","c","e","g");
$arrayCombine1 = array_combine($data3,$data4);
print_r($arrayCombine1);
?>

Output:
Array ( [1] => a [3] => c [5] => e [7] => g )

Username availability checking in database using php with jquery ajax method


Username checker in jquery ajax
Jquery ajax database username checker 
Jquery ajax is the best way to check whether the username is available or not. Only using core ajax code is too long and difficult rather than ajax jquery. So use, jquery ajax method for ajax operation. Actually, ajax helps to get or retrieve and post the data from and into the database without reloading the pages.

Lets follow these core coding of jquery ajax which helps you to check the availability of username or any other data.

First of all you need different 3 codes:

  • Database table
  • Simple HTML Form with Jquery Ajax method
  • PHP coding "check_username.php"

Database Table

Create a table name users in database name test using like following codes:
CREATE TABLE users(
id int(11) not null auto_increment
username varchar(255) UNIQUE KEY,
password varchar(255),
PRIMARY KEY (id),
);

Simple HTML Form

<!doctype html>
<html>
<head>
<script src="<ADD JQUERY LIBRARY URL HERE>"></script>
ADD BELOW SCRIPT HERE OR ADD THE URL
</head>
<body>
<form method="post" name="form" action="check_username.php">
username<input type="text" name="username" id="username"/><br/>
<p id="res"></p>password<input type="password" name="password" id="password" />
<input type="submit" value="submit" name="submit" name="submit"/>
</form>
</body>
</html>


JQUERY AJAX SCRIPT

$(document).ready(function(){
      $('#username').keyup(function(){
          var uname = $(this).val();
         
        if(uname.length>5)
          {
              $(#res).html("Processing...");
               $.ajax({
                    type:'post',
                    url:"check_username.php",
                    dataType:'text' ,
                     data:{username:uname}, //key value pairing
                              success:function(value){
                                 $('#res').html(value);
                              }
                  });
           }
       
            else{
                  $('#res').html('<div style="color:red">Needs more than 5 characters</div>');
        }
     });
});

check_username.php PHP file

//create database connection first
$dbConn = new mysqli("localhost","root","password","test");
//check whether the connection is ready or not
if($dbConn->connect_error)
{
      die("Not connected with database, try again");
}
$username = $_POST['username'];
$sqlQuery = "SELECT USERNAME FROM users WHERE username = '$username' ";
$res = $dbConn->query($sqlQuery)
if($res->num_rows>0)
{
       echo "Username Already Taken";
}
else{
       echo "Username Available. Register Now";
}


I hope, the above code will help you to understand basic about .ajax() method of jquery. This is very much easy way to check username availability in database using jquery ajax method and php. 

If you have any difficulties to understand the above code, feel free to ask me. I will do my best to help you. Keep coding, Thank you.

Some unusual demerits of using of frameworks in programming


Using of framework making programmers lazy
Programming Frameworks
I never deny the goodness of use of MVC architecture in programming field. However, I am always against the use of frameworks to bring MVC architecture in your apps. Of course, using of frameworks provide number of advantages while doing coding. It saves the coding time, which also makes easy to build apps. But you have to know some unusual demerits of using of frameworks which completely destroys and makes your apps clumsy. Nowadays, many programmer or html/css designers, they use frameworks for the simplicity in working. But they even do not know a simple core coding of any programming language.

You may think using of framework is better than doing core coding, but I don't think it is good to use framework. Here are some malfunctions of using of frameworks:-

1) Too much unnecessary codes
If you have used either of frameworks like laravel, codeigniter, cakephp (PHP) or spring (Java) or bootstap (HTML/CSS), you can understand how much unnecessary codes, you have to apply for a simple task or apps.

2) You may forget the core coding techniques
When you use frameworks, most of the core coding techniques are not used here, you may forget core coding in that particular programming language. Suppose, you are a php programmer, you uses wordpress framework to build a website or cake php to build a php application, then you must follow their coding syntax ditto. Hence you will be decreasing your creation ability.

3) Slow Application
The another unusual and most important demerits of using of frame is consuming of too much time for loading of application since it uses too much unnecessary codes which also must be loaded first along with your apps codes.

4) More Threats of Hacking
Most programmers use frameworks for easy coding, easy MVC architecture and fast apps development. Therefore it has high threat of attack of hackers because they properly know the coding techniques, flow of your application's codes and also the weakness of your apps. In some cases of use of bootstrap, you can steal the whole website. Because you properly know that the site is using bootstrap. So you do not have to be worry about the css and jquery which are using in that website.

5) Deficiency of programmers creation ability
Using of Frameworks in programming decrease the new creation of programmers. It is one of the most considerable shortcoming of framework use. Programmers mostly waste their time in the following of coding syntax of frameworks. They mostly forget to use their own creation.

Therefore, I only suggest to use frameworks to those programmer who properly know about the use of frameworks. Programming Frameworks are actually for huge projects/application which consume lots of time and money. Frameworks shorten the codes that is why you must use framework if you are doing a project which demands highly core coding.