home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD5394512000.psc / GForm.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-05-02  |  15.0 KB  |  482 lines

  1. VERSION 5.00
  2. Begin VB.Form GForm 
  3.    Caption         =   "Invasion - By Simon Price"
  4.    ClientHeight    =   5352
  5.    ClientLeft      =   48
  6.    ClientTop       =   288
  7.    ClientWidth     =   7176
  8.    KeyPreview      =   -1  'True
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   446
  11.    ScaleMode       =   3  'Pixel
  12.    ScaleWidth      =   598
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.Timer AddMoreMayhem 
  15.       Interval        =   4000
  16.       Left            =   960
  17.       Top             =   2880
  18.    End
  19.    Begin VB.PictureBox UFOPic 
  20.       AutoRedraw      =   -1  'True
  21.       BackColor       =   &H00FFFFFF&
  22.       BorderStyle     =   0  'None
  23.       ClipControls    =   0   'False
  24.       DrawWidth       =   10
  25.       Height          =   360
  26.       Index           =   5
  27.       Left            =   3240
  28.       Picture         =   "GForm.frx":0000
  29.       ScaleHeight     =   30
  30.       ScaleMode       =   3  'Pixel
  31.       ScaleWidth      =   50
  32.       TabIndex        =   12
  33.       Top             =   2880
  34.       Visible         =   0   'False
  35.       Width           =   600
  36.    End
  37.    Begin VB.PictureBox UFOPic 
  38.       AutoRedraw      =   -1  'True
  39.       BackColor       =   &H00FFFFFF&
  40.       BorderStyle     =   0  'None
  41.       ClipControls    =   0   'False
  42.       DrawWidth       =   10
  43.       Height          =   360
  44.       Index           =   4
  45.       Left            =   3240
  46.       Picture         =   "GForm.frx":0A5A
  47.       ScaleHeight     =   30
  48.       ScaleMode       =   3  'Pixel
  49.       ScaleWidth      =   50
  50.       TabIndex        =   11
  51.       Top             =   2400
  52.       Visible         =   0   'False
  53.       Width           =   600
  54.    End
  55.    Begin VB.PictureBox UFOPic 
  56.       AutoRedraw      =   -1  'True
  57.       BackColor       =   &H00FFFFFF&
  58.       BorderStyle     =   0  'None
  59.       ClipControls    =   0   'False
  60.       DrawWidth       =   10
  61.       Height          =   360
  62.       Index           =   3
  63.       Left            =   3240
  64.       Picture         =   "GForm.frx":14B4
  65.       ScaleHeight     =   30
  66.       ScaleMode       =   3  'Pixel
  67.       ScaleWidth      =   50
  68.       TabIndex        =   10
  69.       Top             =   1920
  70.       Visible         =   0   'False
  71.       Width           =   600
  72.    End
  73.    Begin VB.PictureBox UFOPic 
  74.       AutoRedraw      =   -1  'True
  75.       BackColor       =   &H00FFFFFF&
  76.       BorderStyle     =   0  'None
  77.       ClipControls    =   0   'False
  78.       DrawWidth       =   10
  79.       Height          =   360
  80.       Index           =   2
  81.       Left            =   3240
  82.       Picture         =   "GForm.frx":1F0E
  83.       ScaleHeight     =   30
  84.       ScaleMode       =   3  'Pixel
  85.       ScaleWidth      =   50
  86.       TabIndex        =   9
  87.       Top             =   1440
  88.       Visible         =   0   'False
  89.       Width           =   600
  90.    End
  91.    Begin VB.PictureBox UFOPic 
  92.       AutoRedraw      =   -1  'True
  93.       BackColor       =   &H00FFFFFF&
  94.       BorderStyle     =   0  'None
  95.       ClipControls    =   0   'False
  96.       DrawWidth       =   10
  97.       Height          =   360
  98.       Index           =   1
  99.       Left            =   3240
  100.       Picture         =   "GForm.frx":2968
  101.       ScaleHeight     =   30
  102.       ScaleMode       =   3  'Pixel
  103.       ScaleWidth      =   50
  104.       TabIndex        =   8
  105.       Top             =   960
  106.       Visible         =   0   'False
  107.       Width           =   600
  108.    End
  109.    Begin VB.PictureBox UFOMask 
  110.       AutoRedraw      =   -1  'True
  111.       BackColor       =   &H00FFFFFF&
  112.       BorderStyle     =   0  'None
  113.       ClipControls    =   0   'False
  114.       DrawWidth       =   10
  115.       Height          =   360
  116.       Left            =   4200
  117.       Picture         =   "GForm.frx":33C2
  118.       ScaleHeight     =   30
  119.       ScaleMode       =   3  'Pixel
  120.       ScaleWidth      =   50
  121.       TabIndex        =   7
  122.       Top             =   1200
  123.       Visible         =   0   'False
  124.       Width           =   600
  125.    End
  126.    Begin VB.PictureBox BulletMask 
  127.       AutoRedraw      =   -1  'True
  128.       BackColor       =   &H00FFFFFF&
  129.       BorderStyle     =   0  'None
  130.       ClipControls    =   0   'False
  131.       DrawWidth       =   10
  132.       Height          =   120
  133.       Left            =   4920
  134.       Picture         =   "GForm.frx":3E1C
  135.       ScaleHeight     =   10
  136.       ScaleMode       =   3  'Pixel
  137.       ScaleWidth      =   10
  138.       TabIndex        =   6
  139.       Top             =   600
  140.       Visible         =   0   'False
  141.       Width           =   120
  142.    End
  143.    Begin VB.PictureBox BulletPic 
  144.       AutoRedraw      =   -1  'True
  145.       BackColor       =   &H00FFFFFF&
  146.       BorderStyle     =   0  'None
  147.       ClipControls    =   0   'False
  148.       DrawWidth       =   10
  149.       Height          =   120
  150.       Index           =   5
  151.       Left            =   4200
  152.       Picture         =   "GForm.frx":42D6
  153.       ScaleHeight     =   10
  154.       ScaleMode       =   3  'Pixel
  155.       ScaleWidth      =   10
  156.       TabIndex        =   5
  157.       Top             =   600
  158.       Visible         =   0   'False
  159.       Width           =   120
  160.    End
  161.    Begin VB.PictureBox BulletPic 
  162.       AutoRedraw      =   -1  'True
  163.       BackColor       =   &H00FFFFFF&
  164.       BorderStyle     =   0  'None
  165.       ClipControls    =   0   'False
  166.       DrawWidth       =   10
  167.       Height          =   120
  168.       Index           =   4
  169.       Left            =   3960
  170.       Picture         =   "GForm.frx":4790
  171.       ScaleHeight     =   10
  172.       ScaleMode       =   3  'Pixel
  173.       ScaleWidth      =   10
  174.       TabIndex        =   4
  175.       Top             =   600
  176.       Visible         =   0   'False
  177.       Width           =   120
  178.    End
  179.    Begin VB.PictureBox BulletPic 
  180.       AutoRedraw      =   -1  'True
  181.       BackColor       =   &H00FFFFFF&
  182.       BorderStyle     =   0  'None
  183.       ClipControls    =   0   'False
  184.       DrawWidth       =   10
  185.       Height          =   120
  186.       Index           =   3
  187.       Left            =   3720
  188.       Picture         =   "GForm.frx":4C4A
  189.       ScaleHeight     =   10
  190.       ScaleMode       =   3  'Pixel
  191.       ScaleWidth      =   10
  192.       TabIndex        =   3
  193.       Top             =   600
  194.       Visible         =   0   'False
  195.       Width           =   120
  196.    End
  197.    Begin VB.PictureBox BulletPic 
  198.       AutoRedraw      =   -1  'True
  199.       BackColor       =   &H00FFFFFF&
  200.       BorderStyle     =   0  'None
  201.       ClipControls    =   0   'False
  202.       DrawWidth       =   10
  203.       Height          =   120
  204.       Index           =   2
  205.       Left            =   3480
  206.       Picture         =   "GForm.frx":5104
  207.       ScaleHeight     =   10
  208.       ScaleMode       =   3  'Pixel
  209.       ScaleWidth      =   10
  210.       TabIndex        =   2
  211.       Top             =   600
  212.       Visible         =   0   'False
  213.       Width           =   120
  214.    End
  215.    Begin VB.PictureBox BulletPic 
  216.       AutoRedraw      =   -1  'True
  217.       BackColor       =   &H00FFFFFF&
  218.       BorderStyle     =   0  'None
  219.       ClipControls    =   0   'False
  220.       DrawWidth       =   10
  221.       Height          =   120
  222.       Index           =   1
  223.       Left            =   3240
  224.       Picture         =   "GForm.frx":55BE
  225.       ScaleHeight     =   10
  226.       ScaleMode       =   3  'Pixel
  227.       ScaleWidth      =   10
  228.       TabIndex        =   1
  229.       Top             =   600
  230.       Visible         =   0   'False
  231.       Width           =   120
  232.    End
  233.    Begin VB.PictureBox PB 
  234.       AutoRedraw      =   -1  'True
  235.       BackColor       =   &H00000000&
  236.       BorderStyle     =   0  'None
  237.       ClipControls    =   0   'False
  238.       DrawWidth       =   10
  239.       FillColor       =   &H000000FF&
  240.       FillStyle       =   0  'Solid
  241.       ForeColor       =   &H000000FF&
  242.       Height          =   2292
  243.       Left            =   120
  244.       ScaleHeight     =   191
  245.       ScaleMode       =   3  'Pixel
  246.       ScaleWidth      =   201
  247.       TabIndex        =   0
  248.       Top             =   120
  249.       Visible         =   0   'False
  250.       Width           =   2412
  251.    End
  252. Attribute VB_Name = "GForm"
  253. Attribute VB_GlobalNameSpace = False
  254. Attribute VB_Creatable = False
  255. Attribute VB_PredeclaredId = True
  256. Attribute VB_Exposed = False
  257. Private DispWidth As Integer
  258. Private DispHeight As Integer
  259. Private ExitLoop As Boolean
  260. Private Sub AddMoreMayhem_Timer()
  261. i = UBound(Invader) + 1
  262. ReDim Preserve Invader(1 To i)
  263.   Invader(i).X = (Rnd * 500) + 50
  264.   Invader(i).Y = -(Rnd * 10)
  265.   Invader(i).xm = Int(Rnd * 10) - 5
  266.   Invader(i).ym = 5
  267.   Invader(i).Frame = Int(Rnd * 5) + 1
  268. End Sub
  269. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  270. Select Case KeyCode
  271.   Case vbKeyEscape
  272.     ExitLoop = True
  273.     SForm.Visible = True
  274.     Unload Me
  275.   Case vbKeyLeft
  276.     Shooter.Angle = Shooter.Angle + 10
  277.   Case vbKeyRight
  278.     Shooter.Angle = Shooter.Angle - 10
  279.   Case vbKeySpace
  280.     If BulletNo = BULLETS Then
  281.       BulletNo = 1
  282.     Else
  283.     BulletNo = BulletNo + 1
  284.     End If
  285.         Bullet(BulletNo).X = 300
  286.         Bullet(BulletNo).Y = 450
  287.         Bullet(BulletNo).xm = -20 * Sin(Shooter.Angle * PIdiv180)
  288.         Bullet(BulletNo).ym = -20 * Cos(Shooter.Angle * PIdiv180)
  289.   Case vbKeyC
  290.     PB.Picture = PB.Image
  291.     SavePicture PB.Picture, App.Path & "/Pic.bmp"
  292.     PB.Picture = LoadPicture()
  293. End Select
  294. End Sub
  295. Private Sub Form_Load()
  296. Randomize Timer
  297. SortLayout
  298. CreateStars
  299. CreateInvaders
  300. MainLoop
  301. End Sub
  302. Public Sub MainLoop()
  303. DoEvents
  304. PB.Cls
  305. If StarsOn Then DoStars
  306. DoShooter
  307. DoInvaders
  308. DoBullets
  309. DoExplosions
  310. StretchBlt hdc, 0, 0, DispWidth, DispHeight, PB.hdc, 0, 0, 600, 450, vbSrcCopy
  311. Loop Until ExitLoop = True
  312. End Sub
  313. Private Sub SortLayout()
  314. Move 0, 0, Screen.Width, Screen.Height
  315. PB.Move 0, 0, 600, 450
  316. DispWidth = Screen.Height * 1.315 / Screen.TwipsPerPixelY
  317. DispHeight = Screen.Height * 0.975 / Screen.TwipsPerPixelY
  318. ScaleWidth = 180
  319. ScaleHeight = 100
  320. End Sub
  321. Private Sub CreateStars()
  322. For i = 1 To WHITESTARS
  323.   WhiteStar(i).X = Rnd * 600
  324.   WhiteStar(i).Y = Rnd * 450
  325. For i = 1 To CYANSTARS
  326.   CyanStar(i).X = Rnd * 600
  327.   CyanStar(i).Y = Rnd * 450
  328. For i = 1 To YELLOWSTARS
  329.   YellowStar(i).X = Rnd * 600
  330.   YellowStar(i).Y = Rnd * 450
  331. For i = 1 To REDSTARS
  332.   RedStar(i).X = Rnd * 600
  333.   RedStar(i).Y = Rnd * 450
  334. End Sub
  335. Private Sub CreateInvaders()
  336. Difficulty = 5
  337. ReDim Invader(1 To 5)
  338. For i = 1 To 5
  339.   Invader(i).X = (Rnd * 500) + 50
  340.   Invader(i).Y = -(Rnd * 10)
  341.   Invader(i).xm = Int(Rnd * 10) - 5
  342.   Invader(i).ym = 5
  343.   Invader(i).Frame = Int(Rnd * 5) + 1
  344. End Sub
  345. Private Sub DoExplosions()
  346. PB.DrawWidth = 1
  347. For i = 1 To EXPLOSIONS
  348. If Explosion(i).Power <> 0 Then
  349.     Explosion(i).Power = Explosion(i).Power - 1
  350.     For i2 = 1 To Explosion(i).Power
  351.       MoveToEx PB.hdc, Explosion(i).Pixel(i2).X, Explosion(i).Pixel(i2).Y, lpPoint
  352.       Explosion(i).Pixel(i2).X = Explosion(i).Pixel(i2).X + Explosion(i).Pixel(i2).xm
  353.       Explosion(i).Pixel(i2).Y = Explosion(i).Pixel(i2).Y + Explosion(i).Pixel(i2).ym
  354.       PB.ForeColor = Explosion(i).Pixel(i2).Color
  355.       LineTo PB.hdc, Explosion(i).Pixel(i2).X, Explosion(i).Pixel(i2).Y
  356.     Next
  357. End If
  358. End Sub
  359. Private Sub CreateExplosion()
  360. 'uncomment this line below for explosion sounds!!!
  361. 'sndPlaySound App.Path & "\Explode.wav", &H1
  362. If ExplosionNo = EXPLOSIONS Then
  363.   ExplosionNo = 1
  364.   ExplosionNo = ExplosionNo + 1
  365. End If
  366. Explosion(ExplosionNo).Power = EXPLOSIONPOWER
  367. For i3 = 1 To EXPLOSIONPOWER
  368.   Explosion(ExplosionNo).Pixel(i3).X = X
  369.   Explosion(ExplosionNo).Pixel(i3).Y = Y
  370.   Explosion(ExplosionNo).Pixel(i3).xm = (Rnd * 20) - 10
  371.   Explosion(ExplosionNo).Pixel(i3).ym = (Rnd * 20) - 10
  372.     Select Case Int(Rnd * 4)
  373.       Case 0: Explosion(ExplosionNo).Pixel(i3).Color = vbWhite
  374.       Case 1: Explosion(ExplosionNo).Pixel(i3).Color = vbYellow
  375.       Case 2: Explosion(ExplosionNo).Pixel(i3).Color = vbCyan
  376.       Case 3: Explosion(ExplosionNo).Pixel(i3).Color = vbRed
  377.     End Select
  378. End Sub
  379. Private Sub DoInvaders()
  380. For i = 1 To UBound(Invader)
  381.     If Invader(i).Frame = 5 Then
  382.       Invader(i).Frame = 1
  383.     Else
  384.       Invader(i).Frame = Invader(i).Frame + 1
  385.     End If
  386.   X = Invader(i).X + Invader(i).xm
  387.   Y = Invader(i).Y + Invader(i).ym
  388.     Select Case X
  389.       Case Is < 0
  390.         Invader(i).xm = -Invader(i).xm
  391.       Case Is > 600
  392.         Invader(i).xm = -Invader(i).xm
  393.       Case Else
  394.         Invader(i).X = X
  395.     End Select
  396.     Select Case Y
  397.       Case Is > 450
  398.         MsgBox "Game Over - the invaders have invaded!!!", vbExclamation, "U IS DEAD!"
  399.         ExitLoop = True
  400.         End
  401.       Case Else
  402.         Invader(i).Y = Y
  403.     End Select
  404.         BitBlt PB.hdc, Invader(i).X - 25, Invader(i).Y - 15, 50, 30, UFOMask.hdc, 0, 0, vbMergePaint
  405.         BitBlt PB.hdc, Invader(i).X - 25, Invader(i).Y - 15, 50, 30, UFOPic(Invader(i).Frame).hdc, 0, 0, vbSrcAnd
  406. End Sub
  407. Private Sub DoShooter()
  408. PB.DrawWidth = 10
  409. PB.ForeColor = vbRed
  410. MoveToEx PB.hdc, 300, 450, lpPoint
  411. SinA = Sin(Shooter.Angle * PIdiv180)
  412. CosA = Cos(Shooter.Angle * PIdiv180)
  413. LineTo PB.hdc, 300 - 50 * SinA, 450 - 50 * CosA
  414. End Sub
  415. Private Sub DoBullets()
  416. For i = 1 To BULLETS
  417.   If Bullet(i).X > 0 Then
  418.     X = Bullet(i).X + Bullet(i).xm
  419.     Y = Bullet(i).Y + Bullet(i).ym
  420.   For i2 = 1 To UBound(Invader)
  421.     Select Case Invader(i2).X
  422.       Case X - 30 To X + 30
  423.         Select Case Invader(i2).Y
  424.           Case Y - 20 To Y + 20
  425.             Invader(i2).X = (Rnd * 500) + 50
  426.             Invader(i2).Y = (Rnd * 100) - 100
  427.             Invader(i2).xm = Int(Rnd * 10) - 5
  428.             Invader(i2).ym = Difficulty
  429.             Shooter.Score = Shooter.Score + Invader(i2).Y
  430.             Caption = "Invasion - By Simon Price - Score = " & -Shooter.Score & " points"
  431.             CreateExplosion
  432.         End Select
  433.     End Select
  434.   Next
  435.   Bullet(i).X = X
  436.   Bullet(i).Y = Y
  437.     BitBlt PB.hdc, Bullet(i).X - 5, Bullet(i).Y - 5, 10, 10, BulletMask.hdc, 0, 0, vbMergePaint
  438.     BitBlt PB.hdc, Bullet(i).X - 5, Bullet(i).Y - 5, 10, 10, BulletPic((i Mod 5) + 1).hdc, 0, 0, vbSrcAnd
  439. End If
  440. End Sub
  441. Private Sub DoStars()
  442. 'white stars
  443. For i = 1 To WHITESTARS
  444.   If WhiteStar(i).Y > 600 Then
  445.     WhiteStar(i).X = Rnd * 600
  446.     WhiteStar(i).Y = 0
  447.   Else
  448.   WhiteStar(i).Y = WhiteStar(i).Y + 2
  449.   SetPixel PB.hdc, WhiteStar(i).X, WhiteStar(i).Y, vbWhite
  450.   End If
  451. 'cyan stars
  452. For i = 1 To CYANSTARS
  453.   If CyanStar(i).Y > 600 Then
  454.     CyanStar(i).X = Rnd * 600
  455.     CyanStar(i).Y = 0
  456.   Else
  457.   CyanStar(i).Y = CyanStar(i).Y + 3
  458.   SetPixel PB.hdc, CyanStar(i).X, CyanStar(i).Y, vbCyan
  459.   End If
  460. 'yellow stars
  461. For i = 1 To YELLOWSTARS
  462.   If YellowStar(i).Y > 600 Then
  463.     YellowStar(i).X = Rnd * 600
  464.     YellowStar(i).Y = 0
  465.   Else
  466.   YellowStar(i).Y = YellowStar(i).Y + 5
  467.   SetPixel PB.hdc, YellowStar(i).X, YellowStar(i).Y, vbYellow
  468.   End If
  469. 'red stars
  470. For i = 1 To REDSTARS
  471.   If RedStar(i).Y > 600 Then
  472.     RedStar(i).X = Rnd * 600
  473.     RedStar(i).Y = 0
  474.   Else
  475.   RedStar(i).Y = RedStar(i).Y + 8
  476.   SetPixel PB.hdc, RedStar(i).X, RedStar(i).Y, vbRed
  477.   End If
  478. End Sub
  479. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  480. Shooter.Angle = 90 - X
  481. End Sub
  482.