Заставка

Программирование на старых и современных языках, а так-же дизайн

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.



2D игра уровень 1

Сообщений 1 страница 3 из 3

1

Файл frmlevel0.frm:

Код:
VERSION 5.00
Begin VB.Form frmLevel0 
   BorderStyle     =   0  'None
   Caption         =   "Уровень 2"
   ClientHeight    =   7200
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   9600
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   MousePointer    =   99  'Custom
   Picture         =   "frmlevel0.frx":0000
   ScaleHeight     =   480
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   640
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.PictureBox PictWindows 
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BorderStyle     =   0  'None
      Height          =   2715
      Index           =   2
      Left            =   8280
      MousePointer    =   99  'Custom
      Picture         =   "frmlevel0.frx":E1042
      ScaleHeight     =   2715
      ScaleWidth      =   1005
      TabIndex        =   5
      Top             =   3600
      Visible         =   0   'False
      Width           =   1005
   End
   Begin VB.PictureBox PictWindows 
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BorderStyle     =   0  'None
      Height          =   2715
      Index           =   1
      Left            =   4080
      MousePointer    =   99  'Custom
      Picture         =   "frmlevel0.frx":EA0C0
      ScaleHeight     =   2715
      ScaleWidth      =   1170
      TabIndex        =   4
      Top             =   3840
      Visible         =   0   'False
      Width           =   1170
   End
   Begin VB.Timer Timer2 
      Left            =   2040
      Top             =   2040
   End
   Begin VB.Timer Timer1 
      Left            =   1200
      Top             =   1920
   End
   Begin VB.PictureBox picCursor 
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      Height          =   540
      Left            =   3480
      Picture         =   "frmlevel0.frx":F47DE
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   1
      Top             =   360
      Visible         =   0   'False
      Width           =   540
   End
   Begin VB.PictureBox PictWindows 
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BorderStyle     =   0  'None
      Height          =   2655
      Index           =   0
      Left            =   1080
      MousePointer    =   99  'Custom
      Picture         =   "frmlevel0.frx":F4930
      ScaleHeight     =   2655
      ScaleWidth      =   930
      TabIndex        =   0
      Top             =   3360
      Visible         =   0   'False
      Width           =   930
   End
   Begin VB.Label lbClose 
      BackStyle       =   0  'Transparent
      Caption         =   "X"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   9360
      MousePointer    =   1  'Arrow
      TabIndex        =   3
      Top             =   0
      Width           =   375
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Очки:0"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   24
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   4200
      TabIndex        =   2
      Top             =   0
      Width           =   5295
   End
End
Attribute VB_Name = "frmLevel0"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Const SND_ASYNC = &H1         '  play asynchronously
Const SND_SYNC = &H0         '  play synchronously (default)
Dim i As Long, n As Long, res As Long
Dim what_cols(10) As Boolean
Dim col As Long, curr As Long
Dim scores As Long, Lives As Long
Dim ObjDx As DirectX7
Dim ObjDraw As DirectDraw7
Dim max_v As Long
Private Const SRCCOPY = &HCC0020
Private Const SRCAND = &H8800C6
Private Const SRCERASE = &H440328
Private Const SRCINVERT = &H660046
Private Const SRCPAINT = &HEE0086


Private Sub Form_Load()
Dim j As Long
'    Set ObjDx = New DirectX7
'    Set ObjDraw = ObjDx.DirectDrawCreate("")
'    ObjDraw.SetCooperativeLevel frmLevel0.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE
'    ObjDraw.SetDisplayMode 640, 480, 16, 0, DDSDM_DEFAULT
    For j = 0 To Me.PictWindows.Count - 1
      BitBlt Me.PictWindows(j), Me.PictWindows(j).Left, Me.PictWindows(j).Top, Me.PictWindows(j).Width, Me.PictWindows(j).Height, Me.hDC, 0, 0, SRCCOPY
    Next j
    max_v = 3
    Lives = 5
    Me.MouseIcon = Me.picCursor.Picture
    For j = 0 To Me.PictWindows.Count - 1
        Me.PictWindows(j).Visible = True
        Me.PictWindows(j).MouseIcon = Me.picCursor.Picture
        Me.PictWindows(j).Picture = Me.picCursor.Picture
        what_cols(j) = False
    Next j
    col = 1
    Timer1.Interval = 1000
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    sndPlaySound App.Path & "\gunshot.wav", SND_ASYNC
    scores = scores - 10
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    Timer2.Enabled = False
End Sub


Private Sub lbClose_Click()
    Unload Me
End Sub

Private Sub PictWindows_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
Dim j As Long
    sndPlaySound App.Path & "\gunshot.wav", SND_ASYNC
    If what_cols(Index) = True Then
        scores = scores + 10
        Timer2.Enabled = False
    Else
        scores = scores - 10
    End If
    For j = 0 To Me.PictWindows.Count - 1
        Me.PictWindows(j).Visible = True
        Me.PictWindows(j).MouseIcon = Me.picCursor.Picture
        Me.PictWindows(j).Picture = Me.Picture1.Picture
    Next j
End Sub

Private Sub PictWindows_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
    Timer2.Enabled = True
    Timer2.Interval = Timer1.Interval + 100
    curr = Index
End Sub

Private Sub PictWindows_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
Dim j As Long
    For j = 0 To Me.PictWindows.Count - 1
        what_cols(j) = False
    Next j
End Sub

Private Sub Timer1_Timer()
Dim j As Long
    For j = 0 To Me.PictWindows.Count - 1
        Me.PictWindows(j).Visible = True
        Me.PictWindows(j).MouseIcon = Me.picCursor.Picture
        Me.PictWindows(j).Picture = Me.picCursor.Picture
    Next j
    For i = 1 To col
        res = Int(Rnd * max_v)
        Me.PictWindows(res) = Me.picSoldat.Picture
        what_cols(res) = True
    Next i
    For j = 0 To 5000
        Sin 0.5
        Timer1.Enabled = False
    Next j
    Timer1.Enabled = True
    Me.Label1.Caption = "Очки:" & scores & "  Жизней:" & Lives
End Sub

Private Sub Timer2_Timer()
Dim j As Long
    Me.PictWindows(res).Picture = Me.picSoldat.Picture
    Timer2.Enabled = False
    sndPlaySound App.Path & "\explode.wav", SND_ASYNC
    Me.PictWindows(res) = Me.picSoldatFire.Picture
    Lives = Lives - 1
End Sub

0

2

Файл Project1.vbp:

Код:
Type=Exe
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\System32\stdole2.tlb#OLE Automation
Object={0E59F1D2-1FBE-11D0-8FF2-00A0D10038BC}#1.0#0; msscript.ocx
Reference=*\G{E1211242-8E94-11D1-8808-00C04FC2C602}#1.0#0#C:\WINDOWS\System32\dx7vb.dll#DirectX 7 for Visual Basic Type Library
Form=frmlevel0.frm
Startup="frmLevel0"
HelpFile=""
ExeName32="Level2.exe"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="PIN"
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

0

3

Файл Project1.vbw:

Код:
frmLevel0 = 44, 44, 384, 334, Z, 22, 22, 362, 312, C

0