Important alert: (current site time 7/16/2013 4:12:39 AM EDT)
 

VB icon

Duck Shoot Game

Email
Submitted on: 4/6/1999
By: Ed Hockaday 
Level: Not Given
User Rating: By 101 Users
Compatibility: VB 5.0, VB 6.0
Views: 27459
 
     Create your own duck shoot style game, you can even kill your best buddy, just get a picture of him!!!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Duck Shoot Game
' Description:Create your own duck shoot style game, you can even kill your best buddy, just get a picture of him!!!
' By: Ed Hockaday
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1568&lngWId=1'for details.'**************************************

Leave Picture1 blank, make Picture2's picture a "kill picture" (so when the target is hit a bullet hole appears in it) and make Picture3's Picture the blank target (ie an "unwounded target")
Copy and paste this into a notepad and save as form1.frm
VERSION 5.00
Begin VB.Form Form1 
BorderStyle =4 'Fixed ToolWindow
ClientHeight=3195
ClientLeft =45
ClientTop=285
ClientWidth =4680
LinkTopic="Form1"
MaxButton=0'False
MinButton=0'False
ScaleHeight =3195
ScaleWidth =4680
ShowInTaskbar=0'False
StartUpPosition =3 'Windows Default
Begin VB.Timer tmrSeconds 
 Left=600
 Top =960
End
Begin VB.CommandButton cmdReset 
 Caption ="&Reset"
 Height =375
 Left=120
 TabIndex=5
 Top =2760
 Visible =0'False
 Width=855
End
Begin VB.PictureBox Picture3 
 Appearance =0 'Flat
 BackColor=&H00C0C0C0&
 BorderStyle =0 'None
 ForeColor=&H80000008&
 Height =495
 Left=960
 ScaleHeight =495
 ScaleWidth =495
 TabIndex=4
 Top =2040
 Visible =0'False
 Width=495
End
Begin VB.CommandButton cmdStart 
 Caption ="&Start"
 Height =375
 Left=120
 TabIndex=3
 Top =2760
 Width=855
End
Begin VB.CommandButton cmdExit 
 Caption ="&Exit"
 Height =375
 Left=3720
 TabIndex=2
 Top =2760
 Width=855
End
Begin VB.PictureBox Picture2 
 Appearance =0 'Flat
 BackColor=&H80000004&
 BorderStyle =0 'None
 ForeColor=&H80000008&
 Height =495
 Left=480
 ScaleHeight =495
 ScaleWidth =495
 TabIndex=1
 Top =2040
 Visible =0'False
 Width=495
End
Begin VB.PictureBox Picture1 
 BackColor=&H008080FF&
 BorderStyle =0 'None
 Height =495
 Left=1920
 ScaleHeight =495
 ScaleWidth =495
 TabIndex=0
 Top =1320
 Width=495
End
Begin VB.Timer Timer1 
 Interval=1
 Left=480
 Top =240
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim DeltaX
Dim DeltaY
Dim gTimerSpeed
Dim gGameOn As Boolean
Dim gHit As Boolean
Dim gSeconds
Dim gShots
Dim gTime
Private Sub cmdExit_Click()
Unload Form1
End Sub
Private Sub cmdReset_Click()
Picture1.Picture = Picture3.Picture
Screen.MousePointer = vbCrosshair
Timer1.Interval = 0
DeltaX = 100' Initialize variables.
DeltaY = 100
cmdStart.Visible = True
cmdExit.Visible = True
cmdReset.Visible = False
End Sub
Private Sub cmdStart_Click()
Picture1.Picture = Picture3.Picture
Screen.MousePointer = vbCrosshair
Timer1.Interval = 1
gTimerSpeed = 1
DeltaX = 100' Initialize variables.
DeltaY = 100
cmdReset.Visible = False
cmdStart.Visible = False
cmdExit.Visible = False
gHit = False
gShots = 0
gGameOn = True
gTime = 0
tmrSeconds.Interval = 1000
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
gShots = gShots + 1
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If gGameOn = True Then
Timer1.Interval = 0
Picture1.Picture = Picture2.Picture
Screen.MousePointer = Default
cmdReset.Visible = True
cmdExit.Visible = True
gHit = True
If gShots = 0 Then
MsgBox "It took you " & gShots + 1 & " shot and " & gTime & " seconds to kill him!"
ElseIf gShots > 0 Then
MsgBox "It took you " & gShots + 1 & " shots and " & gTime & " seconds to kill him!"
End If
gGameOn = False
tmrSeconds.Interval = 0
Exit Sub
ElseIf gGameOn = False Then
Exit Sub
End If
End Sub
Private Sub Timer1_Timer()
If gHit = True Then
Timer1.Interval = 0
Exit Sub
End If
If gTimerSpeed < 50 Then gTimerSpeed = gTimerSpeed + 1
Timer1.Interval = gTimerSpeed
Picture1.Move Picture1.Left + DeltaX, Picture1.Top + DeltaY
If Picture1.Left < ScaleLeft Then DeltaX = 100
If Picture1.Left + Picture1.Width > ScaleWidth + ScaleLeft Then
DeltaX = -100
End If
If Picture1.Top < ScaleTop Then DeltaY = 100
If Picture1.Top + Picture1.Height > ScaleHeight + ScaleTop Then
DeltaY = -100
End If
End Sub
Private Sub tmrSeconds_Timer()
gTime = gTime + 1
End Sub


Other 7 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
4/10/1999 1:39:00 PMIan Ippolito

Make sure you follow the advice
on setting pictures1,2,3 to get
the full effect!
(If this comment was disrespectful, please report it.)

 
4/13/1999 5:44:00 PMMike

Cool man! But lets see if it works!
(If this comment was disrespectful, please report it.)

 
4/15/1999 1:33:00 PMTravis

Well it works on mine... but when i shoot the guy, it doesnt change images!
(If this comment was disrespectful, please report it.)

 
4/17/1999 1:31:00 PMCaptain Needa

Is there as place where I can actually
download the entire code?
This thing is really screwing me up!
Thanx
(If this comment was disrespectful, please report it.)

 
4/19/1999 2:55:00 AMGuus van den Berg

Great, But you should add some pre-made bulletholes!

G.
(If this comment was disrespectful, please report it.)

 
4/22/1999 10:21:00 AMAdam Foulkes

i think thAT your page is realy good BUT , why the hell dont you make the actual vb files available for download in a .zip format , thats why i get my vbb stuff from other sites that have this feture , thanx
(If this comment was disrespectful, please report it.)

 
4/23/1999 7:57:00 AMseggie

What does the form look like? I am not sure how many command buttons and pic boxes this thing is supposed to have.

Any help what so ever would be appreciated.
Thanks
(If this comment was disrespectful, please report it.)

 
4/26/1999 8:30:00 AMJon Leister

how many pictures and buttons are you suppost to have and what are they suppost to be named? Also, how should the form look when it is layed out and which codes go in which buttons and stuff? Please e-mail me back real soon because I have to do this for a final project for school, and I have no idea what the hell I am doing.
(If this comment was disrespectful, please report it.)

 
4/26/1999 4:08:00 PMZuhair

Haven't tried it yet but thanx.
Hope it works
(If this comment was disrespectful, please report it.)

 
5/3/1999 5:10:00 PMDrakosnah Hurreala

Can you please send me the full source code? I'm lazy. :) Thanks! Drakosnah@Hotmail.com
(If this comment was disrespectful, please report it.)

 
5/16/1999 6:20:00 AMShawn

thanx for the codes. they're really good and helpful
(If this comment was disrespectful, please report it.)

 
7/22/1999 11:14:00 PMsmoke33

Pretty cool. :o) Works great!

-smoke33
(If this comment was disrespectful, please report it.)

 
8/12/1999 2:27:00 AMheresy

very creative... i like this. but you should post this
(with all forms, etc.) in ZIP format! and if you want, even compile
it while you're at it! thanks!
(If this comment was disrespectful, please report it.)

 
9/25/1999 3:02:00 PMJuuh

Something like "ZIP"???!!!!!
(If this comment was disrespectful, please report it.)

 
2/22/2000 8:09:20 PMvbproggyboy

that is pretty cool. Good Job..The shots missed it messed up a little bit but that is alright!!Good Job

(If this comment was disrespectful, please report it.)

 
6/8/2005 10:52:35 PM

i wany ask you something
how to make a text moving vertical
thanks
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.