Recent

Author Topic: Bouncing object  (Read 3427 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
Bouncing object
« on: February 11, 2011, 09:24:57 am »
What is the technique for coding a small panel moving/bouncing idly within a bigger panel ?
Lazarus 1.2.4 / Win 32 / THAILAND

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Bouncing object
« Reply #1 on: February 11, 2011, 11:00:26 am »
You can use TTimer for the animation. As for moving the panel can either have a separate floating point vector and Round() it to panel new position or simply:
Panel2.Left:=Panel2.Left+X_Speed;
Panel2.Top:=Panel2.Top+Y_Speed;

Count collision with Width properties and if hits, turn X or Y_Speeds around.

 

TinyPortal © 2005-2018