我们期的作品展告一段落了,现在才来写总结很是惭愧,没有理由就是因为自己懒惰。经过这次作品代码的编写发现自己差距好大,在这次作品展中也学会了很多 ,我们的作品展定在4月份,本来可以在现场参加的,由于疫情的原因我们只好在线上参加了,在线上参加有利有弊。利就是我们可以进一步的利用互联网,对互联网有更多的接触。弊就是不在现场没有了那种氛围。
通过这次作品展我学到了:
1、要学会管理并且利用好自己的时间,管理并且充分的利用好自己的时间很重要。
2、现在自己很弱小不要怕,只要肯努力、肯付出,站在巨人的肩膀上定会成功。
3、你身边的每一位人都是导师,我们要多听多学多问。
4、团队合作很重要,一个人势单力薄,融入团队就能立于不败,一滴水很快挥发,汇入大海就成波涛澎湃。
丢丢,我来分享一下有趣的代码段吧,这段代码会绽放漂亮的烟花哦
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Private Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (ByRef Destination As Any, ByVal Length As Long)
Private Declare Function SetPixelV Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
Private Declare Function CreatePen Lib "gdi32.dll" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function MoveToEx Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByRef lpPoint As Any) As Long
Private Declare Function LineTo Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub FireworksInit Lib "fireworksAPI.dll" (ByVal w As Long, ByVal h As Long)
Private Declare Sub FireworksCalcNext256 Lib "fireworksAPI.dll" (lpbm As Any)
Private Declare Sub FireworksCalcNext Lib "fireworksAPI.dll" (lpbm As Any)
Private Declare Sub FireworksSetPixel Lib "fireworksAPI.dll" (lpbm As Any, ByVal x As Long, ByVal y As Long, ByVal idxColor As Byte)
Private bmw As Long, bmh As Long, t As Long
Private bm256 As New cDIBSection256
Private bm As New cAlphaDibSection
Private tb(255) As Long
Public nFPSt As Long, pc As Long
Private Type typeParticle
x As Single
y As Single
dX As Single
dy As Single
ox As Long
oy As Long
lf As Long
Used As Long
clr As Long
End Type
Private ps() As typeParticle, pm As Long
Private Const Gravity As Single = 0.1
Private Const PI As Single = 3.14159265
Private Sub Command1_Click()
Form4.Hide
Form3.Show
End Sub
Private Sub Command2_Click()
Form3.Hide
Form4.Show
End Sub
Private Sub Form_Click()
Form3.Hide
Form4.Hide
End Sub
Private Sub Form_Load()
Dim i As Long
Randomize Timer
For i = 0 To 85
tb(i) = i * &H3&
tb(i + 85) = i * &H300& + &HFF&
tb(i + 170) = i * &H30000 + &HFFFF&
Next i
pm = 1000
ReDim ps(1 To pm)
Me.Show
DoEvents
Form2.Show , Me
pResize
DoEvents
pRun
End Sub
Private Sub pResize()
Dim i As Long
bmw = Me.ScaleWidth
bmh = Me.ScaleHeight
FireworksInit bmw, bmh
bm256.Create bmw, bmh
bm.Create bmw, bmh
For i = 0 To 255
bm256.Color(i) = tb(i)
Next i
Form2.Move Me.Left + Me.Width, Me.Top
End Sub
Private Sub Form_Paint()
If Form2.Option1(0).Value Then
bm256.PaintPicture Me.hdc
Else
bm.PaintPicture Me.hdc
End If
End Sub
Private Sub pTimer()
Dim i As Long
'
If (t And &H1F&) = 0 Then
i = AddParticle
With ps(i)
.x = 50 + (bmw - 100) * Rnd
.y = bmh
.ox = .x
.oy = .y
.dX = 2 * Rnd - 1
.dy = -4 - 6 * Rnd
.lf = 10000 + Int(100 * Rnd)
.clr = &H808080 + Int(&H80& * Rnd) + Int(&H8000& * Rnd) + Int(&H800000 * Rnd)
End With
End If
'
If Form2.Option1(0).Value Then
FireworksCalcNext256 ByVal bm256.DIBSectionBitsPtr
ZeroMemory ByVal bm256.DIBSectionBitsPtr, bmw
pFireworks256
Else
FireworksCalcNext ByVal bm.DIBSectionBitsPtr 'slow!!
ZeroMemory ByVal bm.DIBSectionBitsPtr, bmw * 4
pFireworks
End If
t = t + 1
nFPSt = nFPSt + 1
Form_Paint
End Sub
Private Sub pRun()
Do Until DoEvents = 0
pTimer
Sleep 10
Loop
End Sub
Private Sub pFireworks256()
Dim i As Long, hpn As Long
pCalcFireworks
For i = 1 To pm
With ps(i)
If .Used > 0 Then
.Used = 1
If .lf >= 0 And .lf < 256 Then
hpn = CreatePen(0, 1, tb(255 - .lf))
SelectObject bm256.hdc, hpn
MoveToEx bm256.hdc, .ox, .oy, ByVal 0
LineTo bm256.hdc, .x, .y
DeleteObject hpn
ElseIf .lf >= 10000 And .lf < 10100 Then
hpn = CreatePen(0, 3, vbWhite)
SelectObject bm256.hdc, hpn
MoveToEx bm256.hdc, .ox, .oy, ByVal 0
LineTo bm256.hdc, .x, .y
DeleteObject hpn
End If
End If
End With
Next i
End Sub
Private Sub pFireworks()
Dim i As Long, hpn As Long
pCalcFireworks
For i = 1 To pm
With ps(i)
If .Used > 0 Then
.Used = 1
If .lf >= 0 And .lf < 256 Then
hpn = CreatePen(0, 1, .clr)
SelectObject bm.hdc, hpn
MoveToEx bm.hdc, .ox, .oy, ByVal 0
LineTo bm.hdc, .x, .y
DeleteObject hpn
ElseIf .lf >= 10000 And .lf < 10100 Then
hpn = CreatePen(0, 3, .clr)
SelectObject bm.hdc, hpn
MoveToEx bm.hdc, .ox, .oy, ByVal 0
LineTo bm.hdc, .x, .y
DeleteObject hpn
End If
End If
End With
Next i
End Sub
Private Sub pCalcFireworks()
Dim i As Long, j As Long
Dim n As Long
Dim v As Single, θ As Single
If pc = 0 Then Exit Sub
i = 1
Do Until i > pm
With ps(i)
If .Used = 1 Then
.ox = .x
.oy = .y
.dy = .dy + Gravity
.x = .x + .dX
.y = .y + .dy
If .y > bmw And .dy > 0 Then 'lf??
RemoveParticle i
Else
.lf = .lf + 1
If .lf = 300 Then
RemoveParticle i
ElseIf .lf = 10100 Then
For j = 1 To 100
n = AddParticle
ps(n).x = .x
ps(n).y = .y
ps(n).ox = .x
ps(n).oy = .y
θ = 2 * PI * Rnd
v = 10 * Rnd
ps(n).dX = v * Cos(θ)
ps(n).dy = v * Sin(θ)
ps(n).lf = 0
ps(n).clr = .clr
Next j
RemoveParticle i
End If
End If
End If
End With
i = i + 1
Loop
End Sub
Private Function AddParticle() As Long
Dim i As Long
pc = pc + 1
If pc > pm Then
pm = pm + 1000
ReDim Preserve ps(1 To pm)
ps(pc).Used = 2
AddParticle = pc
Else
For i = 1 To pm
If ps(i).Used = 0 Then
ps(i).Used = 2 'new
AddParticle = i
Exit Function
End If
Next i
End If
End Function
Private Sub RemoveParticle(ByVal i As Long)
If ps(i).Used > 0 Then
ps(i).Used = 0
pc = pc - 1
End If
End Sub
Public Sub fResize()
Dim w As Long, h As Long
If Form2.Option2(0).Value Then
w = 10879
h = 10879
Else
w = 480
h = 360
End If
If w <> Me.ScaleWidth Then
w = Me.Width \ 15 - Me.ScaleWidth + w
h = Me.Height \ 15 - Me.ScaleHeight + h
Me.Width = w * 15
Me.Height = h * 15
pResize
End If
End Sub
好了总结就到这里吧,上面的代码在VB中才能运行,如果还能在其他软件运行,一定要告诉我哦,欢迎各位来当我的老师。