怎样用VB制作一个和梦幻星空一样的程序

怎样用VB制作一个和梦幻星空一样的程序,第1张

Dim red As Integer

Dim green As Integer

Dim blue As Integer

Private Sub Form_Click()

End

End Sub

Private Sub Timer1_Timer()

Dim x As Integer

Dim y As Integer

Dim i As Integer

Do Until i = 1000

i = i + 1

x = Rnd * ScaleWidth

y = Rnd * ScaleWidth

PSet (x, y), RGB(red, green, blue)

Loop

End Sub

Private Sub Timer2_Timer()

Form1.Cls

red = 255 * Rnd

green = 255 * Rnd

blue = 255 * Rnd

Timer1.Enabled = True

End Sub

加个Command按钮,加个Timer计时器

Dim n As Integer, x() As Integer, y() As Integer, dx() As Integer

Private Sub Command1_Click()

End

End Sub

Private Sub Form_Load()

n = 36

ReDim x(1 To n), y(1 To n), dx(1 To n)

Command1.Caption = "结束"

Timer1.Interval = 100

Me.BackColor = vbBlack

End Sub

Private Sub Form_Resize()

Randomize

For i = 1 To n

x(i) = Me.ScaleWidth * (0.9 * Rnd)

y(i) = Me.ScaleHeight * (0.9 * Rnd)

dx(i) = 12

Next

End Sub

Private Sub Timer1_Timer()

Static flag As Boolean

Cls

If flag = False Then

For i = 1 To n

CurrentX = x(i)

CurrentY = y(i)

Me.FontSize = dx(i)

Me.ForeColor = vbYellow

Print "★"

Next

End If

flag = Not flag

End Sub

其实说到效果,不过就是运算加绘图庆裂哗

你先要算出流星的运行轨迹,然后在屏幕上画出来就行了

运行轨迹不用太难,算个圆弧就行了,打印就点就行了,想要好看的点,就自己多加点小誉行处源轮理或者用图片就好了


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12392182.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存