VB: Making snowy stunts

zhaozj2021-02-16  61

For snowy sights, everyone may be unfamiliar, we still use VB to make a snowy sight. In fact, it is not complicated. It is the first to draw many white points (snowflakes) on the screen of the color, and then move these snowflakes down (redraw), repeated Cycling, successfully simulating snowy sights. Below is this applet, you can modify some of these data to adjust the density of the snow and the snowflakes fall.

Double click on the form to write the following code:

DIM SNOW (1000, 2), Amounty As Integer

Private sub flow_load ()

FORM1.SHOW

Doevents

Randomize

Amounty = 325

For j = 1 to Amounty

Snow (j, 0) = int (rND * form1.width)

Snow (j, 1) = int (rND * form1.height)

Snow (j, 2) = 10 (RND * 20)

NEXT J

Do While Not (Doevents = 0)

For ls = 1 to 10

For i = 1 to Amounty

Oldx = SNOW (i, 0): Oldy = SNOW (i, 1)

Snow (i, 1) = SNOW (i, 1) SNOW (i, 2)

IF SNOW (i, 1)> form1.height then

Snow (i, 1) = 0: SNOW (i, 2) = 5 (RND * 30)

Snow (i, 0) = int (rND * form1.width)

Oldx = 0: Oldy = 0

END IF

Coloury = 8 * (Snow (i, 2) - 10): Colour = 60 coloury

Pset (Oldx, Oldy), qbcolor (0)

Pset (Snow (i, 0), Snow (I, 1)), RGB (Colour, Colour, Colour)

Next i

Next LS

Loop

End

End Sub

Write the form of the mouse to press the code:

Private Sub Form_MouseDown (Button As Integer, Shift As Integer, x as single, y as single)

Unload me

End Sub

If you run the above applet, you can see the snowy snow, there will be snow on the ground! The mouse click to end the program.

Related resources: VB snowflake code VB snowflake code VB snowflake code

转载请注明原文地址:https://www.9cbs.com/read-17140.html

New Post(0)