|
DirectX 7 编程初步(5) Pal(Index + 1).green = 0 Pal(Index + 1).blue = 0
Pal(Index + 86).red = 255 Pal(Index + 86).green = Index * 3 + 3 Pal(Index + 86).blue = 0
Pal(Index + 171).red = 255 Pal(Index + 171).green = 255 Pal(Index + 171).blue = Index * 3 + 3 Next Set Palette = Ddraw.CreatePalette(DDPCAPS_8BIT Or DDPCAPS_ALLOW256, Pal()) DDSFront.SetPalette Palette
AlphaRect.Right = DDSBackDesc.lWidth - 1 AlphaRect.Bottom=DDSBackDesc.lHeight - 1
DDSBack.Lock AlphaRect, DDSBackDesc, DDLOCK_WAIT, 0 DDSBack.GetLockedArray Pict() For X = 0 To 639 For Y = 0 To 479 Pict(X, Y) = 0 Next Next 'Corresponding unlock DDSBack.Unlock AlphaRect
While Not ExitLoop Mode = ExModeActive bRestore = False Do Until ExModeActive DoEvents bRestore = True Loop DoEvents If bRestore Then bRestore = False Ddraw.RestoreAllSurfaces End If DDSBack.Lock AlphaRect, DDSBackDesc, DDLOCK_WAIT, 0 DDSBack.GetLockedArray Pict() For Y = 0 To 479 Pict(0, Y) = 0 Pict(639, Y) = 0 Next For X = 0 To 639 Pict(X, 477) = Rnd * 220 + 35 Pict(X, 478) = Rnd * 220 + 35 Pict(X, 479) = Rnd * 220 + 35 Next Accum = 0 For X = 1 To 638 For Y = 0 To 477 Accum = (Accum + Pict(X, Y + 1) + Pict(X, Y + 2) _ + Pict(X + 1, Y + 1) + Pict(X - 1, Y + 1)) \ 5 If Accum < 0 Then Accum = 0 ElseIf Accum > 255 Then Accum = 255 End If Pict(X, Y) = Accum Next Next For X = 0 To 639 Pict(X, 0) = 0 Pict(X, 1) = 0 Next X = Rnd * 639 For Y = 50 To 439 Next 'Unlock DDSBack.Unlock AlphaRect If DX.TickCount() - lastTime > wait Then If Counter = 0 Then bDrawText = True Counter = 1 Xpos = Rnd * 200 Ypos = 300 + Rnd * 140 wait = 400 ElseIf Counter = 1 Then MsgIndex = MsgIndex + 1 If MsgIndex > 5 Then MsgIndex = 0 bDrawText = False Counter = 0 wait = 2000
|