Está en la página 1de 3

1.

2.

Cree una forma con los controles que se detallan en la siguiente figura :

Asigne las propiedades correspondientes a cada control :


ListBox1 :
Items = ( 'Perro' , 'Cuchara', 'Helado', 'Cedula', 'Cartera', 'Telefono' )
Visible = False
Button1:
Caption = 'Nuevo Juego'
Button2:
Caption = 'Probar'

3.

Defina las variables globales y asigne los eventos Click a los dos botones, as :

var

palabra,
prueba
fallos

: String;
: Integer;

procedure TForm1.Button1Click(Sender: TObject);


var
i : integer;
begin
palabra := ListBox1.Items[random(ListBox1.Items.Count)];
palabra := uppercase(palabra);
prueba := '';
for i := 1 to length(palabra) do
prueba := prueba + '-';
label1.caption := prueba;

fallos := 0;
image2.Left := image1.left + 136;
image2.top := image1.top + 80;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
letra
: char;
i
: integer;
acierto : Boolean;
begin
letra := upcase(edit1.text[1]);
edit1.text := '';
acierto := false;
for i := 1 to length(palabra) do
if palabra[i] = letra then
begin
prueba[i] := letra;
acierto := True;
end;
label1.caption := prueba;
if Palabra = Prueba then
begin
label1.caption := 'Salvado !';
image2.Left := image1.left + 64;
image2.top := image1.top + 120;
end;
if not acierto then
begin
fallos := fallos + 1;
if fallos = 6 then
begin
label1.caption := 'Ahorcado !';
image2.Left := image1.left + 16;
image2.top := image1.top + 56;
end
else begin
image2.Left := image2.left - 15;
image2.top := image2.top - 15;
end;
end;
end;

También podría gustarte