P726 CEEFAX 726 Wed 3 Feb 21:06/00 |B2201207 ANIMATION DCHNIQUES WITH GRAVITY W writing a game, or any program in which movement of graphics sprites  rated, it is often desirable to make ce rtain characters move  t we experience in lifeN Gravity is one of these  d in a program the effects can be quite interesting (or startling when they go wrong!). G on all bodies that have mass, but becaus e a  in computer memory) we have to  an artificial gravity into the animatio nN The introduction of  applications which include the movement of a bouncing  thdn speeding up of a sprite when it ju mps up  ealistic swing of a rope in games like H UNCHBACK. ghen applied in a horizontal p lane thf mfthods descibed can 
P726 CEEFAX 726 Wed 3 Feb 21:00/00 |B2202207|a17GravTxt|i14 DXT|m336D|s÷n1÷ ee used to simulate, for example, snookd r balls on a table that has  P ROJECTILE MOVEMENT P al purpose ball throwing program (!)N Va rious  thdre effects upon the balls movement  n be seen by altering 9 different values These parameters are altered  ng the corresponding number and then, if a numbfr is required the  ed to enter a value, otherwise if the op tion is of a YES/NO  toggleN The default values are such tha p the ball  ' and then return to ground. The after i mage  option 8, as can the line references. A few points may be noted :  TX ocity and the Y velocity are TOTALLY ind ependant of each  NTX ty rem—hns constant throughout the motio n bdcause thfre is 
P726 CEEFAX 726 Wed 3 Feb 21:04/11 |B2203207|a17GravTxt|i14TEXT|m36D8|s÷n1÷ egravity) acting in the X plane. T initial Y velocity will, in general, be large to start with, reduce  gets highfr until it stops, and then it will begin to gain  ck down to the ground. B he X velocity it may bf sfen that the ra nge of the ball is  ball can travel further to the right be fore it  T way to understand what is going on is t o simply play with the  HOGRA VITY IS SIMULATED T all sses simple animation techniques, an d the  d on line 370N The variable 'yvel%'  s a value that reprfsents thf Y velocity of the ball i.eN it is the  xils which are fumped during subsequent plotting of the ball. T el%' is large so that the ball appears t o move fast, but 
P726 CEEFAX 726 Wed 3 Feb 21:00/10 |B2204207|a17GravTxt|i14TEXT|m3A43|s÷n1÷ ey decreased by subtracting a value held in 'gravity' so  o slow down as it gets higherN Eventuall y 'yvdl%'  t will bdcome negative (i.e a -ve  ity), so the ball will slowly begin to m ove in the opposite direction  ather speedN The variable 'gravity' repr esents the rate of Y ity (its acceleration, or 'the gravitati onal field  CI BLARMOHFN AND GRAVITY the pendulum  are also effected by  t becomes more difficult to simulate the ir motion on a  is to take each force in turn and progra m the  e on the body one at a timeN For  , a true pendulum bob moves in a circlul ar arc and is effected by  ting in oscillations of the pendulum|c
P726 CEEFAX 726 Wed 3 Feb 21:04/00 |B2205207 eN This can be simulated  y firstly making a ball move in a circle on the screen and  ram 1, it is simply a matter of altering the velocity  ages of its motion. P true pendulum motionN It was written by firstly  ing two SINE waves 90 degrees out of pha se  aking a graphic character move in  ircleN Having achieved this, the initial position of the bob is  the pendulum is allowed to rotate in a circular path  N The procedure 'xy' calculates the x-y position  n 'pos') of the circle. Thus, to obtain circuler motion it is simply a matter of giving 'pos' consecutive values  to 360 dgrfes and plotting each x-y corr dinate for the 
P726 CEEFAX 726 Wed 3 Feb 21:04/01 |B2206207 ÷ef 'posg. H m to start from a horizontal position, s o the  0 degrees (line 240)N The speed of the ob is deterlhned by the step rate of thf angle through which the bob N thf rate of change of 'pos')N dhis step rate is hfld in the  f, for example, gvel' = 10, thfn the bob would move in  egreesN It is now a simple matter to int roduce  by increasing the velocity of the bob a s T . TNB se the velocity is constantly  from a positive value as it swings down wards, it will never N nt at which the velocity will begin to g et slower, so  antly accelerating bob moving in a circl eN Thus 
P726 CEEFAX 726 Wed 3 Feb 21:00/00 |B2207207|a17GravTxt|i14TEXT|m41483|s÷n1 ÷ehereby once the bob rdaches a certain velocity, the sign of the gravity is cha nged resulting in the bob slowing  ntil it eventually stops at the top of i ts swing (see lines NA ely, the sign of 'gravity' could be swap ped when the  degrees, but you have to makf sure that 'pos'  egrees at some point of the swing. ROB ANDERSONN SEP DDBER 