locked
Ladder and snake game

    Question

  • hi, iam making a ladder and snake game in c# for windows application.

    i have to ask about this game,firstly i want to move an image from one place to another.like when i roll a dice and 4 random number appear on a dice and my piece is placed on 2.when i press a button,my piece should move on 6th position but how can i do this.

    here is a code given below but this what its do,its display a random numer

    private void button1_Click(object sender, RoutedEventArgs e)
            {
                Random num = new Random();
                int Number = num.Next(1, 7);
                BitmapImage Img = new BitmapImage(new Uri("ms-appx:///DiceFaces/" + Number.ToString() + ".png"));
                textBlock1.Text = Number.ToString() + " Number"; 
                image1.Source = Img;
            }

    now how can i move an image on a board.please help me

    thanks in advance


    Rabia (Microsoft Student Partner)

    Tuesday, January 27, 2015 12:26 PM

All replies

  • How are you representing your board? Where do you want to place the image?

    You can place an image in a specific row & column of a Grid or at specific X and Y coordinates of a Canvas. Another possibility is to translate its location with a RenderTransform. Which you use and the specific details will depend on what exactly you're trying to do and what data you have about your board and where the piece should go.

    Tuesday, January 27, 2015 10:31 PM
    Owner
  • Hi,

    I am building a snake and ladder game in c# using visual studio 2013. i have generated random numbers for dice but don't know how to move token on board using xaml.

    i write this code

     private void button1_Click(object sender, RoutedEventArgs e)
            {
                Random num = new Random();
                int dice = num.Next(1, 7);
                BitmapImage Img = new BitmapImage(new Uri("ms-appx:///DiceFaces/" + dice + ".png"));
                textBlock1.Text = dice + " Number";
                image1.Source = Img;

    kindly suggest me the directions for token movement when i have two playere to play this game.


    Rabia (Microsoft Student Partner)

    Wednesday, February 4, 2015 6:56 AM
  • Please don't post the same question multiple times. If you need further help with this then please clarify as I requested previously.

    We cannot provide help if you aren't clear on what you are trying to do and where you are stuck.

    Thursday, February 5, 2015 4:20 AM
    Owner