Saturday, 29 December 2012

UDK - Unreal Development Kit - Create basic terrain and use static meshes

I decided to create a series of tutorials for UDK. In this tutorial I will focus on base terrain creation, adding texture and finally adding static meshes.

Thursday, 27 December 2012

Messing with Unreal Engine 3 and UDK

Some of my latest work on small village. I am currently working on 2d platform game for IOs and I will use this level as a background.

Sunday, 18 November 2012

Render random image in android

Recently I have been working on android app that supposed to display random card image from set of 22 images.  To simplify this tutorial let’s create only 3 images.
Let’s create an array resource that will store reference to our images in resource/drawable  folder.


<?xml version="1.0" encoding="utf-8"?>
    <array name="cardImages">


         To find more visit:  Official android reference

As you can see we have 3 images stored in an array.
Now create new Activity and call it
    public void onCreate(Bundle savedInstanceState) {

       ImageView BackCard = (ImageView) findViewById(;

              BackCard.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {
                                // TODO Auto-generated method stub
                                BackCard.postDelayed(new Runnable() {
                                    public void run() {
                                        // TODO Auto-generated method stub
                                        // Randomly choose card
                                        int randomCard = randomCard();
                                }, 150);


   public int randomCard()
        Resources res = getResources();
        TypedArray cards = res.obtainTypedArray(R.array.cardImages);
        int randomNumber =  (int)(Math.random() * ((2 - 0) + 1));
        int card = cards.getResourceId(randomNumber, randomNumber);
        return card;

Now some explanation. I used postDelayed method, simply saying do something after time elapsed(in our case 150ms). Image backblur will be loaded for 150ms and then our actual card is displayed.

randomCard method returns int value of Image resource as setImageResource expects it.

We want to generate number from 0 to 2 where 0 is first element of our array.

Good explanation of random number generator in Java can be found here :

Monday, 22 October 2012

Random password generator using Ajax in ASP.Net MVC

You can download the project from here : Download MVCPasswordExample 

As title says when user click a button it send ajax request to controller
$.post('@Url.Content("~/Home/GeneratePassword/")' ...
and returns Json with new 8 character password.


public class RegisterModel
        [Display(Name = "User name")]
        public string UserName { get; set; }

        [Display(Name = "Email address")]
        public string Email { get; set; }

        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }


    ViewBag.Title = "Home Page";

@using MVCPasswordExample.Models
@model RegisterModel

    $(document).ready(function () {
        $('#updateprofile').click(function () {


        $('#autogenerate').click(function () {
            $.post('@Url.Content("~/Home/GeneratePassword/")', function (data) {

                $('#password, #confirmpassword').attr("value", data.password);





<table style="margin-top:100px;width:40%">
 <th colspan="3">Change Password</th>

      <td>@Html.LabelFor(m => m.Password)
     <td style="width:20%">
         @Html.TextBox("password", null, new { @class = "search_field", @id = "password", @Value = "" })
      <td><input type="button" id="autogenerate" value="Auto generate" class="submit_button" /></td>
         @Html.LabelFor(m => m.ConfirmPassword)
     <td class="confirm" colspan="2">
          @Html.TextBox("confirmpassword", null, new { @class = "search_field", @id = "confirmpassword" })




        public JsonResult GeneratePassword()
           var pass = Guid.NewGuid().ToString().Substring(0, 8);

            return Json(new { password = pass });


You can download the project from here : Download MVCPasswordExample