Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Snow on a menu (vb6)


dao
 Share

Recommended Posts

Over the last couple of weeks i found Alot of cool codes for my game so im going to share one with you.
this is were it snows and you can draw and stuff its pretty cool. ok so here we go
make a new mod and name it Snow_module
and put this inside of it

> '=======================================
> ' The year 2020
> '=======================================
>
> Option Explicit
>
> Type xParticle
>     X As Integer
>     Y As Integer
>     oldX As Integer
>     oldY As Integer
>     iStopped As Integer
> End Type
>
> Global Const MAXP = 400
>
> Global Const PSIZE = 1
>
> Global Snow(0 To MAXP) As xParticle

then make a new form and name it frmmain
double click it and put this code in it

> Private Sub Form_Load()
>    
>     Randomize
>    
>     Me.ScaleMode = vbPixels
>     Me.DrawWidth = PSIZE
>     Me.BackColor = vbBlack
>    
>    
>     Dim i As Integer
>    
>     ' The RND formula!
>     ' Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
>
>     For i = 0 To MAXP
>         Snow(i).X = CInt(Int(Me.ScaleWidth * Rnd))
>         Snow(i).Y = CInt(Int(Me.ScaleHeight * Rnd))
>     Next i
>    
>     bRUN = True
>     Timer1.Enabled = True
>
>     ' Center and draw the text:
>     Const sTEXT = "T H E  Y E A R  2 0 2 0"
>     Me.ForeColor = vbRed
>     Me.CurrentX = Me.ScaleWidth / 2 - TextWidth(sTEXT) / 2
>     Me.CurrentY = Me.ScaleHeight / 2 - TextHeight(sTEXT) / 2 - 5
>     Me.Print sTEXT
>
>     Const sTEXT2 = ""
>     Me.CurrentX = Me.ScaleWidth / 2 - TextWidth(sTEXT2) / 2
>     Me.CurrentY = Me.ScaleHeight / 2 + TextHeight(sTEXT2) + 2
>     Me.Print sTEXT2
>    
>     Me.ForeColor = vbWhite
>    
> End Sub
>
> Sub DrawSnow()
>     Dim i As Integer
>    
>     Dim NewX As Integer
>     Dim NewY As Integer
>    
>     Timer1.Enabled = False
>    
> Do While bRUN
>    
>     For i = 0 To MAXP
>       Me.PSet (Snow(i).oldX, Snow(i).oldY), vbBlack
>       Me.PSet (Snow(i).X, Snow(i).Y)
>     Next i
>    
>     For i = 0 To MAXP
>       Snow(i).oldX = Snow(i).X
>       Snow(i).oldY = Snow(i).Y
>            
>       ' A trick to get both positive and negative random values:
>       NewX = Snow(i).X + Int(2 * Rnd)
>       NewX = NewX - Int(2 * Rnd)
>      
>       ' Don't alow our snow to run away:
>       If NewX < 0 Then NewX = 0
>       If NewX >= Me.ScaleWidth Then NewX = Me.ScaleWidth - 1
>      
>       NewY = Snow(i).Y + 1
>      
>       If Me.Point(NewX, NewY) = vbBlack Then
>             Snow(i).Y = NewY
>             Snow(i).X = NewX
>       Else
>             If Snow(i).iStopped = 10 Then ' if stopped 10 times, make new!
>                
>                 ' Move according to basic SNOW RULE:
>                 If Me.Point(Snow(i).X + 1, Snow(i).Y + 1) = vbBlack Then
>                   Snow(i).X = Snow(i).X + 1
>                   Snow(i).Y = Snow(i).Y + 1
>                   Snow(i).iStopped = 0
>                 ElseIf Me.Point(Snow(i).X - 1, Snow(i).Y + 1) = vbBlack Then
>                   Snow(i).X = Snow(i).X - 1
>                   Snow(i).Y = Snow(i).Y + 1
>                   Snow(i).iStopped = 0
>                 Else
>                   newParticle (i)
>                 End If
>                
>             Else
>                 Snow(i).iStopped = Snow(i).iStopped + 1
>             End If
>       End If
>              
>       If (Snow(i).Y) >= Me.ScaleHeight Then
>               newParticle (i)
>       End If
>      
>     Next i
>    
>     DoEvents
> Loop
>    
> End Sub
>
> Sub newParticle(i As Integer)
>     Snow(i).X = CInt(Int(Me.ScaleWidth * Rnd))
>     Snow(i).Y = 0
>     Snow(i).oldX = 0
>     Snow(i).oldY = 0
>     Snow(i).iStopped = 0
> End Sub
>
> Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
>     Me.PSet (X, Y)
>     bMOUSE_DOWN = True
>     fMouseDown_X = X
>     fMouseDown_Y = Y
> End Sub
>
> Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
>     If bMOUSE_DOWN Then
>         Dim oldDW As Long
>         Dim oldFC As Long
>         oldDW = Me.DrawWidth
>         oldFC = Me.ForeColor
>         Me.DrawWidth = 3
>         Me.ForeColor = vbWhite
>         Me.Line (fMouseDown_X, fMouseDown_Y)-(X, Y)
>         fMouseDown_X = X
>         fMouseDown_Y = Y
>         Me.DrawWidth = oldDW
>         Me.ForeColor = oldFC
>     End If
> End Sub
>
> Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
>     bMOUSE_DOWN = False
> End Sub
>
> Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
>     bRUN = False
> End Sub
>
> Private Sub Timer1_Timer()
>     DrawSnow
> End Sub

Change this to whatever you want
Change this to the color you want when you draw

then add a timer called timer1
it should look like this
![](http://www.freemmorpgmaker.com/files/imagehost/pics/89f2e8a564e82862a9f2dbbb8e1788f4.png)

then add a command button where you want to open it and put this code inside

> frmMain.Visible = True
> Me.Visible = True

This is what it looks like when your done
![](http://www.freemmorpgmaker.com/files/imagehost/pics/552884986feb5e30f1624ea51200e50f.png)
Link to comment
Share on other sites

wait where did you learn this from cause you have made one of the most awsumest fetchers ever, you can have a real fire
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...