Thursday, April 3, 2008

Score, Timer, and Collision: Flash Code Examples

This was Bill's question...

Does anyone have actionscript coding for a game timer (countdown), score keeper (hittest), and drawing walls that stop character movement that work in FLASH MX2004? My kids had started their game on that platform and those are the last 3 major issues to make a fully functional game.

[[Bill]] 15:59, 1 April 2008 (EDT)


I was wondering if anyone out there could point us to some good code examples? These are very common game elements so am thinking it would be great collect several examples around each concept. I posted here first, now I will go and search around the web. I'll let you know if I find anything.

3 comments:

Steward Deering said...

I'm not sure on what kind of game it is but this link may be useful :

http://www.bezzmedia.com/swfspot/tutorials/intermediate/Create_Pong

http://www.developmentnow.com/g/68_2004_5_0_0_317876/how-to-keep-score.htm

http://www.actionscript.org/actionscripts_library/main/search.cgi?query=countdown+timer

Patrick Smith said...

I know that RTC had a game called Phat Phoods that had a maze collision detection system. As for whether the code will work in MX2004, as long as it is ActionScript 2, there shouldn't be any problems I don't believe. My tutorial on collision detection:
http://www.myglife.org/usa/wv/mctcwiki/index.php/Collision_Detection_and_Keyboard_Input
could be modified that in the collision detection loop to increment a variable that could count as a score keeper I suppose.
As for a simple game timer...one could create a movie clip that lasts 12 frames(assuming your flash movie is 12 frames per second). On the 12th frame, you could put Actionscript code that took a particular variable(lets say a variable that represented 300 seconds) and subtracted 1 from it. That would take one unit away per second when that movie clip would run.

Hope this helps.

Lee Kraus said...

Thanks guys! I really appreciate it. I'll check with Denise on this as well. I was there the day she was coding the collision detection.

Lee