How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce
How To Make A Picture Box Bounce How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
Go Back  Xtreme Visual Basic Talk > > > How To Make A Picture Box Bounce


Reply
 
Thread Tools Display Modes
  #1  
Old 12-19-2009, 05:38 PM
soccerkid1122 soccerkid1122 is offline
Newcomer
 
Join Date: Dec 2009
Posts: 6
Exclamation How To Make A Picture Box Bounce


Hi, Im New To VB and i was wondeing how do you make a picture box bounce from the sides of the form.

Thanks In Advance
Reply With Quote
  #2  
Old 12-19-2009, 07:46 PM
Iceplug's Avatar
IceplugHow To Make A Picture Box Bounce Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

By storing the x and y components of velocity in variables and moving the .Left and .Top property of the picturebox based on the value of these variables.

Such that when the left side of the picturebox is less than 0, the variable which controls the .Left property is subtracted from zero, making it positive from a negative number, causing the object to move in the opposite direction.

Similarly, since .Left + .Width corresponds to the right edge of the picturebox, when the right edge of the picturebox exceeds the .Scalewidth of the form, the variable which controls the speed is negated again, causing the object to move in the opposite direction.

Search for bouncing off of form sides. I'm sure that I've answered this question many times in the Game Programming Forum
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 12-19-2009, 09:08 PM
soccerkid1122 soccerkid1122 is offline
Newcomer
 
Join Date: Dec 2009
Posts: 6
Default

if you can would you be able to find me the code and post it on this thread? Please & Thank You, Also let me knw what to put on the designing form.

Thnks Again
Reply With Quote
  #4  
Old 12-19-2009, 09:19 PM
soccerkid1122 soccerkid1122 is offline
Newcomer
 
Join Date: Dec 2009
Posts: 6
Default

i do have the basic code but it gives me errors at places and i dont know why :S thats why i wanted to try sumthing different.. :\
Reply With Quote
  #5  
Old 12-20-2009, 08:07 AM
Iceplug's Avatar
IceplugHow To Make A Picture Box Bounce Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

This isn't a program restaurant where you just walk up and order what you want.
Read the posting guidelines - you have to be able to experiment on your own. There are no irreversible effects from coding in native VB commands.
Bouncing algorithm?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #6  
Old 12-20-2009, 04:38 PM
soccerkid1122 soccerkid1122 is offline
Newcomer
 
Join Date: Dec 2009
Posts: 6
Default

Quote:
Public Class Form1
Dim velX As Integer
Dim velY As Integer

Dim maxX As Integer
Dim maxY As Integer

Dim X As Integer
Dim Y As Integer



Private Sub Form1_Load()

Me.ScaleMode = 3
Picture1.ScaleMode = 3

velX = 3
velY = 3

maxX = Me.ScaleWidth - Picture1.ScaleWidth
maxY = Me.ScaleHeight - Picture1.ScaleHeight

X = 0
Y = 0
End Sub
Private Sub Timer1_Timer()
X = X + velX
Y = Y + velY

If X <= 0 Or X >= maxX Then
velX = -velX
End If

If Y <= 0 Or Y >= maxY Then
velY = -velY
End If
End Sub
End Class

The bolded letters are the areas where im getting an error, if you can find out the solution please let me know.

Thanks Again
Reply With Quote
  #7  
Old 12-20-2009, 04:41 PM
Iceplug's Avatar
IceplugHow To Make A Picture Box Bounce Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

What version of VB are you running?
Because Public Class Form1 isn't something you'd expect to see in VB.NET?
If you are using VB.NET, then there's no need to set the scalemode and you'd use ClientSize.Width instead of ScaleWidth
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #8  
Old 12-20-2009, 05:33 PM
soccerkid1122 soccerkid1122 is offline
Newcomer
 
Join Date: Dec 2009
Posts: 6
Default

I am using Microsoft Visual Basic 2008 Express Edition. i tried clientSize and it took away the error however for:
Me.ClientSize = 3
Picture1.ClientSize = 3


1 Value of type 'Integer' cannot be converted to 'System.Drawing.Size'.


any idea on that :S

Thanks Again
Reply With Quote
  #9  
Old 12-20-2009, 05:53 PM
Iceplug's Avatar
IceplugHow To Make A Picture Box Bounce Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

You should delete that as well, because that's wrong. There's no need to set anything to 3.
I highly doubt you want any portion of the size of your .NET Form to be equal to three, because you won't be able to see anything.

(unless your screen resolution is 16x12 - then I'm sure you have much bigger problems)
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
 
How To Make A Picture Box Bounce
How To Make A Picture Box Bounce
 
-->