home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Realtime_A2047682132007.psc / Form1.frm < prev    next >
Text File  |  2007-02-13  |  23KB  |  661 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMain 
  3.    Caption         =   "Lake Screensaver (Debug Mode)"
  4.    ClientHeight    =   7950
  5.    ClientLeft      =   60
  6.    ClientTop       =   450
  7.    ClientWidth     =   10455
  8.    ControlBox      =   0   'False
  9.    Icon            =   "Form1.frx":0000
  10.    KeyPreview      =   -1  'True
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   530
  13.    ScaleMode       =   3  'Pixel
  14.    ScaleWidth      =   697
  15.    StartUpPosition =   3  'Windows Default
  16.    Visible         =   0   'False
  17.    Begin VB.PictureBox picBeachMask 
  18.       AutoRedraw      =   -1  'True
  19.       AutoSize        =   -1  'True
  20.       Height          =   2760
  21.       Left            =   3000
  22.       Picture         =   "Form1.frx":08CA
  23.       ScaleHeight     =   180
  24.       ScaleMode       =   3  'Pixel
  25.       ScaleWidth      =   550
  26.       TabIndex        =   16
  27.       Top             =   5520
  28.       Visible         =   0   'False
  29.       Width           =   8310
  30.    End
  31.    Begin VB.PictureBox picBeach 
  32.       AutoRedraw      =   -1  'True
  33.       AutoSize        =   -1  'True
  34.       Height          =   2760
  35.       Left            =   2400
  36.       Picture         =   "Form1.frx":54B2
  37.       ScaleHeight     =   180
  38.       ScaleMode       =   3  'Pixel
  39.       ScaleWidth      =   550
  40.       TabIndex        =   15
  41.       Top             =   5400
  42.       Visible         =   0   'False
  43.       Width           =   8310
  44.    End
  45.    Begin VB.PictureBox picfishmask 
  46.       AutoRedraw      =   -1  'True
  47.       AutoSize        =   -1  'True
  48.       Height          =   660
  49.       Left            =   360
  50.       Picture         =   "Form1.frx":12D94
  51.       ScaleHeight     =   40
  52.       ScaleMode       =   3  'Pixel
  53.       ScaleWidth      =   80
  54.       TabIndex        =   13
  55.       Top             =   5640
  56.       Visible         =   0   'False
  57.       Width           =   1260
  58.    End
  59.    Begin VB.PictureBox picShipMask 
  60.       AutoRedraw      =   -1  'True
  61.       AutoSize        =   -1  'True
  62.       BackColor       =   &H80000009&
  63.       Height          =   4650
  64.       Left            =   8520
  65.       Picture         =   "Form1.frx":1589F
  66.       ScaleHeight     =   306
  67.       ScaleMode       =   3  'Pixel
  68.       ScaleWidth      =   107
  69.       TabIndex        =   12
  70.       Top             =   240
  71.       Visible         =   0   'False
  72.       Width           =   1665
  73.    End
  74.    Begin VB.PictureBox picShip 
  75.       AutoRedraw      =   -1  'True
  76.       AutoSize        =   -1  'True
  77.       BackColor       =   &H00000000&
  78.       Height          =   4650
  79.       Left            =   6480
  80.       Picture         =   "Form1.frx":185F8
  81.       ScaleHeight     =   306
  82.       ScaleMode       =   3  'Pixel
  83.       ScaleWidth      =   107
  84.       TabIndex        =   11
  85.       Top             =   360
  86.       Visible         =   0   'False
  87.       Width           =   1665
  88.    End
  89.    Begin VB.PictureBox picOverlayMask 
  90.       AutoRedraw      =   -1  'True
  91.       AutoSize        =   -1  'True
  92.       Height          =   3660
  93.       Left            =   4440
  94.       Picture         =   "Form1.frx":1D16C
  95.       ScaleHeight     =   240
  96.       ScaleMode       =   3  'Pixel
  97.       ScaleWidth      =   640
  98.       TabIndex        =   10
  99.       Top             =   7680
  100.       Visible         =   0   'False
  101.       Width           =   9660
  102.    End
  103.    Begin VB.PictureBox picOverlay 
  104.       AutoRedraw      =   -1  'True
  105.       AutoSize        =   -1  'True
  106.       Height          =   3660
  107.       Left            =   3840
  108.       Picture         =   "Form1.frx":1F515
  109.       ScaleHeight     =   240
  110.       ScaleMode       =   3  'Pixel
  111.       ScaleWidth      =   640
  112.       TabIndex        =   9
  113.       Top             =   6840
  114.       Visible         =   0   'False
  115.       Width           =   9660
  116.    End
  117.    Begin VB.PictureBox picSpriteMask 
  118.       AutoRedraw      =   -1  'True
  119.       AutoSize        =   -1  'True
  120.       Height          =   660
  121.       Left            =   2400
  122.       Picture         =   "Form1.frx":2EB6C
  123.       ScaleHeight     =   40
  124.       ScaleMode       =   3  'Pixel
  125.       ScaleWidth      =   400
  126.       TabIndex        =   8
  127.       Top             =   6000
  128.       Visible         =   0   'False
  129.       Width           =   6060
  130.    End
  131.    Begin VB.PictureBox picSprite 
  132.       AutoRedraw      =   -1  'True
  133.       AutoSize        =   -1  'True
  134.       Height          =   660
  135.       Left            =   2400
  136.       Picture         =   "Form1.frx":34992
  137.       ScaleHeight     =   40
  138.       ScaleMode       =   3  'Pixel
  139.       ScaleWidth      =   400
  140.       TabIndex        =   7
  141.       Top             =   6720
  142.       Visible         =   0   'False
  143.       Width           =   6060
  144.    End
  145.    Begin VB.PictureBox picBackMask 
  146.       AutoRedraw      =   -1  'True
  147.       AutoSize        =   -1  'True
  148.       Height          =   3660
  149.       Left            =   1320
  150.       Picture         =   "Form1.frx":3BD34
  151.       ScaleHeight     =   240
  152.       ScaleMode       =   3  'Pixel
  153.       ScaleWidth      =   640
  154.       TabIndex        =   6
  155.       Top             =   5640
  156.       Visible         =   0   'False
  157.       Width           =   9660
  158.    End
  159.    Begin VB.CommandButton Command1 
  160.       Caption         =   "Exit"
  161.       Height          =   1335
  162.       Left            =   0
  163.       TabIndex        =   5
  164.       Top             =   120
  165.       Width           =   255
  166.    End
  167.    Begin VB.PictureBox picBack 
  168.       AutoRedraw      =   -1  'True
  169.       AutoSize        =   -1  'True
  170.       Height          =   5460
  171.       Left            =   360
  172.       Picture         =   "Form1.frx":421BF
  173.       ScaleHeight     =   360
  174.       ScaleMode       =   3  'Pixel
  175.       ScaleWidth      =   640
  176.       TabIndex        =   4
  177.       Top             =   4920
  178.       Visible         =   0   'False
  179.       Width           =   9660
  180.       Begin VB.PictureBox picFish 
  181.          AutoRedraw      =   -1  'True
  182.          AutoSize        =   -1  'True
  183.          Height          =   660
  184.          Left            =   0
  185.          Picture         =   "Form1.frx":7671B
  186.          ScaleHeight     =   40
  187.          ScaleMode       =   3  'Pixel
  188.          ScaleWidth      =   80
  189.          TabIndex        =   14
  190.          Top             =   0
  191.          Visible         =   0   'False
  192.          Width           =   1260
  193.       End
  194.    End
  195.    Begin VB.PictureBox picSky 
  196.       AutoRedraw      =   -1  'True
  197.       AutoSize        =   -1  'True
  198.       Height          =   3660
  199.       Left            =   360
  200.       Picture         =   "Form1.frx":796A1
  201.       ScaleHeight     =   240
  202.       ScaleMode       =   3  'Pixel
  203.       ScaleWidth      =   1280
  204.       TabIndex        =   3
  205.       Top             =   6840
  206.       Visible         =   0   'False
  207.       Width           =   19260
  208.    End
  209.    Begin VB.PictureBox picBuffer 
  210.       AutoRedraw      =   -1  'True
  211.       Height          =   3375
  212.       Left            =   6840
  213.       ScaleHeight     =   221
  214.       ScaleMode       =   3  'Pixel
  215.       ScaleWidth      =   85
  216.       TabIndex        =   2
  217.       Top             =   2520
  218.       Visible         =   0   'False
  219.       Width           =   1335
  220.    End
  221.    Begin VB.PictureBox picDisplay 
  222.       BackColor       =   &H80000009&
  223.       Height          =   4695
  224.       Left            =   360
  225.       ScaleHeight     =   309
  226.       ScaleMode       =   3  'Pixel
  227.       ScaleWidth      =   421
  228.       TabIndex        =   1
  229.       Top             =   120
  230.       Width           =   6375
  231.    End
  232.    Begin VB.PictureBox picBackground 
  233.       AutoRedraw      =   -1  'True
  234.       AutoSize        =   -1  'True
  235.       Height          =   3660
  236.       Left            =   6600
  237.       Picture         =   "Form1.frx":88D17
  238.       ScaleHeight     =   240
  239.       ScaleMode       =   3  'Pixel
  240.       ScaleWidth      =   640
  241.       TabIndex        =   0
  242.       Top             =   840
  243.       Visible         =   0   'False
  244.       Width           =   9660
  245.    End
  246. End
  247. Attribute VB_Name = "frmMain"
  248. Attribute VB_GlobalNameSpace = False
  249. Attribute VB_Creatable = False
  250. Attribute VB_PredeclaredId = True
  251. Attribute VB_Exposed = False
  252. Option Explicit
  253.     
  254. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  255. Private Const NUM_FRAMES As Integer = 12
  256.  
  257. Dim nImgWidth As Double
  258. Dim nImgHeight As Double
  259. Dim framenumber As Integer
  260.  
  261. Private Type sprite
  262.     X As Long
  263.     Y As Long
  264.     z As Long           '' Not used 0 closest to background 3 (5) farthest out and lower on the inverted pic (0 is higher on the inverted pic)
  265.     shDc As Long        ' Source hdc of sprite
  266.     speed As Integer    ' How fast it moves
  267.     FramesToWait As Integer ' Pause before new instance is created for a certain number of frames
  268.     frameNum As Integer
  269.     visible As Boolean
  270.     width As Single
  271.     height As Single
  272. End Type
  273.  
  274. Dim Ship As sprite
  275.  
  276. Dim ShipWidth As Long
  277. Dim ShipHeight As Long
  278.  
  279. Dim bf As BLENDFUNCTION, lBF As Long
  280.  
  281. Private Sub BlendTest()
  282.  
  283.     With bf
  284.         .BlendOp = AC_SRC_OVER
  285.         .BlendFlags = 0
  286.         .SourceConstantAlpha = waterTransparency
  287.         .AlphaFormat = 0
  288.     End With
  289.     
  290.     RtlMoveMemory lBF, bf, 4
  291.     
  292. End Sub
  293.  
  294.  
  295. Private Sub Command1_Click()
  296.         bCancel = True
  297. End Sub
  298.  
  299. Private Sub Form_KeyPress(KeyAscii As Integer)
  300.     If KeyAscii = vbKeyEscape Then
  301.         bCancel = True
  302.         Unload Me
  303.     End If
  304. End Sub
  305.  
  306. Private Sub Form_Load()
  307.     Init
  308.     'Unload Me
  309.     UnloadAll
  310.     SystemParametersInfo SPI_SETSCREENSAVEACTIVE, 1, ByVal 0&, 0
  311.     DoEvents
  312. End Sub
  313.  
  314. Public Sub Init(Optional initString As String)
  315.  
  316.     Dim WinStyle As Long
  317.     Dim PreviewRect As RECT
  318.         
  319.     If initString = "" Then
  320.         initString = Command$
  321.     End If
  322.     
  323.     Randomize (Now)
  324.       
  325.     ReadIni
  326.     BlendTest
  327.     DisplayMode = Mid$(LCase$(Trim$(initString)), 1, 2) ' /s, /c, /p
  328.     
  329.     nImgHeight = picBackground.ScaleHeight
  330.     nImgWidth = picBackground.ScaleWidth
  331.     picDisplay.height = 2 * picBackground.height
  332.     picDisplay.width = picBackground.width
  333.  
  334.     picBuffer.width = 3 * picBackground.width
  335.     picBuffer.height = picBackground.height
  336.     
  337.     Select Case DisplayMode
  338.         Case "/p" ' preview
  339.             PreviewHWND = GetHwndFromCmd(Command$)
  340.             frmPreview.Show
  341.             frmPreview.visible = False
  342.             GetClientRect PreviewHWND, PreviewRect
  343.             WinStyle = GetWindowLong(frmPreview.hwnd, GWL_STYLE)
  344.             SetWindowLong frmPreview.hwnd, GWL_STYLE, WinStyle Or WS_CHILD
  345.             SetWindowLong frmPreview.hwnd, GWL_HWNDPARENT, PreviewHWND
  346.             SetParent frmPreview.hwnd, PreviewHWND
  347.             SetWindowPos frmPreview.hwnd, HWND_TOP, 0&, 0&, PreviewRect.Right, PreviewRect.Bottom, SWP_NOZORDER Or SWP_NOACTIVATE Or SWP_SHOWWINDOW
  348.             SystemParametersInfo SPI_SETSCREENSAVEACTIVE, 0, ByVal 0&, 0
  349.             picDisplay.AutoRedraw = True
  350.             frmPreview.visible = True
  351.         Case "/s" ',"" ' Full screen normal
  352.             SystemParametersInfo SPI_SETSCREENSAVEACTIVE, 0, ByVal 0&, 0
  353.             ShowCursor False
  354.             picDisplay.AutoRedraw = True
  355.             SetStretchBltMode picDisplay.hdc, vbPaletteModeNone
  356.             SetWindowPos frmDisplay.hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
  357.             frmDisplay.Show
  358.         'Case "/a"
  359.         Case "/c"
  360.             frmConfig.Show
  361.         Case Else
  362.             Me.Show
  363.             picDisplay.AutoRedraw = False
  364.     End Select
  365.  
  366.     SetStretchBltMode picBackground.hdc, vbPaletteModeNone
  367.     SetStretchBltMode picDisplay.hdc, vbPaletteModeNone
  368.     SetStretchBltMode picBuffer.hdc, vbPaletteModeNone
  369.  
  370.     bCancel = False
  371.     DoEvents
  372.     runIt
  373.         
  374. End Sub
  375.  
  376. Public Sub runIt()
  377.     Dim skyPos As Double 'Long
  378.     Dim bird1 As sprite
  379.     Dim fish As sprite
  380.     Dim tickTime As Long
  381.     Dim theTime As Long
  382.     Dim FPS As Integer
  383.     Dim skyTest As Long
  384.     Dim shipSourceTemp As Double
  385.     Dim shipDestTemp As Double
  386.     
  387.     ShipWidth = picShip.ScaleWidth
  388.     ShipHeight = picShip.ScaleHeight
  389.     
  390. '    With bird1
  391. '        .X = 0
  392. '        .Y = nImgHeight \ 2
  393.         '.shDc = picSprite.hdc
  394. '        .speed = 5
  395. '        .visible = True
  396. '    End With
  397.     
  398.     With Ship
  399.         .X = 50
  400.         .Y = 50
  401.         .width = ShipWidth
  402.         .height = ShipHeight
  403.         .visible = True
  404.     End With
  405.     
  406. '    With fish
  407. '        .X = 50
  408. '        .Y = nImgHeight + 100
  409. '        .shDc = picSprite.hdc
  410. '        .speed = 5
  411. '        .visible = True
  412. '    End With
  413.     
  414.     framenumber = 12
  415.     
  416.     Do While Not bCancel
  417.         tickTime = GetTickCount
  418.         ' Draw Sky
  419.         If skyPos + 640 > picSky.ScaleWidth Then
  420.             BitBlt picBackground.hdc, 0, 0, 640, nImgHeight, picSky.hdc, skyPos, 0, vbSrcCopy
  421.             BitBlt picBackground.hdc, picSky.ScaleWidth - skyPos, 0, 640, nImgHeight, picSky.hdc, 0, 0, vbSrcCopy
  422.         Else
  423.             BitBlt picBackground.hdc, 0, 0, 640, nImgHeight, picSky.hdc, skyPos, 0, vbSrcCopy
  424.         End If
  425.         skyPos = skyPos + 0.25 ' 0.5 ' 1
  426.         If skyPos >= picSky.ScaleWidth Then
  427.             'Stop
  428.             skyPos = 0 'picSky.ScaleWidth - skyPos - 640
  429.         End If
  430.         
  431.         ' Draw Background
  432.  
  433.         If framenumber >= 12 Then
  434.             framenumber = 0 'NUM_FRAMES
  435.         End If
  436.         
  437.         framenumber = framenumber + 1
  438.         
  439.         ' Draw Sprite
  440.         If birdAnim Then
  441.             If bird1.visible Then
  442.                 If bird1.frameNum >= 9 Then bird1.frameNum = 0
  443.                 BitBlt picBackground.hdc, bird1.X, bird1.Y, 40, 40, picSpriteMask.hdc, bird1.frameNum * 40, 0, vbSrcAnd
  444.                 BitBlt picBackground.hdc, bird1.X, bird1.Y, 40, 40, picSprite.hdc, bird1.frameNum * 40, 0, vbSrcPaint
  445.                 bird1.frameNum = bird1.frameNum + 1
  446.                 bird1.X = bird1.X + bird1.speed
  447.                 If bird1.X > nImgWidth Then
  448.                     bird1.visible = False
  449.                     bird1.FramesToWait = Rnd() * 400
  450.                     bird1.frameNum = 0
  451.                 End If
  452.             Else
  453.                 If bird1.FramesToWait <= 0 Then
  454.                     ' Start a fresh instance of a bird
  455.                     bird1.X = 0
  456.                     bird1.Y = Rnd() * (nImgHeight * 0.75)
  457.                     bird1.visible = True
  458.                     bird1.speed = Rnd() * 5 + 10
  459.                     bird1.frameNum = 0
  460.                 Else
  461.                     ' Wait some more frames to create another bird
  462.                     bird1.FramesToWait = bird1.FramesToWait - 1
  463.                 End If
  464.             End If
  465.         End If
  466.         
  467.         If showBack Then
  468.         ' Draw Overlay
  469.             BitBlt picBackground.hdc, 0, 0, 640, 240, picOverlayMask.hdc, 0, 0, vbSrcAnd
  470.             BitBlt picBackground.hdc, 0, 0, 640, 240, picOverlay.hdc, 0, 0, vbSrcPaint
  471.         End If
  472.         
  473.         'createAnimation
  474.         makeWaves framenumber
  475.         
  476.         ' Draw underwater picture
  477.         BitBlt picDisplay.hdc, 0, nImgHeight, 640, 240, picBack.hdc, 0, 0, vbSrcCopy
  478.         
  479.         ' Draw fish
  480.          If fishAnim Then
  481.             If fish.visible Then
  482.                 'If fish.frameNum >= 9 Then fish.frameNum = 0
  483.                 BitBlt picDisplay.hdc, fish.X, fish.Y, 80, 40, picfishmask.hdc, 0, 0, vbSrcAnd
  484.                 BitBlt picDisplay.hdc, fish.X, fish.Y, 80, 40, picFish.hdc, 0, 0, vbSrcPaint
  485.                 fish.frameNum = fish.frameNum + 1
  486.                 fish.X = fish.X + fish.speed
  487.                 fish.Y = fish.Y + (Sin(fish.X) * 10)
  488.                 If fish.X > nImgWidth Then
  489.                     fish.visible = False
  490.                     fish.FramesToWait = Rnd() * 100
  491.                     fish.frameNum = 0
  492.                 End If
  493.             Else
  494.                 If fish.FramesToWait <= 0 Then
  495.                     ' Start a fresh instance of a fish
  496.                     fish.X = 0
  497.                     fish.Y = Rnd() * (nImgHeight * 0.75) + nImgHeight
  498.                     fish.visible = True
  499.                     fish.speed = Rnd() * 10 + 5
  500.                     fish.frameNum = 0
  501.                 Else
  502.                     ' Wait some more frames to create another fish
  503.                     fish.FramesToWait = fish.FramesToWait - 1
  504.                 End If
  505.             End If
  506.         End If
  507.  
  508.         ' Draw waves
  509.         AlphaBlend picDisplay.hdc, 0, nImgHeight, nImgWidth, nImgHeight, picBuffer.hdc, 0, 0, nImgWidth, nImgHeight, lBF
  510.         
  511.         If showBack Then
  512.             ' Draw Overlay
  513.             BitBlt picBackground.hdc, 0, 0, 640, 240, picOverlayMask.hdc, 0, 0, vbSrcAnd
  514.             BitBlt picBackground.hdc, 0, 0, 640, 240, picOverlay.hdc, 0, 0, vbSrcPaint
  515.         End If
  516.         
  517.         BitBlt picDisplay.hdc, 0, 0, nImgWidth, nImgHeight, picBackground.hdc, 0, 0, vbSrcCopy
  518.  
  519.         
  520.         ' Draw ship on waves only if not behind overlay
  521.         ' Ship stuff
  522.         If shipAnim Then
  523.             If Ship.X + ShipWidth < 297 And Ship.visible Then
  524.                 StretchBlt picDisplay.hdc, Ship.X, Ship.Y, Ship.width, Ship.height, picShipMask.hdc, 0, 0, ShipWidth, ShipHeight, vbSrcAnd
  525.                 StretchBlt picDisplay.hdc, Ship.X, Ship.Y, Ship.width, Ship.height, picShip.hdc, 0, 0, ShipWidth, ShipHeight, vbSrcPaint
  526.             ElseIf Ship.X > nImgWidth Then
  527.                 ' Reset Ship
  528.                 Ship.X = 50
  529.                 Ship.Y = 50
  530.                 Ship.width = ShipWidth
  531.                 Ship.height = ShipHeight
  532.                 Ship.visible = True
  533.             ElseIf Ship.visible Then
  534.                 'SetStretchBltMode picDisplay.hdc, vbPaletteModeNone
  535.                 StretchBlt picDisplay.hdc, Ship.X, Ship.Y, Ship.width, Ship.height, picShipMask.hdc, 0, 0, ShipWidth, ShipHeight, vbSrcAnd
  536.                 StretchBlt picDisplay.hdc, Ship.X, Ship.Y, Ship.width, Ship.height, picShip.hdc, 0, 0, ShipWidth, ShipHeight, vbSrcPaint
  537.                 If showBack Then
  538.                     ' Redraw overlay and waves to cover ship going behind
  539.                     BitBlt picDisplay.hdc, 0, 0, 640, 240, picOverlayMask.hdc, 0, 0, vbSrcAnd
  540.                     BitBlt picDisplay.hdc, 0, 0, 640, 240, picOverlay.hdc, 0, 0, vbSrcPaint
  541.                     'BitBlt picDisplay.hdc, 295, nImgHeight, 640, 35, picBuffer.hdc, 295, 0, vbSrcCopy
  542.                     AlphaBlend picDisplay.hdc, 298, nImgHeight, nImgWidth, 35, picBuffer.hdc, 298, 0, nImgWidth, 35, lBF
  543.                 End If
  544.             End If
  545.             
  546.             If Ship.height >= 50 Then
  547.                 Ship.height = Ship.height - 5
  548.                 Ship.Y = Ship.Y + 3
  549.                 If Ship.width > 60 Then
  550.                     Ship.width = Ship.width - 1
  551.                 End If
  552.             ElseIf Ship.height >= 25 Then
  553.                 Ship.height = Ship.height - 3
  554.                 Ship.Y = Ship.Y + 1.5
  555.                 If Ship.width > 10 Then
  556.                     Ship.width = Ship.width - 4
  557.                 End If
  558.             Else
  559.                 Ship.visible = False
  560.             End If
  561.             
  562.             Ship.X = Ship.X + 5
  563.         End If
  564.         
  565.         If showBeach Then
  566.             BitBlt picDisplay.hdc, (picOverlay.ScaleWidth) - picBeachMask.ScaleWidth, (picOverlay.ScaleHeight * 2) - picBeachMask.ScaleHeight, 550, 180, picBeachMask.hdc, 0, 0, vbSrcAnd
  567.             BitBlt picDisplay.hdc, (picOverlay.ScaleWidth) - picBeach.ScaleWidth, (picOverlay.ScaleHeight * 2) - picBeach.ScaleHeight, 550, 180, picBeach.hdc, 0, 0, vbSrcPaint
  568.         End If
  569.         
  570.         DoEvents
  571.         
  572.         Select Case DisplayMode
  573.             Case "/p" ' preview
  574.                 StretchBlt frmPreview.hdc, 0, 0, frmPreview.ScaleWidth, frmPreview.ScaleHeight, picDisplay.hdc, 0, 0, 640, 480, vbSrcCopy
  575.             Case "/s" ' Full screen normal
  576.                 StretchBlt frmDisplay.hdc, 0, 0, Screen.width / Screen.TwipsPerPixelX, Screen.height / Screen.TwipsPerPixelY, picDisplay.hdc, 0, 0, 640, 480, vbSrcCopy
  577.             'Case "/a" ' Password TO DO add this ?
  578.             Case Else ' Just run it normally, probably testing
  579.                 'StretchBlt frmDisplay.hdc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, picDisplay.hdc, 0, 0, 640, 480, vbSrcCopy
  580.         End Select
  581.         
  582.         theTime = (GetTickCount - tickTime)
  583.         
  584.         If theTime > 0 Then
  585.             FPS = (1000 / theTime)
  586.         End If
  587.         
  588.         If FPS > 15 Then
  589.             Sleep (1000 \ 15) - theTime
  590.         End If
  591.         
  592.         'Me.Caption = "Lake Screensaver: FPS" & FPS
  593.     Loop
  594.  
  595.     UnloadAll
  596. End Sub
  597.  
  598. Public Sub makeWaves(phase As Integer)
  599.         Dim p1 As Double
  600.         Dim dispx As Integer, dispy As Integer
  601.         Dim i As Double
  602.         Dim nImg14 As Single, refY As Long, refX As Long
  603.         ' Thanks to David Griffiths for the original java lake
  604.         ' whose math I adapted for this.
  605.  
  606.         ' Flip Buffer
  607.         StretchBlt picBuffer.hdc, 2 * nImgWidth, nImgHeight, nImgWidth, -nImgHeight, picBackground.hdc, 0, 0, nImgWidth, nImgHeight, vbSrcCopy
  608.  
  609.         ' Draw Ship Reflection on water
  610.         refX = 2 * nImgWidth + Ship.X
  611.         refY = nImgHeight - Ship.Y - Ship.height - 20
  612.         StretchBlt picBuffer.hdc, refX, refY, Ship.width, Ship.height, picShipMask.hdc, 0, 0, ShipWidth, ShipHeight, vbSrcAnd
  613.         StretchBlt picBuffer.hdc, refX, refY, Ship.width, Ship.height, picShip.hdc, 0, 0, ShipWidth, ShipHeight, vbSrcPaint
  614.  
  615.         If showBack Then ' Cover what is hidden by land
  616.             StretchBlt picBuffer.hdc, 2 * nImgWidth + 300, nImgHeight, nImgWidth, -nImgHeight, picBackground.hdc, 300, 0, nImgWidth, nImgHeight, vbSrcCopy
  617.         End If
  618.  
  619.         p1 = 2 * 3.14 * phase / NUM_FRAMES ' 3.14=PI
  620.  
  621. '        Buffer is in reverse order.  Inverted pic is all the way to right
  622. '        Final frame is the one at left
  623.         dispx = 0 '(NUM_FRAMES - phase) * nImgWidth
  624.  
  625.         For i = 0 To nImgHeight
  626. '          dispy defines the vertical sine displacement. It
  627. '          attenuates higher up the image, for perspective
  628.             nImg14 = nImgHeight / 14
  629.             dispy = (nImg14 * (i + 28#) * Sin((nImg14 * (nImgHeight - i)) / CDbl(i + 1) + p1) / nImgHeight)
  630.     
  631.             If i < -dispy Then
  632.             ' Copy Original line because it falls out of range
  633.                 BitBlt picBuffer.hdc, dispx, i - 1, nImgWidth, 2, picBuffer.hdc, 2 * nImgWidth, i, vbSrcCopy
  634.             Else
  635.             'Else copy dithered line.
  636.             'Added two tests.
  637.             'The first is to check if it falls off of the bottom of the
  638.             'picture.  The next is if it is before the beginning of the picture.
  639.                 
  640.                 If nImgHeight - (i + dispy) <= 0 Then
  641.                     dispy = -dispy
  642.                 End If
  643.                     
  644.                 If i + dispy <= 0 Then
  645.                     dispy = 1
  646.                 End If
  647.                 
  648.                 ' Displacement all fixed so blt this line.
  649.                 BitBlt picBuffer.hdc, 0, i, nImgWidth, 1, picBuffer.hdc, 2 * nImgWidth, i + dispy, vbSrcCopy
  650.             End If
  651.             DoEvents
  652.         Next i
  653. End Sub
  654.  
  655. Private Sub Form_Unload(Cancel As Integer)
  656.     bCancel = True
  657.     DoEvents
  658.     ShowCursor True
  659.     UnloadAll
  660. End Sub
  661.