Jogo da senha (descubra a senha)
Código para o Visual Basic
Module jogo_da_senhaModule
Dim v1, v2, v3, v4, v5, texto, x1, y1, cor1, cor2, botao1, num1, num2, num3, num4, num5, n1, n2, n3, n4, n5, errou As Primitive
Sub Main()
GraphicsWindow.Width = 250
GraphicsWindow.Height = 100
GraphicsWindow.BackgroundColor = "darkred"
GraphicsWindow.Title = "A senha"
GraphicsWindow.CanResize = 0
'numeros aleatorios
v1 = Microsoft.SmallBasic.Library.Math.GetRandomNumber(9)
v2 = Microsoft.SmallBasic.Library.Math.GetRandomNumber(9)
v3 = Microsoft.SmallBasic.Library.Math.GetRandomNumber(9)
v4 = Microsoft.SmallBasic.Library.Math.GetRandomNumber(9)
v5 = Microsoft.SmallBasic.Library.Math.GetRandomNumber(9)
'txt com borda
texto = "Descubra a senha de 5 numeros"
x1 = 10
y1 = 10
cor1 = "black"
cor2 = "white"
GraphicsWindow.BrushColor = cor1
GraphicsWindow.DrawText(x1 - 1, y1 - 1, texto)
GraphicsWindow.DrawText(x1 - 1, y1 + 1, texto)
GraphicsWindow.DrawText(x1 + 1, y1 - 1, texto)
GraphicsWindow.DrawText(x1 + 1, y1 + 1, texto)
GraphicsWindow.BrushColor = cor2
GraphicsWindow.DrawText(x1, y1, texto)
'jogo
GraphicsWindow.BrushColor = "black"
botao1 = Controls.AddButton(" Entrar ", 170, 42)
num1 = Controls.AddTextBox(10, 40)
Controls.SetSize(num1, 20, 30)
num2 = Controls.AddTextBox(40, 40)
Controls.SetSize(num2, 20, 30)
num3 = Controls.AddTextBox(70, 40)
Controls.SetSize(num3, 20, 30)
num4 = Controls.AddTextBox(100, 40)
Controls.SetSize(num4, 20, 30)
num5 = Controls.AddTextBox(130, 40)
Controls.SetSize(num5, 20, 30)
'controle
AddHandler Controls.ButtonClicked, AddressOf clicou
End Sub
Sub clicou()
If Controls.LastClickedButton = botao1 Then
n1 = Controls.GetTextBoxText(num1)
n2 = Controls.GetTextBoxText(num2)
n3 = Controls.GetTextBoxText(num3)
n4 = Controls.GetTextBoxText(num4)
n5 = Controls.GetTextBoxText(num5)
End If
If (v1 = n1) And (v2 = n2) And (v3 = n3) And (v4 = n4) And (v5 = n5) Then
GraphicsWindow.ShowMessage("Parabéns você acertou a senha", "senha")
errou = 0
Else
errou = 1
End If
If errou = 1 Then
If v1 = n1 Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor1 esta correto", "senha")
Else
GraphicsWindow.ShowMessage("O valor1 esta incorreto", "senha")
End If
If v2 = n2 Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor2 esta correto", "senha")
Else
GraphicsWindow.ShowMessage("O valor2 esta incorreto", "senha")
End If
If v3 = n3 Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor3 esta correto", "senha")
Else
GraphicsWindow.ShowMessage("O valor3 esta incorreto", "senha")
End If
If v4 = n4 Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor4 esta correto", "senha")
Else
GraphicsWindow.ShowMessage("O valor4 esta incorreto", "senha")
End If
If v5 = n5 Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor5 esta correto", "senha")
Else
GraphicsWindow.ShowMessage("O valor5 esta incorreto", "senha")
End If
If (v1 = n1) And (v2 = n2) And (v3 = n3) And (v4 = n4) And (v5 = n5) Then
GraphicsWindow.ShowMessage("Parabéns você acertou a senha", "senha")
End If
End If
End Sub
End Module
Código para o Small Basic
GraphicsWindow.Width = 250
GraphicsWindow.Height = 100
GraphicsWindow.BackgroundColor = "darkred"
GraphicsWindow.Title = "A senha"
GraphicsWindow.CanResize = 0
'numeros aleatorios
v1 = Math.GetRandomNumber(9)
v2 = Math.GetRandomNumber(9)
v3 = Math.GetRandomNumber(9)
v4 = Math.GetRandomNumber(9)
v5 = Math.GetRandomNumber(9)
'txt com borda
texto = "Descubra a senha de 5 numeros"
x1 = 10
y1= 10
cor1 = "black"
cor2 = "white"
GraphicsWindow.BrushColor = cor1
GraphicsWindow.DrawText(x1-1, y1-1, texto)
GraphicsWindow.DrawText(x1-1, y1+1, texto)
GraphicsWindow.DrawText(x1+1, y1-1, texto)
GraphicsWindow.DrawText(x1+1, y1+1, texto)
GraphicsWindow.BrushColor = cor2
GraphicsWindow.DrawText(x1, y1, texto)
'jogo
GraphicsWindow.BrushColor = "black"
botao1 = Controls.AddButton(" Entrar ", 170, 42)
num1 = Controls.AddTextBox(10, 40)
Controls.SetSize(num1, 20, 30)
num2 = Controls.AddTextBox(40, 40)
Controls.SetSize(num2, 20, 30)
num3 = Controls.AddTextBox(70, 40)
Controls.SetSize(num3, 20, 30)
num4 = Controls.AddTextBox(100, 40)
Controls.SetSize(num4, 20, 30)
num5 = Controls.AddTextBox(130, 40)
Controls.SetSize(num5, 20, 30)
'controle
Controls.ButtonClicked = clicou
Sub clicou
If (Controls.LastClickedButton = botao1) Then
n1 = Controls.GetTextBoxText(num1)
n2 = Controls.GetTextBoxText(num2)
n3 = Controls.GetTextBoxText(num3)
n4 = Controls.GetTextBoxText(num4)
n5 = Controls.GetTextBoxText(num5)
EndIf
If ( v1 = n1 And v2 = n2 And v3 = n3 And v4 = n4 And v5 = n5 ) Then
GraphicsWindow.ShowMessage("Parabéns você acertou a senha" ,"senha")
errou = 0
Else
errou = 1
EndIf
If (errou = 1) Then
If ( v1 = n1 ) Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor1 esta correto" ,"senha")
Else
GraphicsWindow.ShowMessage("O valor1 esta incorreto" ,"senha")
EndIf
If ( v2 = n2 ) Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor2 esta correto" ,"senha")
Else
GraphicsWindow.ShowMessage("O valor2 esta incorreto" ,"senha")
EndIf
If ( v3 = n3 ) Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor3 esta correto" ,"senha")
Else
GraphicsWindow.ShowMessage("O valor3 esta incorreto" ,"senha")
EndIf
If ( v4 = n4 ) Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor4 esta correto" ,"senha")
Else
GraphicsWindow.ShowMessage("O valor4 esta incorreto" ,"senha")
EndIf
If ( v5 = n5 ) Then
Sound.PlayChime()
GraphicsWindow.ShowMessage("O valor5 esta correto" ,"senha")
Else
GraphicsWindow.ShowMessage("O valor5 esta incorreto" ,"senha")
EndIf
If ( v1 = n1 And v2 = n2 And v3 = n3 And v4 = n4 And v5 = n5 ) Then
GraphicsWindow.ShowMessage("Parabéns você acertou a senha" ,"senha")
EndIf
EndIf
EndSub
Jogo da senha em Visual Basic open source
Postado por Rogério Kund Natusch Filho
Assinar:
Postar comentários (Atom)
0 comentários:
Postar um comentário