02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 18: Sports simulations<br />

1 function move(){<br />

2 movex *= 0.95;<br />

3 movey *= 0.95;<br />

4 //Test for collisions with goal posts<br />

5 if (x < -230){<br />

6 //Blue team goal<br />

7 if ((_y-53)||(_y > 43 && y < 43)){<br />

8 //Hit <strong>to</strong>p or bot<strong>to</strong>m side<br />

9 movey *= -0.8;<br />

10 }else if (y > -53 && y < 43){<br />

11 //Red team have scored<br />

12 _root.ScoreB++;<br />

13 _root.kickOff();<br />

14 }<br />

15 }else if (x > 230){<br />

16 //Red team goal<br />

17 if ((_y-53)||(_y > 43 && y < 43)){<br />

18 //Hit <strong>to</strong>p or bot<strong>to</strong>m side<br />

19 movey *= -0.8;<br />

20 }else if (y > -53 && y < 43){<br />

21 //Blue team have scored<br />

22 _root.ScoreA++;<br />

23 _root.kickOff();<br />

24 }<br />

25 }<br />

26<br />

27 if (_currentframe

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!