Code doesn't like second bounce, please help?



  • <FONT color=#0000ff size=2>

    Imports</FONT><FONT size=2> System.Drawing.Drawing2D

    </FONT><FONT color=#0000ff size=2>

    Imports</FONT><FONT size=2> System.Math

    </FONT><FONT color=#0000ff size=2>

    Imports</FONT><FONT size=2> System.IO

    </FONT><FONT color=#0000ff size=2>

    Imports</FONT><FONT size=2> System.Uri

    </FONT><FONT color=#0000ff size=2>

    Imports</FONT><FONT size=2> System.Threading

    </FONT><FONT color=#0000ff size=2>Public</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Class</FONT><FONT size=2> Form1</FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> ht0 </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> time </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> cht </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> v0 </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> v </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> x </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer</FONT><FONT size=2> = 10</FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> t </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal</FONT><FONT size=2> = 0

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> fht </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> fw </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> mindrop </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> maxdrop </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> curdrop </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> ball </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Bitmap = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Bitmap(</FONT><FONT color=#a31515 size=2>"ball.bmp"</FONT><FONT size=2>)</FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> shadow </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Bitmap = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Bitmap(</FONT><FONT color=#a31515 size=2>"shadow.bmp"</FONT><FONT size=2>)

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> ground </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Bitmap = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Bitmap(</FONT><FONT color=#a31515 size=2>"ground.bmp"</FONT><FONT size=2>)</FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> background </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Bitmap = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Bitmap(</FONT><FONT color=#a31515 size=2>"background.bmp"</FONT><FONT size=2>)

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> rball </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Rectangle</FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> rshadow </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Rectangle

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> rground </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Rectangle</FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> canvas </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Graphics

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> bht </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> gen </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Random</FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> count </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer</FONT><FONT size=2> = 0

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> done = </FONT><FONT color=#0000ff size=2>False</FONT><FONT size=2> </FONT><FONT color=#008000 size=2>'True

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> bounce </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> curht2 </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Decimal

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> vrand </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> terfont </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Font = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Font(</FONT><FONT color=#a31515 size=2>"symbol"</FONT><FONT size=2>, 12, FontStyle.Regular, GraphicsUnit.Pixel, 0)</FONT></FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Sub</FONT><FONT size=2> runbtn_Click(</FONT><FONT color=#0000ff size=2>ByVal</FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> System.Object, </FONT><FONT color=#0000ff size=2>ByVal</FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> System.EventArgs) </FONT><FONT color=#0000ff size=2>Handles</FONT><FONT size=2> runbtn.Click</FONT></FONT><FONT size=2>

    bounce = 0

    curht2 = 0

    curht.Text = curht2

    bounceht.Text = curht2

    mindrop = mindrop_txt.Text

    maxdrop = maxdrop_txt.Text

    t = 0

    v = 0

    ball.MakeTransparent(Color.Blue)

    shadow.MakeTransparent(Color.Blue)

    canvas = PicAnim.CreateGraphics

    fht = PicAnim.Height

    fw = PicAnim.Width

    bht = ball.Height

    ht0 = 0

    cht = ht0

    count = 0

    </FONT><FONT color=#0000ff size=2>If</FONT><FONT size=2> maxdrop > 375 </FONT><FONT color=#0000ff size=2>Then

    </FONT><FONT size=2>

    maxdrop = 375

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>If</FONT><FONT size=2> mindrop > 370 </FONT><FONT color=#0000ff size=2>Then

    </FONT><FONT size=2>

    mindrop = 370

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If

    </FONT><FONT size=2>

    curdrop = gen.Next(mindrop, maxdrop)

    v0 = gen.Next(gen.Next(2000))

    </FONT><FONT color=#0000ff size=2>If</FONT><FONT size=2> v0 > 200 </FONT><FONT color=#0000ff size=2>Then

    </FONT><FONT size=2>

    v0 = v0 / 10

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If

    </FONT><FONT size=2>rground = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Rectangle(0, curdrop, fw, fht - curdrop)</FONT></FONT><FONT size=2>

    rshadow = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Rectangle(x, curdrop, shadow.Width, shadow.Height)

    rball = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Rectangle(x, cht, ball.Width, ball.Height)</FONT></FONT><FONT size=2>

    canvas.DrawImage(background, 0, 0)

    canvas.DrawImage(ground, rground)

    canvas.DrawImage(shadow, rshadow)

    canvas.DrawImage(ball, rball)

    </FONT><FONT color=#0000ff size=2>Do

    </FONT><FONT size=2>

    Thread.Sleep(10)

    ter1()

    Thread.Sleep(10)

    </FONT><FONT color=#0000ff size=2>If</FONT><FONT size=2> (cht + bht) > curdrop </FONT><FONT color=#0000ff size=2>Then

    </FONT><FONT size=2>

    count = 1

    </FONT><FONT color=#0000ff size=2>Else

    </FONT><FONT size=2>rball = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Rectangle(x, cht, ball.Width, bht)</FONT></FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(10)

    </FONT><FONT size=2>

    canvas.DrawImage(background, 0, 0)

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(10)

    </FONT><FONT size=2>

    canvas.DrawImage(ground, rground)

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(10)

    </FONT><FONT size=2>

    canvas.DrawImage(shadow, rshadow)

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(10)

    </FONT><FONT size=2>

    canvas.DrawImage(ball, rball)

    Thread.Sleep(40)

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Loop</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Until</FONT><FONT size=2> count > 0</FONT></FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>' Do

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'vrand = gen.Next(10)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>' Thread.Sleep(20)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'v0 = (curdrop - (cht + bht) - vrand) '* -1

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'t = 0

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'bounceht.Text = 0

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'ht0 = curdrop '* -1

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'cht = 0

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>canvas.DrawString(</FONT><FONT color=#a31515 size=2>"Sorry this is just a demo, rest of code there but won't work"</FONT><FONT size=2>, terfont, Brushes.Silver, 10, 380)</FONT></FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Do

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'ter2()

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(20)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'If (cht + bht) > curdrop Then

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'count = 1

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Else

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'rball = New Rectangle(x, cht, ball.Width, bht)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'canvas.DrawImage(background, 0, 0)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'canvas.DrawImage(ground, rground)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'canvas.DrawImage(shadow, rshadow)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'canvas.DrawImage(ball, rball)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'End If

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Loop Until (cht + bht) > curdrop

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Thread.Sleep(5)

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>'Loop Until done = True

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Sub

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Function</FONT><FONT size=2> ter1()</FONT></FONT><FONT size=2>

    cht = v - (v0 * t) - ht0

    Thread.Sleep(10)

    t = t + 0.1

    Thread.Sleep(10)

    v = 16 * (t ^ 2)

    Thread.Sleep(10)

     

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Function

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Function</FONT><FONT size=2> ter2()</FONT></FONT><FONT size=2>

    cht = v - ((v0 + ht0) * t) + ht0

    Thread.Sleep(5)

    t = t + 0.1

    Thread.Sleep(5)

    v = 16 * t ^ 2

    Thread.Sleep(5)

    curht2 = (ht0 - cht)

    Thread.Sleep(5)

    </FONT><FONT color=#008000 size=2>'curht.Text = curht2

    </FONT><FONT size=2>

    Thread.Sleep(5)

    </FONT><FONT color=#0000ff size=2>If</FONT><FONT size=2> curht2 > bounce </FONT><FONT color=#0000ff size=2>Then

    </FONT><FONT size=2>

    bounce = curht2

    Thread.Sleep(5)

    </FONT><FONT color=#008000 size=2>'bounceht.Text = bounce

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Else

    </FONT><FONT size=2>

    Thread.Sleep(5)

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Function

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>Private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Sub</FONT><FONT size=2> stopbtn_Click(</FONT><FONT color=#0000ff size=2>ByVal</FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> System.Object, </FONT><FONT color=#0000ff size=2>ByVal</FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> System.EventArgs) </FONT><FONT color=#0000ff size=2>Handles</FONT><FONT size=2> stopbtn.Click</FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>If</FONT><FONT size=2> done = </FONT><FONT color=#0000ff size=2>False</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Then

    </FONT><FONT size=2>

    done = </FONT><FONT color=#0000ff size=2>True

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Else

    </FONT><FONT size=2>

    Close()

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If

    </FONT><FONT size=2></FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT color=#0000ff size=2>

    End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Class

    </FONT>


  • So that's where all the missing linebreaks went!



  • Code doesn't like second bounce, please help?

    Easy. Your duractance is not optimal. Just cross-triage the logarithmic carburetor on line 15. 



  • Re: Code doesn't like second bounce, please help? Code has now been indented.

    @Steeldragon said:

    <font color="#0000ff" size="2"> </font>

    <font color="#0000ff" size="2">Imports</font><font size="2"> System.Drawing.Drawing2D</font>

    <font size="2"></font><font color="#0000ff" size="2"> </font>

    <font color="#0000ff" size="2">Imports</font><font size="2"> System.Math</font>

    <font size="2"></font><font color="#0000ff" size="2"> </font>

    <font color="#0000ff" size="2">Imports</font><font size="2"> System.IO</font>

    <font size="2"></font><font color="#0000ff" size="2"> </font>

    <font color="#0000ff" size="2">Imports</font><font size="2"> System.Uri</font>

    <font size="2"></font><font color="#0000ff" size="2"> </font>

    <font color="#0000ff" size="2">Imports</font><font size="2"> System.Threading</font>

    <font size="2"></font><font color="#0000ff" size="2">Public</font><font size="2"> </font><font color="#0000ff" size="2">Class</font><font size="2"> Form1</font><font size="2"> </font>

    <font color="#0000ff" size="2">    Private</font><font size="2"> ht0 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    Private</font><font size="2"> time </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> cht </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> v0 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> v </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> x </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Integer</font><font size="2"> = 10</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> t </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font><font size="2"> = 0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> fht </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Integer</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> fw </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Integer</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> mindrop </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Integer</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> maxdrop </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Integer</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> curdrop </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Integer</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> ball </font><font color="#0000ff" size="2">As</font><font size="2"> Bitmap = </font><font color="#0000ff" size="2">New</font><font size="2"> Bitmap(</font><font color="#a31515" size="2">"ball.bmp"</font><font size="2">)</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> shadow </font><font color="#0000ff" size="2">As</font><font size="2"> Bitmap = </font><font color="#0000ff" size="2">New</font><font size="2"> Bitmap(</font><font color="#a31515" size="2">"shadow.bmp"</font><font size="2">)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> ground </font><font color="#0000ff" size="2">As</font><font size="2"> Bitmap = </font><font color="#0000ff" size="2">New</font><font size="2"> Bitmap(</font><font color="#a31515" size="2">"ground.bmp"</font><font size="2">)</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2"></font><font color="#0000ff" size="2">Private</font><font size="2"> background </font><font color="#0000ff" size="2">As</font><font size="2"> Bitmap = </font><font color="#0000ff" size="2">New</font><font size="2"> Bitmap(</font><font color="#a31515" size="2">"background.bmp"</font><font size="2">)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> rball </font><font color="#0000ff" size="2">As</font><font size="2"> Rectangle</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> rshadow </font><font color="#0000ff" size="2">As</font><font size="2"> Rectangle</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> rground </font><font color="#0000ff" size="2">As</font><font size="2"> Rectangle</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> canvas </font><font color="#0000ff" size="2">As</font><font size="2"> Graphics</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> bht </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> gen </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">New</font><font size="2"> Random</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> count </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Integer</font><font size="2"> = 0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> done = </font><font color="#0000ff" size="2">False</font><font size="2"> </font><font color="#008000" size="2">'True</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> bounce </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> curht2 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Decimal</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> vrand </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Integer</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> terfont </font><font color="#0000ff" size="2">As</font><font size="2"> Font = </font><font color="#0000ff" size="2">New</font><font size="2"> Font(</font><font color="#a31515" size="2">"symbol"</font><font size="2">, 12, FontStyle.Regular, GraphicsUnit.Pixel, 0)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Private</font><font size="2"> </font><font color="#0000ff" size="2">Sub</font><font size="2"> runbtn_Click(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> sender </font><font color="#0000ff" size="2">As</font><font size="2"> System.Object, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> e </font><font color="#0000ff" size="2">As</font><font size="2"> System.EventArgs) </font><font color="#0000ff" size="2">Handles</font><font size="2"> runbtn.Click</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">bounce = 0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">curht2 = 0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">curht.Text = curht2</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">bounceht.Text = curht2</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">mindrop = mindrop_txt.Text</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">maxdrop = maxdrop_txt.Text</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">t = 0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">v = 0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">ball.MakeTransparent(Color.Blue)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">shadow.MakeTransparent(Color.Blue)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas = PicAnim.CreateGraphics</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">fht = PicAnim.Height</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">fw = PicAnim.Width</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">bht = ball.Height</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">ht0 = 0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">cht = ht0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">count = 0</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">If</font><font size="2"> maxdrop > 375 </font><font color="#0000ff" size="2">Then</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">maxdrop = 375</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">If</font><font size="2"> mindrop > 370 </font><font color="#0000ff" size="2">Then</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">mindrop = 370</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">curdrop = gen.Next(mindrop, maxdrop)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">v0 = gen.Next(gen.Next(2000))</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">If</font><font size="2"> v0 > 200 </font><font color="#0000ff" size="2">Then</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">v0 = v0 / 10</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">rground = </font><font color="#0000ff" size="2">New</font><font size="2"> Rectangle(0, curdrop, fw, fht - curdrop)</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">rshadow = </font><font color="#0000ff" size="2">New</font><font size="2"> Rectangle(x, curdrop, shadow.Width, shadow.Height)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">rball = </font><font color="#0000ff" size="2">New</font><font size="2"> Rectangle(x, cht, ball.Width, ball.Height)</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawImage(background, 0, 0)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawImage(ground, rground)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawImage(shadow, rshadow)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawImage(ball, rball)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Do</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">Thread.Sleep(10)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">ter1()</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">Thread.Sleep(10)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">If</font><font size="2"> (cht + bht) > curdrop </font><font color="#0000ff" size="2">Then</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">count = 1</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Else</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">rball = </font><font color="#0000ff" size="2">New</font><font size="2"> Rectangle(x, cht, ball.Width, bht)</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(10)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawImage(background, 0, 0)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(10)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawImage(ground, rground)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(10)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawImage(shadow, rshadow)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(10)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawImage(ball, rball)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">Thread.Sleep(40)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">Loop</font><font size="2"> </font><font color="#0000ff" size="2">Until</font><font size="2"> count > 0</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">' Do</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'vrand = gen.Next(10)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">' Thread.Sleep(20)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'v0 = (curdrop - (cht + bht) - vrand) '* -1</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'t = 0</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'bounceht.Text = 0</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'ht0 = curdrop '* -1</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'cht = 0</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font size="2">canvas.DrawString(</font><font color="#a31515" size="2">"Sorry this is just a demo, rest of code there but won't work"</font><font size="2">, terfont, Brushes.Silver, 10, 380)</font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Do</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'ter2()</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Thread.Sleep(20)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'If (cht + bht) > curdrop Then</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">        </font><font color="#008000" size="2">'count = 1</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'Else</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'rball = New Rectangle(x, cht, ball.Width, bht)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'canvas.DrawImage(background, 0, 0)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'canvas.DrawImage(ground, rground)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'canvas.DrawImage(shadow, rshadow)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'canvas.DrawImage(ball, rball)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">       </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#008000" size="2">'End If</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2"></font><font color="#008000" size="2">'Loop Until (cht + bht) > curdrop</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">     </font><font color="#008000" size="2">'Thread.Sleep(5)</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">    </font><font color="#0000ff" size="2">  </font><font color="#008000" size="2">'Loop Until done = True</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     End</font><font size="2"> </font><font color="#0000ff" size="2">Sub</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">Function</font><font size="2"> ter1()</font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">cht = v - (v0 * t) - ht0</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(10)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">t = t + 0.1</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(10)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">v = 16 * (t ^ 2)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(10)</font>

    <font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Function</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">Function</font><font size="2"> ter2()</font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">cht = v - ((v0 + ht0) * t) + ht0</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(5)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">t = t + 0.1</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(5)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">v = 16 * t ^ 2</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(5)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">curht2 = (ht0 - cht)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(5)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#008000" size="2">'curht.Text = curht2</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(5)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">If</font><font size="2"> curht2 > bounce </font><font color="#0000ff" size="2">Then</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">bounce = curht2</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(5)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#008000" size="2">'bounceht.Text = bounce</font>

    <font color="#008000" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">Else</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Thread.Sleep(5)</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Function</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">Private</font><font size="2"> </font><font color="#0000ff" size="2">Sub</font><font size="2"> stopbtn_Click(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> sender </font><font color="#0000ff" size="2">As</font><font size="2"> System.Object, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> e </font><font color="#0000ff" size="2">As</font><font size="2"> System.EventArgs) </font><font color="#0000ff" size="2">Handles</font><font size="2"> stopbtn.Click</font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">If</font><font size="2"> done = </font><font color="#0000ff" size="2">False</font><font size="2"> </font><font color="#0000ff" size="2">Then</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">done = </font><font color="#0000ff" size="2">True</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">Else</font>

    <font color="#0000ff" size="2"></font><font size="2"> </font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font size="2">Close()</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If</font>

    <font color="#0000ff" size="2">     </font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Sub</font><font color="#0000ff" size="2"> </font>

    <font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Class</font>

    sorry about earlier, but i posted in less than a minute. This code is supposed to show the law of falling objects, and said object is supposed to bounce afterwards. v0 is the initial upwards velocity, mindrop & maxdrop are masked textboxes, and ht0 is the initial height. The code is VB EE 08 and always freezes in the nested do loop. any help would be appreciated. Take out the apostrophies on the commented lines to run it. Ball is just a ball image, and for the others, well, you can use anything.


  • @Steeldragon said:

    [lots of terrible, terrible VB]@Steeldragon said:
    sorry about earlier, but i posted in less than a minute. This code is supposed to show the law of falling objects, and said object is supposed to bounce afterwards. v0 is the initial upwards velocity, mindrop & maxdrop are masked textboxes, and ht0 is the initial height. The code is VB EE 08 and always freezes in the nested do loop. any help would be appreciated. Take out the apostrophies on the commented lines to run it. Ball is just a ball image, and for the others, well, you can use anything.
    Alright, some advice: use a service like Pastebin instead of relying on our terrible forum software to post code. It's OK to post a snippet directly on the forums when it's small, but in this case it's just too much. You'll find Pastebin to be very useful for this kind of thing (because that's what it's for).

    The other thing is explain the code you're posting more clearly. You've got no actual code comments in this mess, and we only have a small description that doesn't hope to explain the dozens of global variables you've thoughtfully named things like "cht" and "v", along with functions named "ter1" and "ter2". If your variables and functions are named reasonably, you generally don't have to document your code with comments. In your case, though, you really need to provide a better description of this code.

    Don't give us a mess of code, then tell us to uncomment some of it. Just give us the code you want us to look at, with a description sufficient so that we don't have to wade through variable soup to figure out what the heck you're trying to do.



  • Only a cursory examination, but it appears you may have the test wrong in the nested loop. When you drop the ball, and it is moving down, you test "<FONT color=#008000>(cht + bht) > curdrop</FONT>". When the ball bounces and is moving up, you continue to use the same test. Since (cht + bht) are now going down instead of up, the loop will never terminate.



  • @CDarklock said:

    Only a cursory examination, but it appears you may have the test wrong in the nested loop. When you drop the ball, and it is moving down, you test "<FONT color=#008000>(cht + bht) > curdrop</FONT>". When the ball bounces and is moving up, you continue to use the same test. Since (cht + bht) are now going down instead of up, the loop will never terminate.

    thx, but it'sa bit too late. assessment is over. Will keep in mind though.



  •  "Assessment is over"? Ugh, this guy was trying to get help on an EXAM? I see...  so testing "(cht + bht) > curdrop" means "if amount of cheating 'cht' plus the bone-headedness of the teacher 'bht' is greater than the threshold necessary for forcing withdrawal from the course 'curdrop'"... wait, that doesn't make sense, the teacher's boneheadedness should be on the other side of the equation, canceling out the cheating! Hmm, our educational system truly is flawed...



  • @ekolis said:

     "Assessment is over"? Ugh, this guy was trying to get help on an EXAM? I see...  so testing "(cht + bht) > curdrop" means "if amount of cheating 'cht' plus the bone-headedness of the teacher 'bht' is greater than the threshold necessary for forcing withdrawal from the course 'curdrop'"... wait, that doesn't make sense, the teacher's boneheadedness should be on the other side of the equation, canceling out the cheating! Hmm, our educational system truly is flawed...

    assessment=in class assignment that's actually graded. Now it's time for the quarter-long assessment.

    cht=current height

    bht=size of the ball along the Y axis

    curdrop= how far the ball has to fall.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.