shena forga

shena forga

  • NA
  • 7
  • 0

C# X and Y problems of a picture box

Sep 12 2009 12:08 PM
Ok heres the layout:

I have two picture boxs that move around and are meant to bounce off the sides of the form they are on. This is part of the code i have for that:

private void timer1_Tick(object sender, EventArgs e)

{

if (clicked)

{

Point p = bball.Location;

p.X += 1;

p.Y += 1;

bball.Location = p;

Point p2 = rball.Location;

p2.X += 1;

p2.Y += 1;

rball.Location = p2;

}

if (moving)

{

if (bball.Y > bball)

vy = Math.Abs(vy) * -1;

else if (bball.Y < bouncetop)

vy = Math.Abs(vy);

if (bball.X > bounceright)

vx = Math.Abs(vx) * -1;

else if (bball.X < bounceleft)

vx = Math.Abs(vx);

}

}

X and Y are throwing lots of errors if "if (moving)". Even if i made a point like the first part of the timer, it says < and > cant be used. bball is a picture box on the form already made. Shouldn't the picture box already have and x and y to it...? I'm having trouble finding what code works for this.


Answers (2)