Results 1 to 8 of 8

Thread: [RESOLVED] placing objects in frame

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    19

    Resolved [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:
    1. Private Sub cmdDown_Click()
    2.     imgHand.Top = imgHand.Top + 100     'moves image down
    3.     If imgHand.Top > 4000 Then imgHand.Top = 3900  'stops the image from leaving the frame
    4.     Call collission
    5. End Sub
    6.  
    7. Private Sub cmdExit_Click()
    8.     End         'ends program
    9.    
    10. End Sub
    11.  
    12. Private Sub cmdLeft_Click()
    13.     imgHand.Left = imgHand.Left - 100   'moves the image left
    14.     If imgHand.Left < 0 Then imgHand.Left = 480 'stops the image from leaving the frame
    15.     Call collission
    16. End Sub
    17.  
    18. Private Sub cmdRight_Click()
    19.     imgHand.Left = imgHand.Left + 100       'moves the image right
    20.     If imgHand.Left > 9000 Then imgHand.Left = 8900 'stops the image from leaving the frame
    21.     Call collission
    22. End Sub
    23.  
    24. [COLOR=Blue]Private Sub cmdStart_Click()
    25.  
    26.          imgBell.Visible = False
    27. End Sub[/COLOR]
    28. Private Sub cmdUp_Click()
    29.    imgHand.Top = imgHand.Top - 100     'moves image up
    30.    If imgHand.Top < 0 Then imgHand.Top = 120    'stops the image from leaving the frame
    31.    Call collission
    32. End Sub
    33.  
    34. Private Sub collission()
    35.  
    36.  
    37.   If imgBell.Top + imgBell.Height >= imgHand.Top - 100 _
    38.         And imgBell.Top <= imgHand.Top + imgHand.Height + 100 _
    39.         And imgBell.Left + imgBell.Width >= imgHand.Left - 100 _
    40.         And imgBell.Left <= imgHand.Left + imgHand.Width + 100 Then
    41.             imgBell.Visible = True  'this is the collission programe
    42.             MsgBox " ouch! "        'the message will appear when the objects collides
    43.     End If
    44.    
    45. End Sub






    Edit: Added [vbcode][/vbcode] tags for more clarity. - Hack
    Last edited by Hack; Nov 17th, 2005 at 07:15 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: placing objects in frame

    A question better suited to folks well versed in Graphics programming. Moved to Games and Graphics.

  3. #3
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    19

    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.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    19

    Re: placing objects in frame

    sorry hack but i am new to this

  6. #6
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    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:
    1. Private Sub cmdStart_Click()
    2.  
    3.     Randomize
    4.  
    5.     imgBell.Visible = False
    6.     imgBell.Left = Rnd * Me.ScaleWidth / 2
    7.     imgBell.Top = Rnd * Me.ScaleHeight / 2
    8.  
    9. End Sub

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: placing objects in frame

    Quote Originally Posted by kkman
    sorry hack but i am new to this
    There is nothing to be sorry for.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    19

    Resolved 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
  •  



Click Here to Expand Forum to Full Width