⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spritetutor.frm

📁 采用VB6编制的小小程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Begin VB.Form Spritetutor 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "SPRITE TUTOR"
   ClientHeight    =   3990
   ClientLeft      =   945
   ClientTop       =   435
   ClientWidth     =   5850
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   266
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   390
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   1
      Left            =   6480
      Top             =   1080
   End
   Begin VB.PictureBox Picback 
      BackColor       =   &H00FFFFFF&
      BorderStyle     =   0  'None
      Height          =   3615
      Left            =   0
      ScaleHeight     =   241
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   305
      TabIndex        =   0
      Top             =   0
      Width           =   4575
   End
   Begin VB.Label Label2 
      Caption         =   "ScrollY = "
      Height          =   255
      Index           =   5
      Left            =   4800
      TabIndex        =   15
      Top             =   3360
      Width           =   855
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFFFFF&
      Caption         =   " "
      Height          =   255
      Index           =   5
      Left            =   4800
      TabIndex        =   14
      Top             =   3600
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "ScreenX "
      Height          =   255
      Index           =   4
      Left            =   4800
      TabIndex        =   13
      Top             =   0
      Width           =   855
   End
   Begin VB.Label Label2 
      Caption         =   "screenY "
      Height          =   255
      Index           =   3
      Left            =   4800
      TabIndex        =   12
      Top             =   720
      Width           =   855
   End
   Begin VB.Label Label2 
      Caption         =   "mapX"
      Height          =   255
      Index           =   2
      Left            =   4800
      TabIndex        =   11
      Top             =   1320
      Width           =   855
   End
   Begin VB.Label Label2 
      Caption         =   "mapY"
      Height          =   255
      Index           =   1
      Left            =   4800
      TabIndex        =   10
      Top             =   2040
      Width           =   855
   End
   Begin VB.Label Label2 
      Caption         =   "ScrollX = "
      Height          =   255
      Index           =   0
      Left            =   4800
      TabIndex        =   9
      Top             =   2760
      Width           =   855
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFFFFF&
      Caption         =   " "
      Height          =   255
      Index           =   4
      Left            =   4800
      TabIndex        =   8
      Top             =   3000
      Width           =   735
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFFFFF&
      Caption         =   " "
      Height          =   255
      Index           =   3
      Left            =   4800
      TabIndex        =   7
      Top             =   2400
      Width           =   735
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFFFFF&
      Caption         =   " "
      Height          =   255
      Index           =   2
      Left            =   4800
      TabIndex        =   6
      Top             =   1680
      Width           =   735
   End
   Begin VB.Label Label1 
      BackColor       =   &H8000000E&
      Caption         =   " "
      Height          =   255
      Index           =   1
      Left            =   4800
      TabIndex        =   5
      Top             =   1080
      Width           =   735
   End
   Begin VB.Label Label1 
      BackColor       =   &H8000000C&
      Caption         =   " "
      Height          =   255
      Index           =   0
      Left            =   4800
      TabIndex        =   4
      Top             =   360
      Width           =   735
   End
   Begin VB.Label Label6 
      Caption         =   "Label for X,Y"
      Height          =   375
      Left            =   6480
      TabIndex        =   3
      Top             =   120
      Width           =   735
   End
   Begin VB.Label lbltop 
      BackColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   6480
      TabIndex        =   2
      Top             =   720
      Width           =   615
   End
   Begin VB.Label lblleft 
      BackColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   6480
      TabIndex        =   1
      Top             =   480
      Width           =   615
   End
End
Attribute VB_Name = "Spritetutor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit    'must use diff names for var
Dim LadyB As tSprite   'declare the LadyBas user defined sprite
Const TileSize = 50 'size of each sprite/map tile
Const ScreenWidth = 300  'The size of our view screen
Const ScreenHeight = 240  'the size of our viewscreen
Const MapHeight = 860
Const MapWidth = 860
Const dx = 15  'The ammount of X movement
Const dy = 13  'The ammount of Y movement
Dim LastXDir As Integer
Dim LastYDir As Integer
Dim ScrollX As Boolean
Dim ScrollY As Boolean
Dim Bullet As tSprite  'The Bullet is a sprite
Dim PicWork As tArea   'PicWork is a mem
Dim PicSprite As tArea
Dim PicMask As tArea
Dim PicOrgBack As tArea
Private Sub DelayLoop(Num As Long)
Dim i As Long
For i = 0 To Num
Next i
End Sub
Private Sub Bullet_Init()
Bullet.Active = False    'sprite active
Bullet.ident = 0         '0 = bulletsprite can be 0,1,2
Bullet.left = 0   'left coord
Bullet.top = 0       'top coord
Bullet.Width = 25    'width of sprite
Bullet.Height = 25   'height of sprite
Bullet.Sprx = 0            'frame offset x
Bullet.Spry = 70            'frame offset y
Bullet.mapx = 0          'board index loc x
Bullet.mapy = 0           'boad index loc x
Bullet.doing = 0   'index to what it is doing 0 = standing
Bullet.XSpeed = 0  'x speed in pixels
Bullet.YSpeed = 0  'y speed in pixels
Bullet.XDir = 0    '+1 or -1 dir
Bullet.Ydir = 0    '+1 or -1 dir
'source area for bulletbitmap
Bullet.src.hdc = PicSprite.hdc
Bullet.src.left = PicSprite.left
Bullet.src.top = PicSprite.top
Bullet.src.Width = PicSprite.Width
Bullet.src.Height = PicSprite.Height
'mask area for bulletmask bitmap
Bullet.mask.hdc = PicMask.hdc
Bullet.mask.left = PicMask.left
Bullet.mask.top = PicMask.top
Bullet.mask.Width = PicMask.Width
Bullet.mask.Height = PicMask.Height
'default background ususally a work or save area to paint to
Bullet.bkg.hdc = PicWork.hdc
Bullet.bkg.left = PicWork.left
Bullet.bkg.top = PicWork.top
Bullet.bkg.Width = PicWork.Width
Bullet.bkg.Height = PicWork.Height
'end of init bullet

End Sub
Private Sub CheckUpDown(Sprite As tSprite)
If ScrollY = True Then
    If Sprite.mapy <= 0 Then
        ScrollY = False
        Sprite.mapy = 0
    ElseIf Sprite.mapy >= MapHeight - ScreenHeight Then
        ScrollY = False
        Sprite.mapy = MapHeight - ScreenHeight
    End If
ElseIf ScrollY = False Then
    If Sprite.mapy <= 0 Then
        If Sprite.top > ((ScreenHeight / 2) - (Sprite.Height / 2)) Then
            ScrollY = True
            Sprite.top = ((ScreenHeight / 2) - (Sprite.Height / 2))
        End If
    ElseIf Sprite.mapy >= MapHeight - ScreenHeight Then
        If Sprite.top < ((ScreenHeight / 2) - (Sprite.Height / 2)) Then
            ScrollY = True
            Sprite.top = ((ScreenHeight / 2) - (Sprite.Height / 2))
        End If
    End If
End If
End Sub
Private Sub CheckLeftRight(Sprite As tSprite)
If ScrollX = True Then
    If Sprite.mapx <= 0 Then
        ScrollX = False
        Sprite.mapx = 0
        
    ElseIf Sprite.mapx >= MapWidth - ScreenWidth Then
        ScrollX = False
        Sprite.mapx = MapWidth - ScreenWidth
       
    End If
ElseIf ScrollX = False Then
    If Sprite.mapx <= 0 Then
        If Sprite.left > ((ScreenWidth / 2) - (Sprite.Width / 2)) Then
            ScrollX = True
            Sprite.left = ((ScreenWidth / 2) - (Sprite.Width / 2))
        End If
    ElseIf Sprite.mapx >= MapWidth - ScreenWidth Then
        If Sprite.left < ((ScreenWidth / 2) - (Sprite.Width / 2)) Then
            ScrollX = True
            Sprite.left = ((ScreenWidth / 2) - (Sprite.Width / 2))
        End If
    End If
End If
End Sub
Private Sub Initializations()
Dim Retcode As Long
'Form Inits
Me.ScaleMode = 3
'Background picturebox
Picback.ScaleMode = 3
Picback.ScaleWidth = ScreenWidth
Picback.ScaleHeight = ScreenHeight
'We will load one of our bitmaps in order to set our needed palette
Picback.Picture = LoadPicture(App.Path & "\ladybug.bmp")
ScrollX = True
ScrollY = True
'Mem Hdc to hold Whole Original bimap
PicOrgBack.hdc = 0
PicOrgBack.left = PicOrgBack.top = 0
PicOrgBack.Width = PicOrgBack.Height = 860
PicOrgBack.hdc = CreateMemHdc(Picback.hdc, PicOrgBack.Width, PicOrgBack.Height)
Call LoadBmpToHdc(PicOrgBack.hdc, "back.bmp")

'Mem Hdc to hold Sprites
PicSprite.hdc = 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -