Вход на сайт
2D движок на VB 6.0 30.05.2025
129 просмотров
Перейти к просмотру всей ветки
в ответ uscheswoi_82 30.05.25 23:39
Пример
Файл frmMain.frm:
VERSION 5.00 Object = "{117023D9-0FFE-49F3-8203-5B62AA0043FF}#34.0#0"; "GameEngine.ocx" Begin VB.Form frmMain Caption = "Form1" ClientHeight = 3840 ClientLeft = 60 ClientTop = 345 ClientWidth = 5205 LinkTopic = "Form1" ScaleHeight = 256 ScaleMode = 3 'Pixel ScaleWidth = 347 StartUpPosition = 3 'Windows Default Begin VB.Timer tmTimer2 Left = 960 Top = 1800 End Begin VB.CommandButton cmdGo Caption = "&Go" Height = 495 Left = 3960 TabIndex = 1 Top = 3240 Width = 1095 End Begin VB.Timer tmTimer Left = 2280 Top = 600 End Begin GameEngine.Sprite Sprite1 Height = 495 Left = 0 TabIndex = 0 Top = 0 Width = 495 _ExtentX = 873 _ExtentY = 873 End Begin GameEngine.Sprite Sprite2 Height = 495 Left = 720 TabIndex = 2 Top = 0 Width = 495 _ExtentX = 873 _ExtentY = 873 End Begin GameEngine.Sprite SpriteBackground Height = 495 Left = 1320 TabIndex = 3 Top = 0 Width = 495 _ExtentX = 873 _ExtentY = 873 End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim x1 As Integer Private Sub cmdGo_Click() Me.tmTimer.Enabled = True Me.tmTimer.Interval = 100 Me.tmTimer2.Enabled = True Me.tmTimer2.Interval = 1000 x1 = 10 End Sub Private Sub Form_Load() Sprite1.Visible = False Sprite1.SpriteFileName = "C:\GAMEENGINE\TEST\audio.bmp" Sprite1.MaskSpriteFileName = "C:\GAMEENGINE\TEST\audio_mask2.bmp" Sprite1.SoundFileName = "C:\GAMEENGINE\TEST\ding.wav" Sprite1.Init Sprite2.Visible = False Sprite2.SpriteFileName = "C:\GAMEENGINE\TEST\audio.bmp" Sprite2.MaskSpriteFileName = "C:\GAMEENGINE\TEST\audio_mask2.bmp" Sprite2.SoundFileName = "C:\GAMEENGINE\TEST\ding.wav" Sprite2.Init SpriteBackground.Visible = False SpriteBackground.BackgroundFileName = "C:\GAMEENGINE\TEST\bg.bmp" SpriteBackground.Init 'Sprite1.StartCollisionDetection Sprite2 End Sub Private Sub Sprite1_Collision() Sprite1.StopCollisionDetection Me.tmTimer.Enabled = False Me.tmTimer2.Enabled = False MsgBox "YES!" End Sub Private Sub tmTimer_Timer() x1 = x1 + 1 Me.Cls SpriteBackground.DrawBackground hDC, 0, 0, 283, 212 Sprite2.DrawSpriteAt Me.hDC, 50, 10, 40, 40 Sprite1.DrawSpriteAt Me.hDC, x1, 10, 40, 40 End Sub Private Sub tmTimer2_Timer() Sprite1.PlaySound End Sub
Файл Test.vbp:
Type=Exe Form=frmMain.frm Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\WINNT\System32\stdole2.tlb#OLE Automation Object={117023D9-0FFE-49F3-8203-5B62AA0043FF}#34.0#0; GameEngine.ocx IconForm="frmMain" Startup="frmMain" Command32="" Name="Test" HelpContextID="0" CompatibleMode="0" MajorVer=1 MinorVer=0 RevisionVer=0 AutoIncrementVer=0 ServerSupportFiles=0 CompilationType=0 OptimizationType=0 FavorPentiumPro(tm)=0 CodeViewDebugInfo=0 NoAliasing=0 BoundsCheck=0 OverflowCheck=0 FlPointCheck=0 FDIVCheck=0 UnroundedFP=0 StartMode=0 Unattended=0 Retained=0 ThreadPerObject=0 MaxNumberOfThreads=1 [MS Transaction Server] AutoRefresh=1
Файл Test.vbw:
frmMain = 44, 44, 1268, 534, , 154, 154, 1378, 644, C
Результат работы:
Ссылка на видео со звуком как работает 2D движок см. https://my.mail.ru/mail/semyon_kulikov/video/_myvideo/118....
Если я кому-то отвечаю, это не значит что я ему симпатизирую, каждый остаётся при своём мнение