int i=242,j=8;
Luego dentro de un Evento KeyPress colocamos este codigo
int tecla= e->KeyChar;
if ((tecla==97))
{
//izquierda
i=i-20;
this->pictureBox2->Location = System::Drawing::Point(i, j);
this->x->Text = Convert::ToString(i);
}
if ((tecla==100))
{
//Derecha
i=i+20;
this->x->Text = Convert::ToString(i);
this->pictureBox2->Location = System::Drawing::Point(i, j);
}
if ((tecla==119))
{
//Arriba
j=j-20;
this->y->Text = Convert::ToString(j);
this->pictureBox2->Location = System::Drawing::Point(i, j);
}
if ((tecla==115))
{
//abajo
j=j+20;
this->pictureBox2->Location = System::Drawing::Point(i, j);
int score=500,total;
}
En este caso estamos moviendo un pictureBox Hacia arriba, abajo, derecha e izquierda usando ASDW
No hay comentarios:
Publicar un comentario