|
-
Nov 17th, 2005, 06:19 AM
#1
Thread Starter
Junior Member
[RESOLVED] placing objects in frame
below is a project i am working on can someone help me i need to make the bell object move around the frame when i press the start button.
VB Code:
Private Sub cmdDown_Click()
imgHand.Top = imgHand.Top + 100 'moves image down
If imgHand.Top > 4000 Then imgHand.Top = 3900 'stops the image from leaving the frame
Call collission
End Sub
Private Sub cmdExit_Click()
End 'ends program
End Sub
Private Sub cmdLeft_Click()
imgHand.Left = imgHand.Left - 100 'moves the image left
If imgHand.Left < 0 Then imgHand.Left = 480 'stops the image from leaving the frame
Call collission
End Sub
Private Sub cmdRight_Click()
imgHand.Left = imgHand.Left + 100 'moves the image right
If imgHand.Left > 9000 Then imgHand.Left = 8900 'stops the image from leaving the frame
Call collission
End Sub
[COLOR=Blue]Private Sub cmdStart_Click()
imgBell.Visible = False
End Sub[/COLOR]
Private Sub cmdUp_Click()
imgHand.Top = imgHand.Top - 100 'moves image up
If imgHand.Top < 0 Then imgHand.Top = 120 'stops the image from leaving the frame
Call collission
End Sub
Private Sub collission()
If imgBell.Top + imgBell.Height >= imgHand.Top - 100 _
And imgBell.Top <= imgHand.Top + imgHand.Height + 100 _
And imgBell.Left + imgBell.Width >= imgHand.Left - 100 _
And imgBell.Left <= imgHand.Left + imgHand.Width + 100 Then
imgBell.Visible = True 'this is the collission programe
MsgBox " ouch! " 'the message will appear when the objects collides
End If
End Sub
Edit: Added [vbcode][/vbcode] tags for more clarity. - Hack
Last edited by Hack; Nov 17th, 2005 at 07:15 AM.
-
Nov 17th, 2005, 07:16 AM
#2
Re: placing objects in frame
A question better suited to folks well versed in Graphics programming. Moved to Games and Graphics.
-
Nov 17th, 2005, 09:34 AM
#3
Re: placing objects in frame
What do you mean by move around the frame? I think it's best that you upload your project so I can fix your problem.
-
Nov 17th, 2005, 11:09 AM
#4
Thread Starter
Junior Member
Re: placing objects in frame
by move around the frame i mean the hand is trying to find the bell. once it finds it the bell is visable. and a message aspears. i just need to get the bell to move to different places every time you press the start button.
-
Nov 17th, 2005, 11:39 AM
#5
Thread Starter
Junior Member
Re: placing objects in frame
sorry hack but i am new to this
-
Nov 17th, 2005, 12:21 PM
#6
Re: placing objects in frame
I noticed you are using big numbers for coordinates. You should change the scalemode property of your form and pictureboxes to 3 - Pixels. I have no idea why Microsoft made Twips the default, but when it comes to games, Pixels is the way to go. As for your problem, try this:
VB Code:
Private Sub cmdStart_Click()
Randomize
imgBell.Visible = False
imgBell.Left = Rnd * Me.ScaleWidth / 2
imgBell.Top = Rnd * Me.ScaleHeight / 2
End Sub
-
Nov 17th, 2005, 03:03 PM
#7
Re: placing objects in frame
 Originally Posted by kkman
sorry hack but i am new to this
There is nothing to be sorry for.
-
Nov 17th, 2005, 05:32 PM
#8
Thread Starter
Junior Member
Re: placing objects in frame
thanks just what the dr. ordered
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|