C++, CLR: 15 Puzzle Game

I'm currently working on a game but with the alphabet (15) that includes no pictures. I'm not sure where to go from there. How to move the button selected by the user to the empty space? It must be adjacent to the empty slot. I've searched a lot on how to, but it's all on C#. They use an EmptyPoint or Location. So far I've used random_shuffle in arrays. Below is just a segment of it. Any help will be much appreciated, thanks!

#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>

using namespace std;

#pragma once

namespace Example {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

public ref class My_Example : public System::Windows::Forms::Form
{
public:
My_Example(void)
{
InitializeComponent();
}

void shuffle_tiles()
{ int position[16]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
String ^letter="ABCDEFGHIJKLMNOP";

random_shuffle(&position[0],&position[16]);

this->button1->Text = System::Convert::ToString(letter[position[0]]);
this->button2->Text = System::Convert::ToString(letter[position[1]]);
this->button3->Text = System::Convert::ToString(letter[position[2]]);
this->button4->Text = System::Convert::ToString(letter[position[3]]);
this->button6->Text = System::Convert::ToString(letter[position[4]]);
this->button7->Text = System::Convert::ToString(letter[position[5]]);
this->button8->Text = System::Convert::ToString(letter[position[6]]);
this->button9->Text = System::Convert::ToString(letter[position[7]]);
this->button10->Text = System::Convert::ToString(letter[position[8]]);
this->button11->Text = System::Convert::ToString(letter[position[9]]);
this->button12->Text = System::Convert::ToString(letter[position[10]]);
this->button13->Text = System::Convert::ToString(letter[position[11]]);
this->button14->Text = System::Convert::ToString(letter[position[12]]);
this->button15->Text = System::Convert::ToString(letter[position[13]]);
this->button16->Text = System::Convert::ToString(letter[position[14]]);
this->button17->Text = System::Convert::ToString(letter[position[15]]);

}
#pragma endregion
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {
shuffle_tiles();
}
}
Topic archived. No new replies allowed.