Questo sito utilizza cookies, anche di terze parti, per mostrare pubblicità e servizi in linea con il tuo account. Leggi l'informativa sui cookies.
Username: Password: oppure
Slot machine 1.0 - Frmslot.frm

Frmslot.frm

Caricato da: Albertking82
Scarica il programma completo

  1. '***************************************************************************
  2. '*   Copyright (C) 2007 by Veronese Alberto - Albertking82                 *
  3. '*                                                                         *
  4. '*                                                                         *
  5. '*   This program is free software; you can redistribute it and/or modify  *
  6. '*   it under the terms of the GNU General Public License as published by  *
  7. '*   the Free Software Foundation; either version 2 of the License, or     *
  8. '*   (at your option) any later version.                                   *
  9. '*                                                                         *
  10. '*   This program is distributed in the hope that it will be useful,       *
  11. '*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  12. '*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  13. '*   GNU General Public License for more details.                          *
  14. '*                                                                         *
  15. '*   You should have received a copy of the GNU General Public License     *
  16. '*   along with this program; if not, write to the                         *
  17. '*   Free Software Foundation, Inc.,                                       *
  18. '*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  19. '***************************************************************************
  20.  
  21. Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
  22. Const SND_SYNC = &H0
  23. Const SND_ASYNC = &H1
  24. Const p = 5
  25. Const velocita = 20
  26. Const vel = 100
  27. Public credito As Long
  28. Public puntata As Long
  29. Dim num As Integer
  30. Public alt As Integer
  31. Dim v(0 To 2) As Integer
  32. Dim n(0 To 2) As Integer
  33. Public path As String
  34. Public val As Integer
  35. Public i As Integer, col As Integer, j As Integer
  36.  
  37. Public Sub soldi(cr As Long, pu As Long, v As Integer)
  38.  
  39.    Dim p As String
  40.       p = App.path & "\" & "slot"
  41.      
  42.       Select Case v
  43.        Case 2
  44.         credito = 2 * pu + cr
  45.         lblwin.Caption = "Hai vinto " & puntata * 2 & " $"
  46.        Case 3
  47.         credito = 3 * pu + cr
  48.         lblwin.Caption = "Hai vinto " & puntata * 3 & " $"
  49.       End Select
  50.      
  51.       lblcredito.Caption = credito & " $"
  52.       lblwin.Visible = True
  53.       puntata = 0
  54.       lblpunt.Caption = "0 $"
  55.       Call PlaySound(p & "\" & "win.wav", 0, SND_SYNC)
  56.      
  57. End Sub
  58. Public Sub win(n As Integer, c As Long, p As Long)
  59.  
  60.  If n = 3 Then
  61.  
  62.     cmdpiu.Enabled = True
  63.     cmdmeno.Enabled = True
  64.     cmdall.Enabled = True
  65.     alt = 0
  66.     cmdstop1.Enabled = False
  67.     cmdstop2.Enabled = False
  68.     cmdstop3.Enabled = False
  69.  
  70.    
  71.    If v(0) = 1 And v(1) = 1 And v(2) = 1 Then
  72.       Call soldi(c, p, 3)
  73.       Exit Sub
  74.    End If
  75.    
  76.    If v(0) = 2 And v(1) = 2 And v(2) = 2 Then
  77.       Call soldi(c, p, 3)
  78.       Exit Sub
  79.    End If
  80.    
  81.    If v(0) = 3 And v(1) = 3 And v(2) = 3 Then
  82.       Call soldi(c, p, 3)
  83.       Exit Sub
  84.    End If
  85.    
  86.     If v(0) = 2 And v(1) = 2 Then
  87.        Call soldi(c, p, 2)
  88.        Exit Sub
  89.    End If
  90.    
  91.    puntata = 0
  92.    lblpunt.Caption = "0 $"
  93.    
  94.  End If
  95.  
  96. End Sub
  97. Public Sub rand(i As Integer)
  98.  
  99.  Dim random As String
  100.  
  101.  
  102.  
  103.  Randomize
  104.  
  105.   num = Int(Rnd * 3) + 1
  106.  
  107.     Select Case num
  108.    
  109.       Case 1
  110.        random = path & "\" & "mela.jpg"
  111.        slot(i).Picture = LoadPicture(random)
  112.        v(i) = 1
  113.        Exit Sub
  114.       Case 2
  115.        random = path & "\" & "ciliegia.jpg"
  116.        slot(i).Picture = LoadPicture(random)
  117.        v(i) = 2
  118.        Exit Sub
  119.       Case 3
  120.        random = path & "\" & "banana.jpg"
  121.        slot(i).Picture = LoadPicture(random)
  122.        v(i) = 3
  123.        Exit Sub
  124.     End Select
  125.  
  126. End Sub
  127.  
  128. Private Sub cmdall_Click()
  129.  
  130.  If credito <> 0 Then
  131.      puntata = credito
  132.      credito = 0
  133.      lblpunt.Caption = puntata & " $"
  134.      lblcredito.Caption = credito & " $"
  135.      cmdspin.Enabled = True
  136.      Call PlaySound(path & "/" & "vittoria.wav", 0, SND_ASYNC)
  137.  End If
  138.  
  139. End Sub
  140.  
  141. Private Sub cmdmeno_Click()
  142.  
  143.  If puntata > 0 Then
  144.     puntata = puntata - p
  145.      credito = credito + 5
  146.     lblpunt.Caption = puntata & " $"
  147.     lblcredito.Caption = credito & " $"
  148.     Call PlaySound(path & "/" & "puntata.wav", 0, SND_ASYNC)
  149.  End If
  150.  
  151.  If puntata = 0 Then
  152.   cmdspin.Enabled = False
  153.   cmdall.Enabled = True
  154.  End If
  155.  
  156. End Sub
  157.  
  158. Private Sub cmdpiu_Click()
  159.  
  160.  If credito > 0 Then
  161.     puntata = puntata + 5
  162.     credito = credito - 5
  163.     lblpunt.Caption = puntata & " $"
  164.     lblcredito.Caption = credito & " $"
  165.     cmdspin.Enabled = True
  166.     Call PlaySound(path & "/" & "puntata.wav", 0, SND_ASYNC)
  167.     cmdall.Enabled = False
  168.    
  169.  End If
  170.  
  171. End Sub
  172.  
  173. Private Sub cmdspin_Click()
  174.  
  175. If puntata > 0 Then
  176.  
  177.  Timer1.Enabled = True
  178.  Timer2.Enabled = True
  179.  Timer3.Enabled = True
  180. End If
  181.  
  182.  lblwin.Visible = False
  183.  cmdpiu.Enabled = False
  184.  cmdmeno.Enabled = False
  185.  cmdall.Enabled = False
  186.  cmdspin.Enabled = False
  187.  cmdstop1.Enabled = True
  188.  cmdstop2.Enabled = True
  189.  cmdstop3.Enabled = True
  190.  Call PlaySound(path & "/" & "gioca.wav", 0, SND_ASYNC)
  191.  
  192. End Sub
  193.  
  194.  
  195.  
  196. Private Sub cmdstop1_Click()
  197.  
  198. cmdstop1.Enabled = False
  199. Timer1.Enabled = False
  200. alt = alt + 1
  201.  
  202.  If alt = 3 Then
  203.     Call win(alt, credito, puntata)
  204.  End If
  205.  
  206. Call PlaySound(path & "/" & "stop.wav", 0, SND_ASYNC)
  207.  
  208. End Sub
  209.  
  210. Private Sub cmdstop2_Click()
  211.  
  212.  cmdstop2.Enabled = False
  213.  Timer2.Enabled = False
  214.  alt = alt + 1
  215.  
  216.  If alt = 3 Then
  217.     Call win(alt, credito, puntata)
  218.  End If
  219.  
  220.  Call PlaySound(path & "/" & "stop.wav", 0, SND_ASYNC)
  221.  
  222. End Sub
  223.  
  224. Private Sub cmdstop3_Click()
  225.  
  226.  cmdstop3.Enabled = False
  227.  Timer3.Enabled = False
  228.  alt = alt + 1
  229.  
  230.  If alt = 3 Then
  231.     Call win(alt, credito, puntata)
  232.  End If
  233.  
  234.  Call PlaySound(path & "/" & "stop.wav", 0, SND_ASYNC)
  235.  
  236. End Sub
  237.  
  238. Private Sub Form_Load()
  239.  path = App.path & "\" & "slot"
  240.  credito = 1000
  241.  puntata = 0
  242.  Timer1.Interval = velocita
  243.  Timer2.Interval = velocita
  244.  Timer3.Interval = velocita
  245.  Timer4.Interval = vel
  246.  Timer1.Enabled = False
  247.  Timer2.Enabled = False
  248.  Timer3.Enabled = False
  249.  cmdpiu.Enabled = True
  250.  cmdmeno.Enabled = True
  251.  cmdall.Enabled = True
  252.  cmdstop1.Enabled = False
  253.  cmdstop2.Enabled = False
  254.  cmdstop3.Enabled = False
  255.   For i = 1 To 12
  256.   lbls(0).Caption = lbls(0).Caption & Mid(Frmslot.Caption, i, 1) & vbCrLf
  257.   Next i
  258.   lbls(1).Caption = lbls(0).Caption
  259.  lblcredito.Caption = "1000 $"
  260.  lblpunt.Caption = "0 $"
  261.  Call PlaySound(path & "/" & "init.wav", 0, SND_ASYNC)
  262.  
  263. End Sub
  264.  
  265. Private Sub Form_Unload(Cancel As Integer)
  266. MsgBox "Programma realizzato da Veronese Alberto alias Albertking82", vbInformation, "Creatore"
  267. End Sub
  268.  
  269. Private Sub mnuesc_Click()
  270.  MsgBox "Programma realizzato da Veronese Alberto alias Albertking82", vbInformation, "Creatore"
  271.  Unload Me
  272. End Sub
  273.  
  274. Private Sub mnunew_Click()
  275.  Call Form_Load
  276. End Sub
  277.  
  278. Private Sub Timer1_Timer()
  279. Call rand(0)
  280. End Sub
  281.  
  282. Private Sub Timer2_Timer()
  283. Call rand(1)
  284. End Sub
  285.  
  286. Private Sub Timer3_Timer()
  287. Call rand(2)
  288. End Sub
  289.  
  290. Private Sub Timer4_Timer()
  291.  
  292.  Randomize
  293.  
  294.  For j = 0 To 13
  295.    col = Int(Rnd * 13) + 1
  296.    lbld(j).BackColor = QBColor(col)
  297.    lbls(0).ForeColor = QBColor(col)
  298.    lbls(1).ForeColor = QBColor(col)
  299.  Next j
  300.  j = 200
  301.  lblme.ForeColor = QBColor(col)
  302.  If lblme.Left > Frmslot.Width Then
  303.     lblme.Left = 0
  304.   Else
  305.     lblme.Left = lblme.Left + j
  306.   End If
  307.  
  308. End Sub