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

📄 frmmain.frm

📁 用vb开发的RPG游戏引擎+例子,不错,值得参考
💻 FRM
📖 第 1 页 / 共 2 页
字号:
'If playerx >= tLEFT(t) And playerx <= tLEFT(t) + 40 And playery + 25 >= tTOP(t) And playery + 25 <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
Next t
direction = dleft
framex = fLEFT
framey = framey + 50
playerx = playerx - wSPEED
If framey >= 50 * 8 Then framey = 0
a = BitBlt(picMain.hdc, 0, 0, picMain.Width, picMain.Height, picRefresh.hdc, 0, 0, SRCCOPY)
a = BitBlt(picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex + 50, framey, SRCAND)
a = BitBlt(picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex, framey, SRCINVERT)
If playerx < 0 Then
playerx = picMain.ScaleWidth
mapx = mapx - 1
Call newmap
End If
End If

If KeyCode = 38 Then
For t = 0 To 254
If playerx + 11 >= tLEFT(t) And playerx + 11 <= tLEFT(t) + 40 And playery + 35 - wSPEED >= tTOP(t) And playery + 35 - wSPEED <= tTOP(t) + 40 And walk(t) = 0 Then Exit Sub
If playerx + 38 >= tLEFT(t) And playerx + 38 <= tLEFT(t) + 40 And playery + 35 - wSPEED >= tTOP(t) And playery + 35 - wSPEED <= tTOP(t) + 40 And walk(t) = 0 Then Exit Sub
'If playerx >= tLEFT(t) And playerx <= tLEFT(t) + 40 And playery >= tTOP(t) And playery <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
'If playerx + 50 >= tLEFT(t) And playerx + 50 <= tLEFT(t) + 40 And playery >= tTOP(t) And playery <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
'If playerx + 25 >= tLEFT(t) And playerx + 25 <= tLEFT(t) + 40 And playery >= tTOP(t) And playery <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
Next t
direction = dUP
framex = fUP
framey = framey + 50
playery = playery - wSPEED
If framey >= 50 * 8 Then framey = 0
a = BitBlt(picMain.hdc, 0, 0, picMain.Width, picMain.Height, picRefresh.hdc, 0, 0, SRCCOPY)
a = BitBlt(picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex + 50, framey, SRCAND)
a = BitBlt(picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex, framey, SRCINVERT)
If playery < 0 Then
playery = picMain.ScaleHeight
mapy = mapy + 1
Call newmap
End If
End If

If KeyCode = 39 Then
For t = 0 To 254
If playerx + 38 + wSPEED >= tLEFT(t) And playerx + 38 + wSPEED <= tLEFT(t) + 40 And playery + 35 >= tTOP(t) And playery + 35 <= tTOP(t) + 40 And walk(t) = 0 Then Exit Sub
If playerx + 38 + wSPEED >= tLEFT(t) And playerx + 38 + wSPEED <= tLEFT(t) + 40 And playery + 50 >= tTOP(t) And playery + 50 <= tTOP(t) + 40 And walk(t) = 0 Then Exit Sub
'If playerx + 50 >= tLEFT(t) And playerx + 50 <= tLEFT(t) + 40 And playery >= tTOP(t) And playery <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
'If playerx + 50 >= tLEFT(t) And playerx + 50 <= tLEFT(t) + 40 And playery + 50 >= tTOP(t) And playery + 50 <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
'If playerx + 50 >= tLEFT(t) And playerx + 50 <= tLEFT(t) + 40 And playery + 25 >= tTOP(t) And playery + 25 <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
Next t
direction = dRIGHT
framex = fRIGHT
framey = framey + 50
playerx = playerx + wSPEED
If framey >= 50 * 8 Then framey = 0
a = BitBlt(picMain.hdc, 0, 0, picMain.Width, picMain.Height, picRefresh.hdc, 0, 0, SRCCOPY)
a = BitBlt(picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex + 50, framey, SRCAND)
a = BitBlt(picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex, framey, SRCINVERT)
If playerx > picMain.ScaleWidth Then
playerx = 0
mapx = mapx + 1
Call newmap
End If
End If

If KeyCode = 40 Then
For t = 0 To 254
If playerx + 11 >= tLEFT(t) And playerx + 11 <= tLEFT(t) + 40 And playery + 50 + wSPEED >= tTOP(t) And playery + 50 + wSPEED <= tTOP(t) + 40 And walk(t) = 0 Then Exit Sub
If playerx + 38 >= tLEFT(t) And playerx + 38 <= tLEFT(t) + 40 And playery + 50 + wSPEED >= tTOP(t) And playery + 50 + wSPEED <= tTOP(t) + 40 And walk(t) = 0 Then Exit Sub
'If playerx >= tLEFT(t) And playerx <= tLEFT(t) + 40 And playery + 50 >= tTOP(t) And playery + 50 <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
'If playerx + 50 >= tLEFT(t) And playerx + 50 <= tLEFT(t) + 40 And playery + 50 >= tTOP(t) And playery + 50 <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
'If playerx + 25 >= tLEFT(t) And playerx + 25 <= tLEFT(t) + 40 And playery + 50 >= tTOP(t) And playery + 50 <= tTOP(t) + 40 And tENEMY(t) = 1 Then
'Call battle
'Exit Sub
'End If
Next t
direction = dDOWN
framex = fDOWN
framey = framey + 50
playery = playery + wSPEED
If framey >= 50 * 8 Then framey = 0
a = BitBlt(picMain.hdc, 0, 0, picMain.Width, picMain.Height, picRefresh.hdc, 0, 0, SRCCOPY)
a = BitBlt(picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex + 50, framey, SRCAND)
a = BitBlt(picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex, framey, SRCINVERT)
If playery > picMain.ScaleHeight Then
playery = 0
mapy = mapy - 1
Call newmap
End If
End If

For t = 0 To 254
If tENEMY(t) = 1 Then
a = BitBlt(picMain.hdc, tENEMY_LEFT(t), tENEMY_TOP(t), 50, 50, frmTiles.picSoldier.hdc, tENEMY_frameX(t) + 50, tENEMY_frameY(t), SRCAND)
a = BitBlt(picMain.hdc, tENEMY_LEFT(t), tENEMY_TOP(t), 50, 50, frmTiles.picSoldier.hdc, tENEMY_frameX(t), tENEMY_frameY(t), SRCINVERT)
End If
Next t
picMain.Refresh
End Sub
Public Sub resreset()
Dim Y As Long
Dim Flags As Long, X As Long
For checkres = 0 To 50
If res(checkres) = oRES Then X = checkres
Next checkres
D(X).dmFields = DM_BITSPERPEL Or DM_PELSWIDTH Or DM_PELSHEIGHT
    Flags = CDS_UPDATEREGISTRY
    Y = ChangeDisplaySettings(D(X), Flags)
    Select Case Y
        Case DISP_CHANGE_RESTART
            Y = MsgBox("This change will not take effect until you reboot the system.  Reboot now?", vbYesNo)
            If Y = vbYes Then
                Flags = 0
                Y = ExitWindowsEx(EWX_REBOOT, Flags)
            End If
        Case DISP_CHANGE_SUCCESSFUL
        Case Else
            MsgBox "Error changing resolution! Returned: " & Y
    End Select
Unload frmMain
Unload frmTiles
End
End Sub

Private Sub tmrEnemy_Timer()
Randomize
If dHIT = 1 Then Exit Sub
a = BitBlt(frmMain.picMain.hdc, 0, 0, frmMain.picRefresh.ScaleWidth, frmMain.picRefresh.ScaleHeight, frmMain.picRefresh.hdc, 0, 0, SRCCOPY)
For r = 0 To 254
If tENEMY(r) = 1 Then
If tENEMY_DIRECTION(r) = "left" Then
For l = 0 To 254
If tENEMY_LEFT(r) + 11 - wSPEED >= tLEFT(l) And tENEMY_LEFT(r) + 11 - wSPEED <= tLEFT(l) + 40 And tENEMY_TOP(r) + 38 >= tTOP(l) And tENEMY_TOP(r) + 38 <= tTOP(l) + 40 And walk(l) = 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "up"
If direct = 1 Then tENEMY_DIRECTION(r) = "right"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
End If
If tENEMY_LEFT(r) + 11 - wSPEED >= tLEFT(l) And tENEMY_LEFT(r) + 11 - wSPEED <= tLEFT(l) + 40 And tENEMY_TOP(r) + 50 >= tTOP(l) And tENEMY_TOP(r) + 50 <= tTOP(l) + 40 And walk(l) = 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "up"
If direct = 1 Then tENEMY_DIRECTION(r) = "right"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
End If
Next l
If tENEMY_LEFT(r) + 11 >= playerx + 11 And tENEMY_LEFT(r) + 11 <= playerx + 38 And tENEMY_TOP(r) + 35 <= playery + 50 And tENEMY_TOP(r) + 35 >= playery + 35 Then Call damien_hit_left
If tENEMY_LEFT(r) + 11 >= playerx + 11 And tENEMY_LEFT(r) + 11 <= playerx + 38 And tENEMY_TOP(r) + 50 <= playery + 50 And tENEMY_TOP(r) + 50 >= playery + 35 Then Call damien_hit_left
End If

If tENEMY_DIRECTION(r) = "up" Then
For l = 0 To 254
If tENEMY_LEFT(r) + 11 >= tLEFT(l) And tENEMY_LEFT(r) + 11 <= tLEFT(l) + 40 And tENEMY_TOP(r) + 35 - wSPEED >= tTOP(l) And tENEMY_TOP(r) + 35 - wSPEED <= tTOP(l) + 40 And walk(l) = 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "right"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
End If
If tENEMY_LEFT(r) + 38 >= tLEFT(l) And tENEMY_LEFT(r) + 38 <= tLEFT(l) + 40 And tENEMY_TOP(r) + 35 - wSPEED >= tTOP(l) And tENEMY_TOP(r) + 35 - wSPEED <= tTOP(l) + 40 And walk(l) = 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "right"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
End If
Next l
If tENEMY_LEFT(r) + 11 >= playerx + 11 And tENEMY_LEFT(r) + 11 <= playerx + 38 And tENEMY_TOP(r) + 35 <= playery + 50 And tENEMY_TOP(r) + 35 >= playery + 35 Then Call damien_hit_up
If tENEMY_LEFT(r) + 38 >= playerx + 11 And tENEMY_LEFT(r) + 38 <= playerx + 38 And tENEMY_TOP(r) + 35 <= playery + 50 And tENEMY_TOP(r) + 35 >= playery + 35 Then Call damien_hit_up
End If

If tENEMY_DIRECTION(r) = "right" Then
For l = 0 To 254
If tENEMY_LEFT(r) + 38 + wSPEED >= tLEFT(l) And tENEMY_LEFT(r) + 38 + wSPEED <= tLEFT(l) + 40 And tENEMY_TOP(r) + 35 >= tTOP(l) And tENEMY_TOP(r) + 35 <= tTOP(l) + 40 And walk(l) = 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "up"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
End If
If tENEMY_LEFT(r) + 38 + wSPEED >= tLEFT(l) And tENEMY_LEFT(r) + 38 + wSPEED <= tLEFT(l) + 40 And tENEMY_TOP(r) + 50 >= tTOP(l) And tENEMY_TOP(r) + 50 <= tTOP(l) + 40 And walk(l) = 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "up"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
End If
Next l
If tENEMY_LEFT(r) + 38 >= playerx + 11 And tENEMY_LEFT(r) + 38 <= playerx + 38 And tENEMY_TOP(r) + 35 <= playery + 50 And tENEMY_TOP(r) + 35 >= playery + 35 Then Call damien_hit_right
If tENEMY_LEFT(r) + 38 >= playerx + 11 And tENEMY_LEFT(r) + 38 <= playerx + 38 And tENEMY_TOP(r) + 50 <= playery + 50 And tENEMY_TOP(r) + 50 >= playery + 35 Then Call damien_hit_right
End If

If tENEMY_DIRECTION(r) = "down" Then
For l = 0 To 254
If tENEMY_LEFT(r) + 11 >= tLEFT(l) And tENEMY_LEFT(r) + 11 <= tLEFT(l) + 40 And tENEMY_TOP(r) + 50 + wSPEED >= tTOP(l) And tENEMY_TOP(r) + 50 + wSPEED <= tTOP(l) + 40 And walk(l) = 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "up"
If direct = 2 Then tENEMY_DIRECTION(r) = "right"
End If
If tENEMY_LEFT(r) + 38 >= tLEFT(l) And tENEMY_LEFT(r) + 38 <= tLEFT(l) + 40 And tENEMY_TOP(r) + 50 + wSPEED >= tTOP(l) And tENEMY_TOP(r) + 50 + wSPEED <= tTOP(l) + 40 And walk(l) = 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "up"
If direct = 2 Then tENEMY_DIRECTION(r) = "right"
End If
Next l
If tENEMY_LEFT(r) + 38 >= playerx + 11 And tENEMY_LEFT(r) + 38 <= playerx + 38 And tENEMY_TOP(r) + 50 <= playery + 50 And tENEMY_TOP(r) + 50 >= playery + 35 Then Call damien_hit_down
If tENEMY_LEFT(r) + 11 >= playerx + 11 And tENEMY_LEFT(r) + 11 <= playerx + 38 And tENEMY_TOP(r) + 50 <= playery + 50 And tENEMY_TOP(r) + 50 >= playery + 35 Then Call damien_hit_down
End If

If tENEMY_LEFT(r) < 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "up"
If direct = 1 Then tENEMY_DIRECTION(r) = "right"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
tENEMY_LEFT(r) = 1
End If
If tENEMY_LEFT(r) + 50 > frmMain.picRefresh.ScaleWidth Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "up"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
tENEMY_LEFT(r) = frmMain.picRefresh.ScaleWidth - 51
End If
If tENEMY_TOP(r) < 0 Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "right"
If direct = 2 Then tENEMY_DIRECTION(r) = "down"
tENEMY_TOP(r) = 1
End If
If tENEMY_TOP(r) + 50 > frmMain.picRefresh.ScaleHeight Then
direct = Int(3 * Rnd)
If direct = 0 Then tENEMY_DIRECTION(r) = "left"
If direct = 1 Then tENEMY_DIRECTION(r) = "up"
If direct = 2 Then tENEMY_DIRECTION(r) = "right"
tENEMY_TOP(r) = frmMain.picRefresh.ScaleHeight - 51
End If

If tENEMY_DIRECTION(r) = "left" Then
tENEMY_frameX(r) = fLEFT
tENEMY_frameY(r) = tENEMY_frameY(r) + 50
If tENEMY_frameY(r) >= 400 Then tENEMY_frameY(r) = 0
tENEMY_LEFT(r) = tENEMY_LEFT(r) - eSPEED
End If

If tENEMY_DIRECTION(r) = "up" Then
tENEMY_frameX(r) = fLEFT
tENEMY_frameY(r) = tENEMY_frameY(r) + 50
If tENEMY_frameY(r) >= 400 Then tENEMY_frameY(r) = 0
tENEMY_TOP(r) = tENEMY_TOP(r) - eSPEED
End If

If tENEMY_DIRECTION(r) = "right" Then
tENEMY_frameX(r) = fLEFT
tENEMY_frameY(r) = tENEMY_frameY(r) + 50
If tENEMY_frameY(r) >= 400 Then tENEMY_frameY(r) = 0
tENEMY_LEFT(r) = tENEMY_LEFT(r) + eSPEED
End If

If tENEMY_DIRECTION(r) = "down" Then
tENEMY_frameX(r) = fLEFT
tENEMY_frameY(r) = tENEMY_frameY(r) + 50
If tENEMY_frameY(r) >= 400 Then tENEMY_frameY(r) = 0
tENEMY_TOP(r) = tENEMY_TOP(r) + eSPEED
End If

a = BitBlt(frmMain.picMain.hdc, tENEMY_LEFT(r), tENEMY_TOP(r), 50, 50, frmTiles.picSoldier.hdc, tENEMY_frameX(r) + 50, tENEMY_frameY(r), SRCAND)
a = BitBlt(frmMain.picMain.hdc, tENEMY_LEFT(r), tENEMY_TOP(r), 50, 50, frmTiles.picSoldier.hdc, tENEMY_frameX(r), tENEMY_frameY(r), SRCINVERT)
End If

Next r

a = BitBlt(frmMain.picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex + 50, framey, SRCAND)
a = BitBlt(frmMain.picMain.hdc, playerx, playery, 50, 50, frmTiles.picDamien.hdc, framex, framey, SRCINVERT)

frmMain.picMain.Refresh
End Sub
Private Sub tmrMusic_Timer()
If chkMusic.Value = 1 Then
If music.Position = music.Length Then
music.Command = "Stop"
music.Command = "Close"
music.filename = App.Path & "\zelda.mid"
music.Command = "Open"
music.Command = "Play"
End If
End If
End Sub


⌨️ 快捷键说明

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