Visual Basic - Lluvia de letras. ¿Cómo lo harían?

Life is soft - evento anual de software empresarial
 
Vista:

Lluvia de letras. ¿Cómo lo harían?

Publicado por Oliver (1 intervención) el 20/08/2020 04:46:52
Hola, quería hacer un juego para aprender mecanografía y uno de los niveles consiste en una lluvia de letras. Necesito que cuando el usuario presione la letra que está cayendo, verifique si es correcta y si es así sume un punto a la variable "puntos" y cree una nueva label que la reemplace. Sino, que reste una a las oportunidades restantes (tiene 3).
Este es el código que utilicé para que las letras caigan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Public Class Leccion1
    Dim z As Integer
    Dim letras() As Label
    Dim alfabeto() As String
    Dim posy As Integer
    Dim Index As Integer
 
    Private Sub crearLabel(posicion As Integer, Nombre As String, Texto As String, x As Integer, y As Integer)
        letras(posicion) = New Label
        letras(posicion).Name = Nombre
        letras(posicion).Text = Texto
        letras(posicion).Height = 29
        letras(posicion).Width = 27
        letras(posicion).Location = New Point(x, y)
        letras(posicion).BackColor = Color.White
        letras(posicion).ForeColor = Color.Black
        letras(posicion).Font = New Font("Calibri", 18, FontStyle.Regular, GraphicsUnit.Pixel)
        Me.PictureBox1.Controls.Add(letras(posicion))
    End Sub
    Private Sub Leccion1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim posx As Integer
        Dim posy As Integer
        Dim Random As New Random()
        Dim numero As Integer = 0
        Dim total As Integer = 9
 
        Timer1.Interval = 200
        posx = 10
        posy = 10
        alfabeto = {"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"}
 
        ReDim letras(total)
 
        For ii = 0 To total
            numero = Random.Next(0, 9)
            crearLabel(ii, alfabeto(numero) + ii.ToString, alfabeto(numero), posx, posy)
            posx += 30
        Next
    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If Index = letras.Count Then
            Timer1.Stop()
        Else
            posy += 10
            letras(Index).Location = New Point(letras(Index).Location.X, letras(Index).Location.Y + posy + 5)
 
            If posy = 50 Then
                Index += 1
                posy = 0
            End If
        End If
    End Sub
    Private Sub ButtonStart_Click(sender As Object, e As EventArgs) Handles ButtonStart.Click
        Index = 0
        posy = 0
 
        For ii = 0 To letras.Count - 1
            letras(ii).Location = New Point(letras(ii).Location.X, 10)
        Next
 
 
        Timer1.Start()
    End Sub
Su apoyo me serviría mucho, gracias!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder