home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / sources / chapter12 / ViewMap / Form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2004-10-23  |  2.3 KB  |  72 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12. Attribute VB_Name = "Form1"
  13. Attribute VB_GlobalNameSpace = False
  14. Attribute VB_Creatable = False
  15. Attribute VB_PredeclaredId = True
  16. Attribute VB_Exposed = False
  17. Const TILEBMPCOLS As Long = 16
  18. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  19.     If KeyCode = 27 Then Shutdown
  20. End Sub
  21. Private Sub Form_Load()
  22.     'set up the main form
  23.     Me.Caption = "ViewMap"
  24.     Me.AutoRedraw = False
  25.     Me.BorderStyle = 1
  26.     Me.ClipControls = False
  27.     Me.ScaleMode = 3
  28.     Me.width = Screen.TwipsPerPixelX * (SCREENWIDTH + 12)
  29.     Me.height = Screen.TwipsPerPixelY * (SCREENHEIGHT + 30)
  30.     Me.Show
  31.     'initialize Direct3D
  32.     InitDirect3D Me.hWnd
  33.     'get reference to the back buffer
  34.     Set backbuffer = d3ddev.GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
  35.     'load the bitmap file
  36.     Set tiles = LoadSurface(App.Path & "\ireland.bmp", 1024, 576)
  37.     'load the map data from the Mappy export file
  38.     LoadBinaryMap App.Path & "\ireland.mar", MAPWIDTH, MAPHEIGHT
  39.     'clear the screen to black
  40.     d3ddev.Clear 0, ByVal 0, D3DCLEAR_TARGET, C_BLACK, 1, 0
  41.     SatelliteView
  42. End Sub
  43. Public Sub SatelliteView()
  44.     Dim tilex As Integer
  45.     Dim tiley As Integer
  46.     Dim x As Integer
  47.     Dim y As Integer
  48.     Dim tilenum As Integer
  49.     Dim r As DxVBLibA.RECT
  50.     Dim p As DxVBLibA.point
  51.     'draw tiles onto the scroll buffer surface
  52.     For y = 0 To MAPHEIGHT - 1 Step 4
  53.         For x = 0 To MAPWIDTH - 1 Step 4
  54.             
  55.             tilenum = mapdata(y * MAPWIDTH + x)
  56.             
  57.             r.Left = (tilenum Mod TILEBMPCOLS) * TILEWIDTH
  58.             r.Top = (tilenum \ TILEBMPCOLS) * TILEHEIGHT
  59.             r.Right = r.Left + 1
  60.             r.bottom = r.Top + 1
  61.             
  62.             p.x = x / 4
  63.             p.y = y / 4
  64.             
  65.             d3ddev.CopyRects tiles, r, 1, backbuffer, p
  66.         Next x
  67.     Next y
  68. End Sub
  69. Private Sub Form_Paint()
  70.     d3ddev.Present ByVal 0, ByVal 0, 0, ByVal 0
  71. End Sub
  72.